-
Notifications
You must be signed in to change notification settings - Fork 63
/
index.html
118 lines (105 loc) · 5.83 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- Bitmovin player modules -->
<script type="text/javascript" src="https://cdn.bitmovin.com/player/web/8/modules/bitmovinplayer-core.js"></script>
<script type="text/javascript"
src="https://cdn.bitmovin.com/player/web/8/modules/bitmovinplayer-polyfill.js"></script>
<script type="text/javascript"
src="https://cdn.bitmovin.com/player/web/8/modules/bitmovinplayer-engine-bitmovin.js"></script>
<script type="text/javascript"
src="https://cdn.bitmovin.com/player/web/8/modules/bitmovinplayer-engine-native.js"></script>
<script type="text/javascript"
src="https://cdn.bitmovin.com/player/web/8/modules/bitmovinplayer-mserenderer.js"></script>
<script type="text/javascript" src="https://cdn.bitmovin.com/player/web/8/modules/bitmovinplayer-abr.js"></script>
<script type="text/javascript" src="https://cdn.bitmovin.com/player/web/8/modules/bitmovinplayer-drm.js"></script>
<script type="text/javascript"
src="https://cdn.bitmovin.com/player/web/8/modules/bitmovinplayer-container-mp4.js"></script>
<script type="text/javascript"
src="https://cdn.bitmovin.com/player/web/8/modules/bitmovinplayer-container-ts.js"></script>
<script type="text/javascript" src="https://cdn.bitmovin.com/player/web/8/modules/bitmovinplayer-xml.js"></script>
<script type="text/javascript" src="https://cdn.bitmovin.com/player/web/8/modules/bitmovinplayer-dash.js"></script>
<script type="text/javascript" src="https://cdn.bitmovin.com/player/web/8/modules/bitmovinplayer-hls.js"></script>
<script type="text/javascript"
src="https://cdn.bitmovin.com/player/web/8/modules/bitmovinplayer-crypto.js"></script>
<script type="text/javascript" src="https://cdn.bitmovin.com/player/web/8/modules/bitmovinplayer-style.js"></script>
<script type="text/javascript" src="https://cdn.bitmovin.com/player/web/8/modules/bitmovinplayer-ui.js"></script>
</head>
<button id="pipButtonElement" disabled>CLICK me to toggle PIP</button>
<div id="log" style="color: red;"></div>
<br></br>
<div id="my-player">
<video id="videoElement"></video>
</div>
<script>
// add all necessary (and loaded) modules to the player core
bitmovin.player.core.Player.addModule(window.bitmovin.player.polyfill.default);
bitmovin.player.core.Player.addModule(window.bitmovin.player['engine-bitmovin'].default);
bitmovin.player.core.Player.addModule(window.bitmovin.player['engine-native'].default);
bitmovin.player.core.Player.addModule(window.bitmovin.player['container-mp4'].default);
bitmovin.player.core.Player.addModule(window.bitmovin.player['container-ts'].default);
bitmovin.player.core.Player.addModule(window.bitmovin.player.mserenderer.default);
bitmovin.player.core.Player.addModule(window.bitmovin.player.abr.default);
bitmovin.player.core.Player.addModule(window.bitmovin.player.drm.default);
bitmovin.player.core.Player.addModule(window.bitmovin.player.xml.default);
bitmovin.player.core.Player.addModule(window.bitmovin.player.dash.default);
bitmovin.player.core.Player.addModule(window.bitmovin.player.hls.default);
bitmovin.player.core.Player.addModule(window.bitmovin.player.crypto.default);
bitmovin.player.core.Player.addModule(window.bitmovin.player.style.default);
bitmovin.player.core.Player.addModule(window.bitmovin.player.ui.default);
// check for Picture-in-Picture Web API browser support; is NOT supported log the reason & disable the button
// ------------------------------------------------------------------------------------------------------------------------
var logElement = document.getElementById("log");
var pipButtonElement = document.getElementById("pipButtonElement");
if (!('pictureInPictureEnabled' in document)) {
logElement.innerHTML = 'PIP Button Disabled. Picture-in-Picture Web API is not available in this browser. Try using Chrome / Safari.';
}
else if (!document.pictureInPictureEnabled) {
logElement.innerHTML = 'PIP Button Disabled. Picture-in-Picture Web API is disabled in this browser. Try using Chrome / Safari.';
}
else {
pipButtonElement.disabled = false;
}
// ------------------------------------------------------------------------------------------------------------------------
var config = {
"key": "---YOUR-KEY-HERE---",
playback: {
autoplay: true,
muted: true
},
events: {
error: console.error
},
}
var source = {
dash: 'https://bitmovin-a.akamaihd.net/content/MI201109210084_1/mpds/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.mpd',
hls: 'https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8'
};
var container = document.getElementById('my-player');
var player = new bitmovin.player.core.Player(container, config);
var videoElement = document.getElementById("videoElement")
player.setVideoElement(videoElement);
player.load(source).then(
function () {
console.log('Successfully created Bitmovin Player instance');
},
function (reason) {
console.log('Error while creating Bitmovin Player instance');
}
);
pipButtonElement.addEventListener('click', async function () {
try {
if (videoElement !== document.pictureInPictureElement) {
await videoElement.requestPictureInPicture();
} else {
await document.exitPictureInPicture();
}
}
catch (error) {
console.log('' + error);
}
});
</script>
</html>