File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 32
32
( function ( window , videojs ) {
33
33
var player = window . player = videojs ( 'videojs-http-source-selector-player' ) ;
34
34
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
+ }
35
42
} ( window , window . videojs ) ) ;
36
43
37
44
function loadStream ( ) {
48
55
console . log ( "Add caption: " + document . getElementById ( "caption2URL" ) . value ) ;
49
56
player . addRemoteTextTrack ( { src : document . getElementById ( "caption2URL" ) . value , label : 'Caption 2' } , false ) ;
50
57
}
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
+ }
51
72
</ script >
52
73
</ body >
53
74
</ html >
You can’t perform that action at this time.
0 commit comments