@@ -19,11 +19,14 @@ const testStreams = require('../tests/test-streams');
1919const defaultTestStreamUrl = testStreams [ Object . keys ( testStreams ) [ 0 ] ] . url ;
2020const sourceURL = decodeURIComponent ( getURLParam ( 'src' , defaultTestStreamUrl ) ) ;
2121
22- let demoConfig = getURLParam ( 'demoConfig' , null ) ;
23- if ( demoConfig ) {
24- demoConfig = JSON . parse ( atob ( demoConfig ) ) ;
25- } else {
26- demoConfig = { } ;
22+ let demoConfig = { } ;
23+ const demoConfigParam = getURLParam ( 'demoConfig' , null ) ;
24+ if ( demoConfigParam ) {
25+ try {
26+ demoConfig = JSON . parse ( atob ( demoConfigParam ) ) ;
27+ } catch ( error ) {
28+ console . warn ( 'Failed to parse demoConfig:' , error ) ;
29+ }
2730}
2831
2932const hlsjsDefaults = {
@@ -33,6 +36,16 @@ const hlsjsDefaults = {
3336 backBufferLength : 60 * 1.5 ,
3437} ;
3538
39+ const hlsjsConfigParam = getURLParam ( 'hlsjsConfig' , null ) ;
40+ let hlsjsConfig = hlsjsDefaults ;
41+ if ( hlsjsConfigParam ) {
42+ try {
43+ hlsjsConfig = JSON . parse ( atob ( hlsjsConfigParam ) ) ;
44+ } catch ( error ) {
45+ console . warn ( 'Failed to parse hlsjsConfig:' , error ) ;
46+ }
47+ }
48+
3649let enableStreaming = getDemoConfigPropOrDefault ( 'enableStreaming' , true ) ;
3750let autoRecoverError = getDemoConfigPropOrDefault ( 'autoRecoverError' , true ) ;
3851let levelCapping = getDemoConfigPropOrDefault ( 'levelCapping' , - 1 ) ;
@@ -1497,12 +1510,17 @@ function onDemoConfigChanged(firstLoad) {
14971510 persistEditorValue ( ) ;
14981511 }
14991512
1513+ updatePermalink ( firstLoad )
1514+ }
1515+
1516+ function updatePermalink ( firstLoad ) {
15001517 const serializedDemoConfig = btoa ( JSON . stringify ( demoConfig ) ) ;
1518+ const serializedHlsjsConfig = btoa ( JSON . stringify ( hlsjsConfig ) ) ;
15011519 const baseURL = document . URL . split ( '?' ) [ 0 ] ;
15021520 const streamURL = $ ( '#streamURL' ) . val ( ) ;
15031521 const permalinkURL = `${ baseURL } ?src=${ encodeURIComponent (
15041522 streamURL
1505- ) } &demoConfig=${ serializedDemoConfig } `;
1523+ ) } &demoConfig=${ serializedDemoConfig } &hlsjsConfig= ${ serializedHlsjsConfig } `;
15061524
15071525 $ ( '#StreamPermalink' ) . html ( `<a href="${ permalinkURL } ">${ permalinkURL } </a>` ) ;
15081526 if ( ! firstLoad && self . location . href !== permalinkURL ) {
@@ -1565,7 +1583,7 @@ function setupConfigEditor() {
15651583 configEditor . setTheme ( 'ace/theme/github' ) ;
15661584 configEditor . session . setMode ( 'ace/mode/json' ) ;
15671585
1568- const contents = hlsjsDefaults ;
1586+ const contents = hlsjsConfig ;
15691587 const shouldRestorePersisted =
15701588 JSON . parse ( localStorage . getItem ( STORAGE_KEYS . Editor_Persistence ) ) === true ;
15711589
@@ -1737,6 +1755,8 @@ function updateConfigEditorValue(obj) {
17371755
17381756function applyConfigEditorValue ( ) {
17391757 onDemoConfigChanged ( ) ;
1758+ hlsjsConfig = getEditorValue ( { parse : true } )
1759+ updatePermalink ( false ) ;
17401760 loadSelectedStream ( ) ;
17411761}
17421762
0 commit comments