-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstream.html
87 lines (73 loc) · 2.64 KB
/
stream.html
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
<head>
<title>TD Web Player SDK 2.9 - Simple implementation demo</title>
</head>
<body>
<!-- Player container -->
<div id="td_container"></div>
<!-- Now Playing information -->
<div id="onair"></div>
<script>
var player;
function initPlayerSDK()
{
console.log( 'TD Player SDK is ready' );
//Player SDK is ready to be used, this is where you can instantiate a new TDSdk instance.
//Player configuration: list of modules
var tdPlayerConfig = {
coreModules: [{
id: 'MediaPlayer',
playerId: 'td_container'
}],
playerReady: onPlayerReady,
configurationError: onConfigurationError,
moduleError: onModuleError,
adBlockerDetected: onAdBlockerDetected
};
//Player instance
player = new TDSdk( tdPlayerConfig );
}
/* Callback function called to notify that the SDK is ready to be used */
function onPlayerReady()
{
//Listen for 'track-cue-point' event
player.addEventListener( 'track-cue-point', onTrackCuePoint );
//Play the stream: station is TRITONRADIOMUSIC
console.log("ready to play");
player.play( {station:'KQXYFM'} );
console.log("after playing");
}
/* Callback function called to notify that the player configuration has an error. */
function onConfigurationError( e ) {
console.log(object);
console.log(object.data.errors);
//Error code : object.data.errors[0].code
//Error message : object.data.errors[0].message
}
/* Callback function called to notify that a module has not been loaded properly */
function onModuleError( object )
{
console.log(object);
console.log(object.data.errors);
//Error code : object.data.errors[0].code
//Error message : object.data.errors[0].message
}
/* Callback function called to notify that a new Track CuePoint comes in. */
function onTrackCuePoint( e )
{
console.log( 'onTrackCuePoint' );
console.log( e.data.cuePoint );
//Display now playing information in the "onair" div element.
document.getElementById('onair').innerHTML = 'Artist: ' + e.data.cuePoint.artistName + '<BR>Title: ' + e.data.cuePoint.cueTitle;
}
/* Callback function called to notify that an Ad-Blocker was detected */
function onAdBlockerDetected()
{
console.log( 'AdBlockerDetected' );
}
</script>
<script src="//sdk.listenlive.co/web/2.9/td-sdk.min.js"></script>
<script>initPlayerSDK();</script>
</body>
</html>