-
Notifications
You must be signed in to change notification settings - Fork 63
/
regionOfInterest.html
489 lines (437 loc) · 18 KB
/
regionOfInterest.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bitmovin Demo</title>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400" rel="stylesheet">
<link rel="icon" type="../image/png" href="../images/bit-fav.png">
<script type="text/javascript"
src="//cdn.bitmovin.com/player/web/8/bitmovinplayer.js"></script>
<!-- Bootstrap 3.3.7 -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous">
<style>
body {
margin: 0;
padding: 0;
font-family: 'Open Sans', sans-serif;
color: #fff;
font-weight: 300;
}
body {
background: rgba(44, 131, 185, 1);
background: -moz-linear-gradient(left, rgba(44, 131, 185, 1) 0%, rgba(30, 171, 227, 1) 100%);
background: -webkit-gradient(left top, right top, color-stop(0%, rgba(44, 131, 185, 1)), color-stop(100%, rgba(30, 171, 227, 1)));
background: -webkit-linear-gradient(left, rgba(44, 131, 185, 1) 0%, rgba(30, 171, 227, 1) 100%);
background: -o-linear-gradient(left, rgba(44, 131, 185, 1) 0%, rgba(30, 171, 227, 1) 100%);
background: -ms-linear-gradient(left, rgba(44, 131, 185, 1) 0%, rgba(30, 171, 227, 1) 100%);
background: linear-gradient(to right, rgba(44, 131, 185, 1) 0%, rgba(30, 171, 227, 1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#2c83b9', endColorstr='#1eabe3', GradientType=1);
}
#wrapper {
background: url(../images/logo-bg-demopage.png);
height: 100vh;
}
#banner {
border-bottom: 1px solid #fff;
background-color: #1eabe3;
width: 100%
}
#banner h1 {
margin: 0;
padding: 30px;
}
.logo {
padding: 10px;
width: 25%;
min-width: 350px;
float: left;
margin: auto;
}
.title {
width: 75%;
white-space: nowrap;
}
.clear {
clear: both;
}
.content {
margin-bottom: 10em;
}
h1, h2, h3, p {
font-weight: 300;
text-align: center;
margin: 40px;
}
#player {
max-width: 900px;
width: 90%;
margin: auto;
-webkit-box-shadow: 0px 0px 56px 0px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 0px 0px 56px 0px rgba(0, 0, 0, 0.75);
box-shadow: 0px 0px 56px 0px rgba(0, 0, 0, 0.75);
}
.playback-stats {
width: 50%;
margin-right: auto;
margin-left: auto;
margin-top: 20px;
height: auto;
box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
background-color: gray;
}
.playback-stats td {
-webkit-transition: background-color 250ms ease;
-moz-transition: background-color 250ms ease;
-o-transition: background-color 250ms ease;
-ms-transition: background-color 250ms ease;
transition: background-color 250ms ease;
padding: 5px;
}
.active {
background-color: #2eabe2;
}
.changed {
-webkit-transition: color 100ms ease !important;
-moz-transition: color 100ms ease !important;
-o-transition: color 100ms ease !important;
-ms-transition: color 100ms ease !important;
transition: color 100ms ease !important;
color: #f3922b !important;
}
#playback-stats-wrapper-table {
width: 100%;
/*height: auto;*/
border-spacing: 0;
border-collapse: collapse;
margin-top: 5px;
padding-bottom: 5px;
border: 0 none;
}
.player-row {
margin-top: 20px;
height: 400px;
}
.player-cell {
height: 100%;
}
#playback-stats-wrapper-table div {
-webkit-transition: color 1000ms ease;
-moz-transition: color 1000ms ease;
-o-transition: color 1000ms ease;
-ms-transition: color 1000ms ease;
transition: color 1000ms ease;
}
#playback-stats-wrapper-table .active div {
color: white;
}
#playback-stats-wrapper-table span {
color: lightblue;
}
#playback-stats-wrapper-table .active span {
color: white;
}
.playback-stats-cell {
width: 50%;
padding: 5px;
margin: 0;
}
.playback-stats-row {
width: 50%;
padding: 0;
margin: 0;
}
.player-wrapper td {
/*height: 200px;*/
}
.playback-stats h3 {
font-weight: normal;
text-transform: uppercase;
margin-bottom: 5px;
margin-top: 5px;
line-height: 26px;
}
a {
color: #97d9ef;
font-weight: 400;
text-decoration: none;
}
a:hover {
color: #fff;
}
@media (max-width: 800px) {
.logo {
width: 100%;
}
.title {
display: none;
}
}
</style>
</head>
<body>
<div id="wrapper">
<div id="banner">
<div class="logo"><img src="../images/bitmovin-logo.png"></div>
<div class="title"><h1>Region of Interest</h1></div>
<div class="clear"></div>
</div>
<div class="container">
<h1>HTML5 Adaptive Streaming Player for MPEG-DASH & HLS</h1>
<h2>Your videos play everywhere with low startup delay, no buffering and in highest quality.</h2>
<div class="ca-content">
</div>
</div>
<div class="content">
<div class="row player-row">
<div class="col-md-5 col-md-offset-1 player-cell">
<div id="top-left-player"></div>
</div>
<div class="col-md-5 player-cell">
<div id="top-right-player"></div>
</div>
</div>
<div class="row player-row">
<div class="col-md-5 col-md-offset-1 player-cell">
<div id="bottom-left-player"></div>
</div>
<div class="col-md-5 player-cell">
<div id="bottom-right-player"></div>
</div>
</div>
<div class="playback-stats">
<h3>playback control</h3>
<a id="play" class="btn btn-default" onclick="playPause('play')" disabled>play</a>
<a id="pause" class="btn btn-default" onclick="playPause('pause')" disabled>pause</a>
<h3>playback stats</h3>
<table id="playback-stats-wrapper-table">
<tr class="playback-stats-row">
<td id="top-left-player-stats" class="playback-stats-cell">
<h3>top-left player</h3>
<span>chosen representation</span>
<div id="top-left-player-chosen-representation"></div>
<br/>
<span>playback representation</span>
<div id="top-left-player-playback-representation"></div>
</td>
<td id="top-right-player-stats" class="playback-stats-cell">
<h3>top-right player</h3>
<span>chosen representation</span>
<div id="top-right-player-chosen-representation"></div>
<br/>
<span>playback representation</span>
<div id="top-right-player-playback-representation"></div>
</td>
</tr>
<tr class="playback-stats-row">
<td id="bottom-left-player-stats" class="playback-stats-cell">
<h3>bottom-left player</h3>
<span>chosen representation</span>
<div id="bottom-left-player-chosen-representation"></div>
<br/>
<span>playback representation</span>
<div id="bottom-left-player-playback-representation"></div>
</td>
<td id="bottom-right-player-stats" class="playback-stats-cell">
<h3>bottom-right player</h3>
<span>chosen representation</span>
<div id="bottom-right-player-chosen-representation"></div>
<br/>
<span>playback representation</span>
<div id="bottom-right-player-playback-representation"></div>
</td>
</tr>
</table>
</div>
</div>
</div>
<script type="text/javascript">
var topLeftPlayerWrapper = document.getElementById('top-left-player');
var topRightPlayerWrapper = document.getElementById('top-right-player');
var bottomLeftPlayerWrapper = document.getElementById('bottom-left-player');
var bottomRightPlayerWrapper = document.getElementById('bottom-right-player');
var minVideoRepresentation = null;
var maxVideoRepresentation = null;
var initializedPlayers = 0;
var players = {
'top-left-player': null,
'top-right-player': null,
'bottom-left-player': null,
'bottom-right-player': null
};
var playerWrappers = [
topLeftPlayerWrapper,
topRightPlayerWrapper,
bottomLeftPlayerWrapper,
bottomRightPlayerWrapper
];
var playerStats = {
'top-left-player': {
'wrapper': document.getElementById('top-left-player-stats'),
'chosen-representation': document.getElementById('top-left-player-chosen-representation'),
'playback-representation': document.getElementById('top-left-player-playback-representation')
},
'top-right-player': {
'wrapper': document.getElementById('top-right-player-stats'),
'chosen-representation': document.getElementById('top-right-player-chosen-representation'),
'playback-representation': document.getElementById('top-right-player-playback-representation')
},
'bottom-left-player': {
'wrapper': document.getElementById('bottom-left-player-stats'),
'chosen-representation': document.getElementById('bottom-left-player-chosen-representation'),
'playback-representation': document.getElementById('bottom-left-player-playback-representation')
},
'bottom-right-player': {
'wrapper': document.getElementById('bottom-right-player-stats'),
'chosen-representation': document.getElementById('bottom-right-player-chosen-representation'),
'playback-representation': document.getElementById('bottom-right-player-playback-representation')
}
};
var config = {
key: 'YOUR KEY HERE',
ui: false,
playback: {
autoplay: true
},
adaptation: {
desktop: {
bitrates: {
minSelectableAudioBitrate: 0,
maxSelectableAudioBitrate: 1,
minSelectableVideoBitrate: 0,
maxSelectableVideoBitrate: 1
}
},
mobile: {
bitrates: {
minSelectableAudioBitrate: 0,
maxSelectableAudioBitrate: 1,
minSelectableVideoBitrate: 0,
maxSelectableVideoBitrate: 1
}
}
},
tweaks: {
max_buffer_level: 6
}
};
var source = {
dash: '//bitdash-a.akamaihd.net/content/sintel/sintel.mpd',
hls: 'http://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8',
progressive: [
{url: 'http://bitdash-a.akamaihd.net/content/sintel/Sintel.mp4', type: 'video/mp4'},
{url: 'http://bitdash-a.akamaihd.net/content/sintel/Sintel.webm', type: 'video/webm'}
]
};
function getMinMaxVideoRepresentation() {
if (players['top-left-player'] && (!maxVideoRepresentation || !minVideoRepresentation)) {
maxVideoRepresentation = {bitrate: 0};
minVideoRepresentation = {bitrate: Infinity};
var availableVideoRepresentations = players['top-left-player'].getAvailableVideoQualities();
for (var idx = 0; idx < availableVideoRepresentations.length; idx++) {
if (availableVideoRepresentations[idx].bitrate > maxVideoRepresentation.bitrate) {
maxVideoRepresentation = availableVideoRepresentations[idx];
}
if (availableVideoRepresentations[idx].bitrate < minVideoRepresentation.bitrate) {
minVideoRepresentation = availableVideoRepresentations[idx];
}
}
}
}
function playPause(type) {
for (var prop in players) {
if (players.hasOwnProperty(prop)) {
if (type === 'play') {
players[prop].play();
} else if (type === 'pause') {
players[prop].pause();
}
}
}
}
function onPlay() {
this.pause();
this.off(bitmovin.player.PlayerEvent.Playing, onPlay);
}
function onDownloadFinished(event) {
if (event.url.indexOf('segment_1') >= 0) {
if (++initializedPlayers === 4) {
document.getElementById('play').removeAttribute('disabled');
document.getElementById('pause').removeAttribute('disabled');
}
this.off(bitmovin.player.PlayerEvent.DownloadFinished, onDownloadFinished);
}
}
function onVideoPlaybackQualityChanged(event) {
playerStats[this.getContainer().id]['playback-representation'].innerHTML = event.targetQuality.id;
playerStats[this.getContainer().id]['playback-representation'].className = 'changed';
setTimeout(function () {
playerStats[this.getContainer().id]['playback-representation'].removeAttribute('class');
}.bind(this), 300);
}
function onMouseEnter(event) {
getMinMaxVideoRepresentation();
console.log(event, players);
if (players.hasOwnProperty(event.target.getAttribute('id')) && players[event.target.getAttribute('id')] && maxVideoRepresentation) {
players[event.target.getAttribute('id')].setVideoQuality(maxVideoRepresentation.id);
playerStats[event.target.getAttribute('id')]['wrapper'].className = 'active';
playerStats[event.target.getAttribute('id')]['chosen-representation'].className = 'changed';
setTimeout(function () {
playerStats[event.target.getAttribute('id')]['chosen-representation'].removeAttribute('class');
}, 300);
playerStats[event.target.getAttribute('id')]['chosen-representation'].innerHTML = maxVideoRepresentation.id;
}
}
function onMouseLeave(event) {
getMinMaxVideoRepresentation();
if (players.hasOwnProperty(event.target.getAttribute('id')) && players[event.target.getAttribute('id')]) {
players[event.target.getAttribute('id')].setVideoQuality(minVideoRepresentation.id);
playerStats[event.target.getAttribute('id')]['wrapper'].removeAttribute('class');
playerStats[event.target.getAttribute('id')]['chosen-representation'].className = 'changed';
setTimeout(function () {
playerStats[event.target.getAttribute('id')]['chosen-representation'].removeAttribute('class');
}, 300);
playerStats[event.target.getAttribute('id')]['chosen-representation'].innerHTML = minVideoRepresentation.id;
}
}
(function init() {
var idx;
initializedPlayers = 0;
console.log('wrap', playerWrappers);
for (idx = 0; idx < playerWrappers.length; idx++) {
playerWrappers[idx].onmouseenter = onMouseEnter;
playerWrappers[idx].onmouseleave = onMouseLeave;
}
var playerReady = function (player) {
players[player.getContainer().id] = player;
if (player.isPlaying()) {
player.pause();
} else {
player.on(bitmovin.player.PlayerEvent.Playing, onPlay);
}
player.on(bitmovin.player.PlayerEvent.DownloadFinished, onDownloadFinished);
player.on(bitmovin.player.PlayerEvent.VideoPlaybackQualityChanged, onVideoPlaybackQualityChanged);
player.on(bitmovin.player.PlayerEvent.PlaybackFinished, function () {
console.log('finished');
this.play();
});
};
var player1 = new bitmovin.player.Player(document.getElementById("top-left-player"), config);
player1.on(bitmovin.player.PlayerEvent.SourceLoaded, playerReady(player1));
player1.load(source);
var player2 = new bitmovin.player.Player(document.getElementById("top-right-player"), config);
player2.on(bitmovin.player.PlayerEvent.SourceLoaded, playerReady(player2));
player2.load(source);
var player3 = new bitmovin.player.Player(document.getElementById("bottom-left-player"), config);
player3.on(bitmovin.player.PlayerEvent.SourceLoaded, playerReady(player3));
player3.load(source);
var player4 = new bitmovin.player.Player(document.getElementById("bottom-right-player"), config);
player4.on(bitmovin.player.PlayerEvent.SourceLoaded, playerReady(player4));
player4.load(source);
})();
</script>
</body>
</html>