-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdplayer.html
67 lines (62 loc) · 1.96 KB
/
dplayer.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 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>DPLAYER</title>
<script src="https://lib.baomitu.com/hls.js/1.1.5/hls.light.js"></script>
<script src="https://lib.baomitu.com/dplayer/1.26.0/DPlayer.min.js"></script>
<script>
sessionStorage.loglevel = 'warn'
</script>
<script src="./p2pstat.min.js"></script>
<script src="/js/vsl.js"></script>
<style>
#dplayer {
max-width: 400px;
margin: 10px auto;
}
</style>
</head>
<body>
<div>
<div id="dplayer"></div>
<button class="todebug" onclick="doDebug()">打开调试</button>
</div>
<script>
function doDebug() {
if (__hls_p2p_stat && typeof __hls_p2p_stat[0] == 'object') {
__hls_p2p_stat[0].$emit('debug', true)
} else {
console.warn('can not debug');
}
}
</script>
<script>
const url = 'https://v.gsuus.com/play/QdJ9Vgyb/index.m3u8';
const dp = new DPlayer({
container: document.getElementById('dplayer'),
screenshot: true,
type: 'customHls',
video: {
url: url,
type: 'customHls',
customType: {
'customHls': function (video, player) {
const hls = new Hls({
maxBufferLength: 60,
debug: false,
live: false,
startFragPrefetch: true,
});
hls.loadSource(video.src);
hls.attachMedia(video);
HlsP2P.Init(hls) // 使用内部默认参数
}
},
}
});
</script>
</body>
</html>