Created
June 21, 2020 17:46
-
-
Save 0187773933/43399aa776923c2c3cc748ec3578b29f to your computer and use it in GitHub Desktop.
Cast Website / URL to Chromecast
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const process = require( "process" ); | |
const path = require( "path" ); | |
const global_package_path = process.argv[ 0 ].split( "/bin/node" )[ 0 ] + "/lib/node_modules"; | |
const nodecastor = require( path.join( global_package_path , "nodecastor" ) ); | |
( async ()=> { | |
// "192.168.1.102" | |
// "urn:x-cast:com.url.cast" | |
// Display Name = URL Cast Receiver | |
// APP_ID = 5CB45E5A | |
const device = new nodecastor.CastDevice({ | |
//friendlyName: 'Attic TV', | |
address: "192.168.1.102" , | |
//port: 8009 , | |
//logger: console | |
}); | |
const url_test = "https://www.windy.com/?37.892,-97.305,5"; | |
function open_url_test() { | |
return new Promise( function( resolve , reject ) { | |
try { | |
device.application( "5CB45E5A" , ( err , application ) => { | |
if ( err ) { console.log( err ); return; } | |
application.run( "urn:x-cast:com.url.cast" , ( err , session ) => { | |
if ( err ) { console.log( error ); return; } | |
console.log( session ); | |
session.send( { "type": "loc" , "url": url_test } , ( err , data ) => { | |
console.log( data ); | |
resolve(); | |
return; | |
}); | |
}); | |
}); | |
} | |
catch( error ) { console.log( error ); reject( error ); return; } | |
}); | |
} | |
device.on( "connect" , () => { | |
device.status( ( err , status ) => { | |
if ( err ) { console.log( err ); return; } | |
console.log( status ); | |
open_url_test(); | |
}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://pythonawesome.com/library-for-python-3-to-communicate-with-the-google-chromecast/