forked from iobroker-community-adapters/castv2-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
announcement.js
55 lines (48 loc) · 1.23 KB
/
announcement.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"use strict"
//Default to dummyLogClass
var log = require("../lib/dummyLogClass")("Main");
var defines = require("./defines");
var common = require("./common")(log);
function runPromise() {
let mediaPlayer;
//Setup
return common.setupPromise()
.then (function (mP) {
mediaPlayer = mP;
return Promise.resolve();
})
//PLAYLIST with ogg
.then( function () {return common.playAndCheckPromise(
mediaPlayer,
defines.urls.oggPlaylist,
defines.urls.oggPlaylist_firstItem);
})
//seekPromise
.then( function (item) {
log.info("Seek 1 minute");
return mediaPlayer.seekPromise(60)
.then(function() {return Promise.resolve(item);});
})
//playAnnouncementPromise
.then( function () {
return mediaPlayer.playAnnouncementPromise(defines.urls.shortSingle);
})
//Final checks
.then (function () {
return common.finalizeOk(mediaPlayer);
})
.catch (function (err) {
return common.finalizeError(mediaPlayer, err);
});
}
//module for testcase
module.exports = runPromise;
//main
var main = function () {
runPromise()
.then (function() {process.exit(0);})
.catch(function(err) {process.exit(1);});
}
if (require.main === module) {
main();
}