forked from iobroker-community-adapters/castv2-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
streaming.js
48 lines (43 loc) · 1.13 KB
/
streaming.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
"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();
})
//ICY STREAMING
.then( function () {return common.playAndCheckPromise(
mediaPlayer,
defines.urls.mp3Streaming,
defines.urls.mp3Streaming_firstItem);
})
.then( function () {return mediaPlayer.stopPromise();})
.then( function () {return common.playAndCheckPromise(
mediaPlayer,
defines.urls.plsStreaming,
defines.urls.plsStreamin_firstItem);
})//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();
}