36 lines
941 B
JavaScript
36 lines
941 B
JavaScript
const ChromecastAPI = require('chromecast-api')
|
|
|
|
async function getDevice() {
|
|
const client = new ChromecastAPI()
|
|
return new Promise(function (resolve, reject) {
|
|
client.on('device', function (device) {
|
|
// console.log(device)
|
|
if (device.friendlyName === 'Downstairs') {
|
|
resolve(device);
|
|
}
|
|
})
|
|
})
|
|
}
|
|
|
|
async function test() {
|
|
var mediaURL = 'https://www.youtube.com/watch?v=pb05OXz7-Ko&list=PLATQ8iWXs4GzKzUhHyImBCvVVQWkTnmeM';
|
|
test = await getDevice()
|
|
console.log(test)
|
|
test.play(mediaURL, function (err) {
|
|
if (!err) console.log('Playing in your chromecast')
|
|
})
|
|
}
|
|
|
|
test()
|
|
|
|
// console.log(device)
|
|
// if (device.friendlyName === 'Downstairs') {
|
|
// test.friendlyName = device.friendlyName,
|
|
// test.name = device.name,
|
|
// test.host = device.host
|
|
// }
|
|
|
|
// // device.play(mediaURL, function (err) {
|
|
// // if (!err) console.log('Playing in your chromecast')
|
|
// // })
|
|
// })
|