-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
54 lines (46 loc) · 1.83 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
<!doctype html>
<html>
<head>
<title>MyLive SHOW</title>
<link href="./css/video.css" rel="stylesheet">
<link href="./css/app.css" rel="stylesheet">
<script src="./js/video.js"></script>
<script src="./js/videojs-live.js"></script>
</head>
<body>
<div class="content-box">
<div class="chat-panel">
<form action="" class="chat-dispatch" >
<textarea id="m" autocomplete="off" ></textarea> <button>发送</button>
</form>
<ul id="messages" class="chat-container"></ul>
</div>
<div class="video-panel">
<video id="my_video_1" class="video-js vjs-default-skin " controls preload="auto" width="800" height="400" poster="./fm.jpg" data-setup='{}'>
<!-- <source src="../hls/.m3u8" type="application/x-mpegURL"> -->
<source src="rtmp://127.0.0.1:1935/myapp/" type="rtmp/flv">
</video>
</div>
</div>
<script src="/socket.io/socket.io.js"></script>
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script>
var socket = io();
$('form').submit(function(){
if($('#m').val() ) {
socket.emit('chat message', $('#m').val());
$('#messages').append("<li><span class='self'>Yourself:</span> <span class='message'>"+$('#m').val()+"</span></li>");
$('#m').val('');
return false;
}
return false;
});
socket.on('chat message', function(msg){
if(socket.id.substr(0,4)!=msg.substr(0,4)){
$('#messages').append("<li><span class='user-name'>游客"+msg.substr(0,4).toUpperCase()+":</span> <span class='message'>"+msg.substr(5)+"</span></li>");
}
document.getElementById('messages').scrollTop = document.getElementById('messages').scrollHeight
});
</script>
</body>
</html>