-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
259 lines (227 loc) · 7.25 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="./jessibuca.js"></script>
<style>
.root {
display: flex;
place-content: center;
margin-top: 3rem;
}
.container-shell {
backdrop-filter: blur(5px);
background: hsla(0, 0%, 50%, 0.5);
padding: 30px 4px 10px 4px;
/* border: 2px solid black; */
width: auto;
position: relative;
border-radius: 5px;
box-shadow: 0 10px 20px;
}
.container-shell:before {
content: "jessibuca demo player";
position: absolute;
color: darkgray;
top: 4px;
left: 10px;
text-shadow: 1px 1px black;
}
.container {
background: rgba(13, 14, 27, 0.7);
width: 320px;
height: 199px;
display: inline-block;
margin-right: 10px;
margin-bottom: 10px;
}
#container {
}
.input {
display: flex;
margin-top: 10px;
color: white;
place-content: stretch;
}
.input2 {
bottom: 0px;
}
.input input {
flex: auto;
}
.err {
position: absolute;
top: 40px;
left: 10px;
color: red;
}
.option {
position: absolute;
top: 4px;
right: 10px;
display: flex;
place-content: center;
font-size: 12px;
}
.option span {
color: white;
}
.page {
background: url('./bg.jpg');
background-repeat: no-repeat;
background-position: top;
}
@media (max-width: 720px) {
.container {
width: 90vw;
height: 52.7vw;
}
}
</style>
</head>
<body class="page">
<div class="root">
<div class="container-shell">
<div>
<div class="container" id="container1"></div>
<div class="container" id="container2"></div>
</div>
<div>
<div class="container" id="container3"></div>
<div class="container" id="container4"></div>
</div>
<div class="input" style="width: 640px">
使用Chrome86及之后提供的WebCodecs API来进行硬解码,为实验特性,需要手动开启 enable
chrome://flags/#enable-experimental-web-platform-features, or pass --enable-blink-features=WebCodecs flag
via the command line.
<br>
<br>
Chrome94之后,Desktop,Android,Webview中已默认开启!需要https加载web,播放https/wss-flv流. 如果控制台打印 "WCS is not supported or
experimental-web-platform-features not enabled" 请将当前页面使用https访问
</div>
<div class="input">
<div>输入URL:</div>
<input
autocomplete="on"
id="playUrl1"
value="http://flv.bdplay.nodemedia.cn/live/bbb.flv"
/>
</div>
<div class="input">
<div>输入URL:</div>
<input
autocomplete="on"
id="playUrl2"
value="http://flv.bdplay.nodemedia.cn/live/bbb.flv"
/>
</div>
<div class="input">
<div>输入URL:</div>
<input
autocomplete="on"
id="playUrl3"
value="http://flv.bdplay.nodemedia.cn/live/bbb.flv"
/>
</div>
<div class="input">
<div>输入URL:</div>
<input
autocomplete="on"
id="playUrl4"
value="http://flv.bdplay.nodemedia.cn/live/bbb.flv"
/>
</div>
<div class="input">
<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>
</div>
<script>
var $player = document.getElementById('play');
var $pause = document.getElementById('pause');
var $destroy = document.getElementById('destroy');
var showOperateBtns = true; // 是否显示按钮
var playList = [];
function create(id) {
var $container = document.getElementById('container' + id);
var jessibuca = new Jessibuca({
container: $container,
videoBuffer: 0.2, // 缓存时长
isResize: false,
text: "",
loadingText: "加载中",
debug: true,
showBandwidth: showOperateBtns, // 显示网速
operateBtns: {
fullscreen: showOperateBtns,
screenshot: showOperateBtns,
play: showOperateBtns,
audio: showOperateBtns,
},
useWCS: true, // 开启webcodecs解码
hasAudio: false
},);
jessibuca.onLog = msg => console.error(msg);
jessibuca.onRecord = (status) => console.log('onRecord', status);
jessibuca.onPause = () => console.log('onPause');
jessibuca.onPlay = () => console.log('onPlay');
jessibuca.onFullscreen = msg => console.log('onFullscreen', msg);
jessibuca.onMute = msg => console.log('onMute', msg);
playList.push(jessibuca);
}
for (let i = 0; i < 4; i++) {
create(i + 1);
$player.style.display = 'inline-block';
$pause.style.display = 'none';
$destroy.style.display = 'none';
}
$player.addEventListener('click', function () {
for (let i = 0; i < 4; i++) {
var id = i + 1;
var $playHref = document.getElementById('playUrl' + id);
let player = playList[i];
if ($playHref.value) {
console.log($playHref.value);
setTimeout(() => {
player && player.play($playHref.value).then(() => {
}).catch((e) => {
console.error(e);
});
}, 0)
}
}
$player.style.display = 'none';
$pause.style.display = 'inline-block';
$destroy.style.display = 'inline-block';
}, false)
$pause.addEventListener('click', function () {
$player.style.display = 'inline-block';
$pause.style.display = 'none';
for (let i = 0; i < 4; i++) {
let player = playList[i];
player && player.pause()
}
})
$destroy.addEventListener('click', function () {
for (let i = 0; i < 4; i++) {
let player = playList[i];
player && player.destroy()
}
playList = [];
setTimeout(() => {
for (let i = 0; i < 4; i++) {
create(i + 1);
}
$player.style.display = 'inline-block';
$pause.style.display = 'none';
$destroy.style.display = 'none';
}, 100)
})
</script>
</body>
</html>