diff --git a/demo/common/message_ids.js b/demo/common/message_ids.js index 3946435791..5d3fff0615 100644 --- a/demo/common/message_ids.js +++ b/demo/common/message_ids.js @@ -235,6 +235,7 @@ shakaDemo.MessageIds = { TRICK_PLAY_CONTROLS_WARNING: 'DEMO_TRICK_PLAY_CONTROLS_WARNING', UI_LOCALE: 'DEMO_UI_LOCALE', UPDATE_EXPIRATION_TIME: 'DEMO_UPDATE_EXPIRATION_TIME', + UPDATE_INTERVAL_SECONDS: 'DEMO_UPDATE_INTERVAL_SECONDS', USE_NATIVE_HLS_SAFARI: 'DEMO_USE_NATIVE_HLS_SAFARI', USE_PERSISTENT_LICENSES: 'DEMO_USE_PERSISTENT_LICENSES', VIDEO_ROBUSTNESS: 'DEMO_VIDEO_ROBUSTNESS', diff --git a/demo/config.js b/demo/config.js index 1fa232a556..e4f5556ea3 100644 --- a/demo/config.js +++ b/demo/config.js @@ -359,7 +359,10 @@ shakaDemo.Config = class { .addBoolInput_(MessageIds.FORCE_HTTPS, 'streaming.forceHTTPS') .addBoolInput_(MessageIds.PREFER_NATIVE_HLS, - 'streaming.preferNativeHls'); + 'streaming.preferNativeHls') + .addNumberInput_(MessageIds.UPDATE_INTERVAL_SECONDS, + 'streaming.updateIntervalSeconds', + /* canBeDecimal= */ true); if (!shakaDemoMain.getNativeControlsEnabled()) { this.addBoolInput_(MessageIds.ALWAYS_STREAM_TEXT, diff --git a/demo/locales/en.json b/demo/locales/en.json index d83f30c3c1..ce39dbd531 100644 --- a/demo/locales/en.json +++ b/demo/locales/en.json @@ -208,6 +208,7 @@ "DEMO_UNSUPPORTED_NO_LICENSE_SUPPORT": "Your browser does not support offline licenses for the required key systems.", "DEMO_UNSUPPORTED_NO_OFFLINE": "Your browser does not support offline storage.", "DEMO_UPDATE_EXPIRATION_TIME": "Update expiration time", + "DEMO_UPDATE_INTERVAL_SECONDS": "Update interval seconds", "DEMO_UPLYNK": "Verizon Digital Media Services", "DEMO_USE_FULL_SEGMENTS_FOR_START_TIME": "Use Full Segments For Start Time", "DEMO_USE_NATIVE_HLS_SAFARI": "Use native HLS on Safari", diff --git a/demo/locales/source.json b/demo/locales/source.json index fc77a844e4..605585b4f9 100644 --- a/demo/locales/source.json +++ b/demo/locales/source.json @@ -839,6 +839,10 @@ "description": "The name of a configuration value.", "message": "Update expiration time" }, + "DEMO_UPDATE_INTERVAL_SECONDS": { + "description": "The name of a configuration value.", + "message": "Update interval seconds" + }, "DEMO_UPLYNK": { "description": "Text that describes an asset that comes from the Verizon Digital Media Services asset library.", "message": "[PROPER_NAME:Verizon Digital Media Services]" diff --git a/externs/shaka/player.js b/externs/shaka/player.js index 88ddbc6970..0ca8ffa8b6 100644 --- a/externs/shaka/player.js +++ b/externs/shaka/player.js @@ -789,7 +789,8 @@ shaka.extern.ManifestConfiguration; * lowLatencyMode: boolean, * autoLowLatencyMode: boolean, * forceHTTPS: boolean, - * preferNativeHls: boolean + * preferNativeHls: boolean, + * updateIntervalSeconds: number * }} * * @description @@ -896,6 +897,8 @@ shaka.extern.ManifestConfiguration; * If true, if the protocol is HTTP change it to HTTPs. * @property {boolean} preferNativeHls * If true, prefer native HLS playback when possible, regardless of platform. + * @property {number} updateIntervalSeconds + * The minimum number of seconds to see if the manifest has changes. * * @exportDoc */ diff --git a/lib/media/streaming_engine.js b/lib/media/streaming_engine.js index 8316c45531..d62d1511e1 100644 --- a/lib/media/streaming_engine.js +++ b/lib/media/streaming_engine.js @@ -1001,10 +1001,10 @@ shaka.media.StreamingEngine = class { if (bufferedAhead >= scaledBufferingGoal) { shaka.log.v2(logPrefix, 'buffering goal met'); - // Do not try to predict the next update. Just poll twice every second. - // The playback rate can change at any time, so any prediction we make now - // could be terribly invalid soon. - return 0.5; + // Do not try to predict the next update. Just poll according to + // configuration (seconds). The playback rate can change at any time, so + // any prediction we make now could be terribly invalid soon. + return this.config_.updateIntervalSeconds / 2; } const bufferEnd = @@ -1016,7 +1016,7 @@ shaka.media.StreamingEngine = class { // In any case just try again... if the manifest is incomplete or is not // being updated then we'll idle forever; otherwise, we'll end up getting // a SegmentReference eventually. - return 1; + return this.config_.updateIntervalSeconds; } // Do not let any one stream get far ahead of any other. @@ -1047,7 +1047,7 @@ shaka.media.StreamingEngine = class { // For example, let video buffering catch up to audio buffering before // fetching another audio segment. shaka.log.v2(logPrefix, 'waiting for other streams to buffer'); - return 1; + return this.config_.updateIntervalSeconds; } const p = this.fetchAndAppend_(mediaState, presentationTime, reference); diff --git a/lib/util/player_configuration.js b/lib/util/player_configuration.js index 500cbddcc4..1be295a4fe 100644 --- a/lib/util/player_configuration.js +++ b/lib/util/player_configuration.js @@ -162,6 +162,7 @@ shaka.util.PlayerConfiguration = class { autoLowLatencyMode: false, forceHTTPS: false, preferNativeHls: false, + updateIntervalSeconds: 1, }; // Some browsers will stop earlier than others before a gap (e.g., Edge