-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
68 lines (65 loc) · 1.78 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
<!DOCTYPE html>
<html>
<head>
<title>JSMpeg Stream Client</title>
<style type="text/css">
html, body {
background-color: #111;
text-align: center;
color: #a00;
}
div {
margin: 1vw 5vw;
font-size: 10vw;
font-family: monospace;
}
</style>
</head>
<body>
<canvas id="video-canvas"></canvas>
<div id="time"></div>
<script type="text/javascript" src="jsmpeg.min.js"></script>
<script type="text/javascript">
var canvas = document.getElementById('video-canvas');
var url = 'ws://'+'127.0.0.1:8080'+'/play/live/s_1_1001106_1024999';
var player = new JSMpeg.Player(url, {canvas: canvas, pauseWhenHidden: false, audioBufferSize: 250*1024});
function onUnlocked () {
// console.log('unlock video audio: ' + url)
player.volume = 1
document.removeEventListener('touchstart', onTouchStart)
}
function onTouchStart () {
player.audioOut.unlock(onUnlocked)
document.removeEventListener('touchstart', onTouchStart)
}
// try to unlock immediately
player.audioOut.unlock(onUnlocked)
// try to unlock by touchstart event
document.addEventListener('touchstart', onTouchStart, false)
var ele = document.getElementById('time')
function startTime() {
requestAnimationFrame(startTime)
var today = new Date()
var h = today.getHours()
var m = today.getMinutes()
var s = today.getSeconds()
var ms = today.getMilliseconds()
m = checkTime(m)
s = checkTime(s)
ms = pand3(ms)
ele.innerHTML = h + ":" + m + ":" + s + '.' + ms
}
function checkTime(i) {
var out = i
if (i < 10) {out = "0" + out}; // add zero in front of numbers < 10
return out;
}
function pand3(i) {
var out = checkTime(i)
if (i < 100) {out = "0" + out}; // add zero in front of numbers < 100
return out;
}
startTime()
</script>
</body>
</html>