Skip to content

Commit 7618160

Browse files
committed
Added query-param stream linking to demo player
Added query-param stream linking to demo player
1 parent 0b77562 commit 7618160

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

index.html

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232
(function(window, videojs) {
3333
var player = window.player = videojs('videojs-http-source-selector-player');
3434
player.httpSourceSelector();
35+
//Load stream from query param /?stream=MYHLS_STREAM_URL_GOES_HERE
36+
var queryParamStream = getQueryString('stream');
37+
if(queryParamStream !== null)
38+
{
39+
document.getElementById("streamURL").value = queryParamStream;
40+
player.src({ type: "application/x-mpegURL", src: document.getElementById("streamURL").value });
41+
}
3542
}(window, window.videojs));
3643

3744
function loadStream(){
@@ -48,6 +55,20 @@
4855
console.log("Add caption: "+document.getElementById("caption2URL").value );
4956
player.addRemoteTextTrack({src: document.getElementById("caption2URL").value, label: 'Caption 2'}, false);
5057
}
58+
59+
/**
60+
* Get the value of a querystring
61+
* @param {String} field The field to get the value of
62+
* @param {String} url The URL to get the value from (optional)
63+
* @return {String} The field value
64+
*/
65+
function getQueryString ( field, url )
66+
{
67+
var href = url ? url : window.location.href;
68+
var reg = new RegExp( '[?&]' + field + '=([^]*)', 'i' );
69+
var string = reg.exec(href);
70+
return string ? string[1] : null;
71+
}
5172
</script>
5273
</body>
5374
</html>

0 commit comments

Comments
 (0)