forked from videojs/videojs-contrib-hls
-
Notifications
You must be signed in to change notification settings - Fork 13
/
p2pExample.html
124 lines (109 loc) · 4.13 KB
/
p2pExample.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>video.js HLS Plugin Example</title>
<link href="node_modules/video.js/dist/video-js/video-js.css" rel="stylesheet">
<!-- peer5.js -->
<script src="//api.peer5.com/peer5.js?id=ncp2vywz762cq79dgwd7"></script>
<!-- video.js -->
<script src="node_modules/video.js/dist/video-js/video.js"></script>
<!-- Media Sources plugin -->
<script src="node_modules/videojs-contrib-media-sources/src/videojs-media-sources.js"></script>
<!-- HLS plugin -->
<script src="src/videojs-hls.js"></script>
<!-- segment handling -->
<script src="src/peer5-request.js"></script>
<script src="src/flv-tag.js"></script>
<script src="src/stream.js"></script>
<script src="src/exp-golomb.js"></script>
<script src="src/h264-stream.js"></script>
<script src="src/aac-stream.js"></script>
<script src="src/metadata-stream.js"></script>
<script src="src/segment-parser.js"></script>
<!-- m3u8 handling -->
<script src="src/m3u8/m3u8-parser.js"></script>
<script src="src/playlist-loader.js"></script>
<script src="node_modules/pkcs7/dist/pkcs7.unpad.js"></script>
<script src="src/decrypter.js"></script>
<script src="src/bin-utils.js"></script>
<!-- example MPEG2-TS segments -->
<!-- bipbop -->
<!-- <script src="test/tsSegment.js"></script> -->
<!-- bunnies -->
<!--<script src="test/tsSegment-bc.js"></script>-->
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
.info {
background-color: #eee;
border: thin solid #333;
border-radius: 3px;
padding: 0 5px;
margin: 20px 0;
}
</style>
</head>
<body>
<div class="info">
<p>The video below is an <a
href="https://developer.apple.com/library/ios/documentation/networkinginternet/conceptual/streamingmediaguide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008332-CH1-SW1">HTTP
Live Stream</a>. On desktop browsers other than Safari, the HLS plugin will polyfill support for the format on
top of the video.js Flash tech.</p>
<p>Due to security restrictions in Flash, you will have to load this page over HTTP(S) to see the example in
action.</p>
</div>
<video id="video"
class="video-js vjs-default-skin"
height="300"
width="600"
controls>
<source
src="https://storage.googleapis.com/peer5_vod/hls1/stream_1000k_48k_640x360.m3u8"
type="application/x-mpegURL">
</video>
<script>
videojs.options.flash.swf = 'node_modules/video.js/dist/video-js/video-js.swf';
// initialize the player
var player = videojs('video');
function P2PPerformanceUpdate(total) {
// custom code goes here
document.querySelector('.stats .HTTP').innerHTML = total.http;
document.querySelector('.stats .P2P').innerHTML = total.p2p;
document.querySelector('.stats .Total').innerHTML = total.loaded;
document.querySelector('.stats .Efficiency').innerHTML = Math.round(100 * ((total.p2p + total.fs) / total.loaded)) + '%';
document.querySelector('.stats .Sent').innerHTML = total.sent;
document.querySelector('.stats .NumOfPeers').innerHTML = total.numOfPeers;
}
</script>
<div class="stats"> Loaded in bytes<br>
<div>P2P: <span class="P2P">0</span></div>
<div>HTTP: <span class="HTTP">0</span></div>
<div>Total: <span class="Total">0</span></div>
<div>Effic: <span class="Efficiency">0</span></div>
<div>Sent: <span class="Sent">0</span></div>
<div>Peers: <span class="NumOfPeers">0</span></div>
</div>
<style>
body {
padding-left: 250px;
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial;
}
.stats {
position: fixed;
left: 0px;
top: 0px;
padding: 20px;
background: #000000;
opacity: 0.7;
font-family: "Courier New", Courier, monospace;
color: lightcyan;
font-size: 1.1em;
}
</style>
</script>
</
body >
< / html >