forked from bitmovin/bitmovin-player-web-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
receiverApp.html
160 lines (139 loc) · 4.85 KB
/
receiverApp.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
body {
margin: 0;
background-color: black;
font-size: 14pt;
}
#player-wrapper {
height: 100%;
width: 100%;
position: fixed;
}
#app-status-overlay {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 100%;
height: 100%;
background-color: black;
display: table;
}
#app-status-overlay-loading {
display: table-cell;
text-align: center;
vertical-align: middle;
}
@keyframes app-status-overlay-loading-dot {
0% {
opacity: 1;
}
5% {
opacity: 0;
}
20% {
opacity: 0;
}
25% {
opacity: 1;
}
100% {
opacity: 1;
}
}
.app-status-overlay-loading-dot {
display: inline-block;
width: 2em;
height: 2em;
border-radius: 50%;
background-color: #777;
margin: 0.3em;
animation: app-status-overlay-loading-dot 4s ease-in infinite;
}
.app-status-overlay-loading-dot:nth-child(1) {
animation-delay: .25s;
}
.app-status-overlay-loading-dot:nth-child(2) {
animation-delay: .5s;
}
.app-status-overlay-loading-dot:nth-child(3) {
animation-delay: .75s;
}
</style>
<link rel="stylesheet" href="https://bitmovin-a.akamaihd.net/bitmovin-player/stable/7/bitmovinplayer-ui.css">
</head>
<body>
<div id="player-wrapper"></div>
<div id="app-status-overlay">
<div id="app-status-overlay-loading">
<div class="app-status-overlay-loading-dot"></div>
<div class="app-status-overlay-loading-dot"></div>
<div class="app-status-overlay-loading-dot"></div>
</div>
</div>
<script type="text/javascript" src="https://bitmovin-a.akamaihd.net/bitmovin-player/stable/7/bitmovinplayer.js"></script>
<script type="text/javascript" src="https://bitmovin-a.akamaihd.net/bitmovin-player/stable/7/bitmovinplayer-ui.js"></script>
<script type="text/javascript" src="//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.2/require.js" integrity="sha256-uvyqD81XGEqlTzEGkl+5L73IUlWTXtdLhfnUG5n3FbE="
crossorigin="anonymous"></script>
<script type="text/javascript" src="https://bitmovin-a.akamaihd.net/bitmovin-player-cast/stable/7.6.0/bitmovinplayer-remotereceiver.js"></script>
<script type="text/javascript">
var player, uimanager;
var hideStatusOverlay = () => {
document.getElementById('app-status-overlay').style.display = 'none';
};
window.onload = () => {
var conf = {
key: "YOUR-KEY",
tweaks: {
max_buffer_level: 20
},
style: {
ux: false
}
};
// Instantiate a Bitmovin Player
player = bitmovin.player('player-wrapper');
// Hide loading overlay when a source is loaded
player.addEventHandler(player.EVENT.ON_SOURCE_LOADED, hideStatusOverlay);
// Hide overlay when an error happens (avoids hidden errors during startup)
player.addEventHandler(player.EVENT.ON_ERROR, hideStatusOverlay);
player.addEventHandler(player.EVENT.ON_METADATA, (event) => {
switch (event.metadataType) {
case 'CAST':
switch (event.metadata.type) {
case 'customReceiverConfig':
var customReceiverConfig = event.metadata.data;
console.log('customReceiverConfig', customReceiverConfig);
if (customReceiverConfig.receiverStylesheetUrl != null) {
var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = customReceiverConfig.receiverStylesheetUrl;
head.appendChild(link);
}
break;
}
break;
}
});
player.setup(conf).then((player) => {
console.log('Successfully created Bitmovin player instance');
require(['src/remotecontrol/GoogleCastRemoteControlReceiver'], gcr => {
const googleCastRemoteControlReceiver = new gcr.GoogleCastRemoteControlReceiver(player);
});
// Load the built-in Bitmovin Cast Receiver UI
uimanager = bitmovin.playerui.UIManager.Factory.buildDefaultCastReceiverUI(player);
}).catch((error) => {
console.error('Error while creating Bitmovin player instance', error);
});
}
</script>
</body>
</html>