-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathindex.html
96 lines (89 loc) · 5.72 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
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
<!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" controls>
<source src="https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.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>
<button onClick="loadCaptions()">Load Captions</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 loadCaptions(){
console.log("Add autogen captions");
player.addRemoteTextTrack({src: "https://crackle-mediaconvert.s3.amazonaws.com/assets/anythingispossible/aip_english.vtt", label: 'English (Autogenerated)'}, false);
player.addRemoteTextTrack({src: "https://crackle-mediaconvert.s3.amazonaws.com/assets/anythingispossible/aip_gcp_spanish.vtt", label: 'Spanish'}, false);
player.addRemoteTextTrack({src: "https://crackle-mediaconvert.s3.amazonaws.com/assets/anythingispossible/aip_gcp_portuguese_(portugal_brazil)", label: 'Portuguese (Portugal/Brazil)'}, false);
player.addRemoteTextTrack({src: "https://crackle-mediaconvert.s3.amazonaws.com/assets/anythingispossible/aip_gcp_french.vtt", label: 'French'}, false);
player.addRemoteTextTrack({src: "https://crackle-mediaconvert.s3.amazonaws.com/assets/anythingispossible/aip_gcp_german.vtt", label: 'German'}, false);
player.addRemoteTextTrack({src: "https://crackle-mediaconvert.s3.amazonaws.com/assets/anythingispossible/aip_gcp_russian.vtt", label: 'Russian'}, false);
player.addRemoteTextTrack({src: "https://crackle-mediaconvert.s3.amazonaws.com/assets/anythingispossible/aip_gcp_arabic.vtt", label: 'Arabic'}, false);
player.addRemoteTextTrack({src: "https://crackle-mediaconvert.s3.amazonaws.com/assets/anythingispossible/aip_gcp_polish.vtt", label: 'Polish'}, false);
player.addRemoteTextTrack({src: "https://crackle-mediaconvert.s3.amazonaws.com/assets/anythingispossible/aip_gcp_hindi.vtt", label: 'Hindi'}, false);
player.addRemoteTextTrack({src: "https://crackle-mediaconvert.s3.amazonaws.com/assets/anythingispossible/aip_gcp_japanese.vtt", label: 'Japanese'}, false);
player.addRemoteTextTrack({src: "https://crackle-mediaconvert.s3.amazonaws.com/assets/anythingispossible/aip_gcp_korean.vtt", label: 'Korean'}, false);
player.addRemoteTextTrack({src: "https://crackle-mediaconvert.s3.amazonaws.com/assets/anythingispossible/aip_gcp_chinese_(traditional).vtt", label: 'Chinese (Traditional)'}, false);
player.addRemoteTextTrack({src: "https://crackle-mediaconvert.s3.amazonaws.com/assets/anythingispossible/aip_gcp_chinese_(simplified).vtt", label: 'Chinese (Simplified)'}, false);
player.addRemoteTextTrack({src: "https://crackle-mediaconvert.s3.amazonaws.com/assets/anythingispossible/aip_gcp_finnish.vtt", label: 'Finnish'}, false);
}
function loadCaption2(){
console.log("Add caption: "+document.getElementById("caption2URL").value );
player.addRemoteTextTrack({src: document.getElementById("caption2URL").value, label: 'Caption 2'}, 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>