forked from iobroker-community-adapters/castv2-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelloWorld.js
32 lines (30 loc) · 988 Bytes
/
helloWorld.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"use strict"
let playerName = ".."; //Change to "catstv2-player to execute outside this folder
var ScannerPromise = require(playerName).ScannerPromise();
var MediaPlayer = require(playerName).MediaPlayer();
let mediaPlayer;
//Find device
return ScannerPromise(/* device name - empty-> take first device found*/)
//Create mediaPlayer
.then (function (device) {
mediaPlayer = new MediaPlayer(device);
return Promise.resolve();
})
//Stop player
.then (function () {
return mediaPlayer.stopClientPromise();
})
//Start playing
.then (function () {
return mediaPlayer.playUrlPromise("http://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/dash/BigBuckBunnyAudio.mp4")
})
//Wait for the player to start playing
.then( function() {
return new Promise(function (resolve, reject) {
mediaPlayer.once(mediaPlayer.EVENT_PLAYER_PLAYING, function(contentId){
console.log("PLAYING: %s", contentId);
resolve();
process.exit(0);
});
});
});