-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
75 lines (63 loc) · 1.98 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>player</title>
</head>
<body>
<h1>Video Player</h1>
<div class="input">
<div>输入URL:</div>
<input autocomplete="on" id="playUrl" value="ws://10.20.10.87:20080/live/test122.flv" />
<button id="play">播放</button>
<button id="pause" style="display: none">停止</button>
</div>
<div class="input" style="line-height: 30px">
<button id="destroy">销毁</button>
</div>
<div id="container"></div>
<!-- <canvas></canvas> -->
</body>
<script type="module">
import { Player } from './player.js';
let $play = document.getElementById('play');
let $pause = document.getElementById('pause');
let $playHref = document.getElementById('playUrl');
let $container = document.getElementById('container');
let $destroy = document.getElementById('destroy');
let myPlayer = null;
let playerOption = {
container: $container,
showVbps: true,
};
function create() {
myPlayer = new Player(playerOption);
$play.style.display = 'inline-block';
$pause.style.display = 'none';
$destroy.style.display = 'none';
}
$play.addEventListener('click', function () {
let href = $playHref.value;
if (href) {
myPlayer.play(href);
$play.style.display = 'none';
$pause.style.display = 'inline-block';
$destroy.style.display = 'inline-block';
}
}, false)
$pause.addEventListener('click', function () {
$play.style.display = 'inline-block';
$pause.style.display = 'none';
myPlayer.pause();
})
$destroy.addEventListener('click', function () {
if (myPlayer) {
myPlayer.destroy();
}
create();
})
create();
</script>
</html>