-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpage_live_temple.html
78 lines (74 loc) · 2.69 KB
/
webpage_live_temple.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/base.css" />
<link rel="stylesheet" href="css/colpick.css" />
<title>ABPlayerHTML5Py</title>
<script src="js/jquery.min.js"></script>
<script src="js/CommentCoreLibrary.min.js"></script>
<script src="js/ABPMobile.js"></script>
<script src="js/ABPLibxml.js"></script>
<script src="js/ABPlayer.js"></script>
<script src="js/ColPick.js"></script>
<script src="js/hls.js"></script>
<script type="text/javascript">
window.addEventListener("load",function(){
var inst = ABP.create(document.getElementById("player1"), {
src: {
playlist: [{
video: document.getElementById("video-1"),
comments: ""
}]
},
width: "95%",//magic number
height: 960,
mobile: isMobile()
});
window.abpinst = inst;
});
</script>
</head>
<body>
<div id="player1">
<video id="video-1" autobuffer="true" data-setup="{}">
<p>Your browser does not support html5 video!</p>
</video>
</div>
<script>
window.hls = new Hls({debug:true});
hls.loadSource("http://127.0.0.1:$PORT/cache/out.m3u8");
hls.attachVideo(document.getElementById("video-1"));
</script>
<script>
var wsurl = 'ws://livecmt.bilibili.com:88/$cid';
function getws(wsurl)
{
// Create a socket instance
var socket = new WebSocket(wsurl);
// Open the socket
socket.onopen = function(event) {
// Listen for messages
socket.onmessage = function (event) {
var a = JSON.parse(event.data.slice(4));
console.log('Received:',a);
abpinst.cmManager.sendComment({
"text": a["info"][1],
"mode": a["info"][0][1],
"stime": abpinst.video.currentTime,
"size": a["info"][0][2],
"color": a["info"][0][3],
"border": false
});
}
// Listen for socket closes
socket.onclose = function(event) {
console.log('WS closed, starting new one',event);
getws(wsurl); //serve forever and ever and ever
};
};
};
getws(wsurl);
</script>
</body>
</html>