SpotifyDisk-node/bin/chromecast.js
2020-03-10 10:19:58 +00:00

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')
// // })
// })