-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
74 lines (69 loc) · 3.26 KB
/
test.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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>videojs-http-source-selector Demo</title>
<link href="https://vjs.zencdn.net/7.4.1/video-js.css" rel="stylesheet">
<!--<link href="node_modules/video.js/dist/video-js.css" rel="stylesheet">-->
<link href="dist/videojs-http-source-selector.css" rel="stylesheet">
</head>
<body>
<title>videojs-http-source-selector Demo</title>
<video id="videojs-http-source-selector-player" width="1280" height="720" class="video-js vjs-default-skin vjs-big-play-centered" controls>
<source src="videos/day1/mediaFilePlaylist.m3u8" type='application/x-mpegURL'>
</video>
<!-- Stream URL:
<input type="text" id="streamURL" value="https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8" size="65">
<button onClick="loadStream()">Load</button>
<br/>
Caption1 URL:
<input type="text" id="caption1URL" value="https://crackle-mediaconvert.s3.amazonaws.com/assets/thesonata/HLS/captions/thesonata_aiml.vtt" size="65">
<button onClick="loadCaption1()">Load Caption</button>
<br/>
Caption2 URL:
<input type="text" id="caption2URL" value="https://crackle-mediaconvert.s3.amazonaws.com/assets/thesonata/HLS/captions/thesonata_3play.vtt" size="65">
<button onClick="loadCaption2()">Load Caption</button> -->
<!--<script src="node_modules/video.js/dist/video.js"></script>-->
<script src='https://vjs.zencdn.net/7.4.1/video.js'></script>
<script src="dist/videojs-contrib-quality-levels.js"></script>
<script src="dist/videojs-http-source-selector.js"></script>
<script>
(function(window, videojs) {
var player = window.player = videojs('videojs-http-source-selector-player');
player.httpSourceSelector();
//Load stream from query param /?stream=MYHLS_STREAM_URL_GOES_HERE
var queryParamStream = getQueryString('stream');
if(queryParamStream !== null)
{
document.getElementById("streamURL").value = queryParamStream;
player.src({ type: "application/x-mpegURL", src: document.getElementById("streamURL").value });
}
}(window, window.videojs));
function loadStream(){
console.log("Change stream to : "+document.getElementById("streamURL").value );
player.src({ type: "application/x-mpegURL", src: document.getElementById("streamURL").value });
}
function loadCaption1(){
console.log("Add caption: "+document.getElementById("caption1URL").value );
player.addRemoteTextTrack({src: document.getElementById("caption1URL").value, label: 'Caption 1'}, false);
}
function loadCaption2(){
console.log("Add caption: "+document.getElementById("caption2URL").value );
player.addRemoteTextTrack({src: document.getElementById("caption2URL").value, label: 'Caption 2'}, false);
}
/**
* Get the value of a querystring
* @param {String} field The field to get the value of
* @param {String} url The URL to get the value from (optional)
* @return {String} The field value
*/
function getQueryString ( field, url )
{
var href = url ? url : window.location.href;
var reg = new RegExp( '[?&]' + field + '=([^]*)', 'i' );
var string = reg.exec(href);
return string ? string[1] : null;
}
</script>
</body>
</html>