-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
158 lines (135 loc) · 5.7 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Demo</title>
<link rel="stylesheet" href="style/style.css" type="text/css">
</head>
<body>
<div class="container">
<div class="video-container" id="video-container">
<video controls class="video" id="video" preload="metadata" autoplay>
</video>
<div class="video-controls hidden" id="video-controls">
<div class="video-progress">
<progress id="progress-bar" value="0" min="0"></progress>
<input class="seek" id="seek" value="0" min="0" type="range" step="1">
<div class="seek-tooltip" id="seek-tooltip">00:00</div>
</div>
<div class="bottom-controls">
<div class="left-controls">
<button data-title="Play" id="play">
<svg class="playback-icons">
<use href="#play-icon"></use>
<use class="hidden" href="#pause"></use>
</svg>
</button>
<div class="volume-controls">
<button data-title="Mute" class="volume-button" id="volume-button">
<svg>
<use class="hidden" href="#volume-mute"></use>
<use class="hidden" href="#volume-low"></use>
<use href="#volume-high"></use>
</svg>
</button>
<input class="volume" id="volume" value="1" data-mute="0.5" type="range" max="1" min="0" step="0.01">
</div>
<div class="time">
<time id="time-elapsed">00:00</time>
<span> / </span>
<time id="duration">00:00</time>
</div>
</div>
<div class="right-controls">
<div class="shutdown">
<button data-title="Shutdown Flask server" class="normal-button" id="shutdown-button">
Shutdown
</button>
</div>
<div class="deselect">
<button data-title="Deselect object" class="normal-button" id="deselect-button">
Deselect
</button>
</div>
<div class="dropdown">
<button class="dropdown-button" id="dropdown-button" data-title="Quality">auto</button>
<div class="dropdown-content" id="dropdown-content">
<div level-idx="-1" onclick="setLevel(this)">auto</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="log-container" id="log-container">
</div>
</div>
<svg style="display: none">
<defs>
<symbol id="pause" viewBox="0 0 24 24">
<path d="M14.016 5.016h3.984v13.969h-3.984v-13.969zM6 18.984v-13.969h3.984v13.969h-3.984z"></path>
</symbol>
<symbol id="play-icon" viewBox="0 0 24 24">
<path d="M8.016 5.016l10.969 6.984-10.969 6.984v-13.969z"></path>
</symbol>
<symbol id="volume-high" viewBox="0 0 24 24">
<path
d="M14.016 3.234q3.047 0.656 5.016 3.117t1.969 5.648-1.969 5.648-5.016 3.117v-2.063q2.203-0.656 3.586-2.484t1.383-4.219-1.383-4.219-3.586-2.484v-2.063zM16.5 12q0 2.813-2.484 4.031v-8.063q1.031 0.516 1.758 1.688t0.727 2.344zM3 9h3.984l5.016-5.016v16.031l-5.016-5.016h-3.984v-6z">
</path>
</symbol>
<symbol id="volume-low" viewBox="0 0 24 24">
<path
d="M5.016 9h3.984l5.016-5.016v16.031l-5.016-5.016h-3.984v-6zM18.516 12q0 2.766-2.531 4.031v-8.063q1.031 0.516 1.781 1.711t0.75 2.32z">
</path>
</symbol>
<symbol id="volume-mute" viewBox="0 0 24 24">
<path
d="M12 3.984v4.219l-2.109-2.109zM4.266 3l16.734 16.734-1.266 1.266-2.063-2.063q-1.547 1.313-3.656 1.828v-2.063q1.172-0.328 2.25-1.172l-4.266-4.266v6.75l-5.016-5.016h-3.984v-6h4.734l-4.734-4.734zM18.984 12q0-2.391-1.383-4.219t-3.586-2.484v-2.063q3.047 0.656 5.016 3.117t1.969 5.648q0 2.203-1.031 4.172l-1.5-1.547q0.516-1.266 0.516-2.625zM16.5 12q0 0.422-0.047 0.609l-2.438-2.438v-2.203q1.031 0.516 1.758 1.688t0.727 2.344z">
</path>
</symbol>
</defs>
</svg>
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script src="script/index.js"></script>
<script>
// streaming ===============================================================
var videoTag = document.getElementById('video');
var videoSrc = 'hls/hls.m3u8';
var hls = new Hls();
function setLevel(elem) {
try {
hls.currentLevel = parseInt(elem.getAttribute('level-idx'));
var dropdownButton = document.getElementById('dropdown-button');
dropdownButton.innerHTML = elem.innerHTML;
}
catch (e) {
console.log(e);
console.log(`cannot load level #${elem.getAttribute('level-idx')}`);
}
}
function createDropdownMenu() {
var dropdown = document.getElementById('dropdown-content');
hls.levels.forEach(function (item, index) {
var node = document.createElement('div');
node.innerHTML = `${item.height}p`;
node.setAttribute('level-idx', index);
node.setAttribute('onclick', 'setLevel(this)');
dropdown.appendChild(node);
});
console.log('Dropdown menu created');
}
if (Hls.isSupported()) {
hls.loadSource(videoSrc);
hls.attachMedia(videoTag);
hls.on(Hls.Events.MANIFEST_LOADED, createDropdownMenu);
}
else if (videoTag.canPlayType('application/vnd.apple.mpegurl')) {
videoTag.src = videoSrc;
}
setInterval(function () { console.log('Current level: '+hls.currentLevel); }, 1000);
</script>
</body>
</html>