Skip to content

Commit 257ddb4

Browse files
authored
Fix live playback on WebOS (#3750) (#3754)
* Fix live playback on WebOS (#3750) Reverts some of the changes made in: a66913f (Timeline and multiperiod optimizations (#3413), 2021-04-23) * [Settings] Add enableSeekDecorrelationFix Allows disabling the workaround for live playback start (#3750)
1 parent e18baf8 commit 257ddb4

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ declare namespace dashjs {
176176
keepProtectionMediaKeys?: boolean,
177177
},
178178
buffer?: {
179+
enableSeekDecorrelationFix?: boolean,
179180
fastSwitchEnabled?: boolean,
180181
flushBufferAtTrackSwitch?: boolean,
181182
reuseExistingSourceBuffers?: boolean,

src/core/Settings.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ import {HTTPRequest} from '../streaming/vo/metrics/HTTPRequest';
8484
* keepProtectionMediaKeys: false
8585
* },
8686
* buffer: {
87+
enableSeekDecorrelationFix: true,
8788
* fastSwitchEnabled: true,
8889
* flushBufferAtTrackSwitch: false,
8990
* reuseExistingSourceBuffers: true,
@@ -239,6 +240,11 @@ import {HTTPRequest} from '../streaming/vo/metrics/HTTPRequest';
239240

240241
/**
241242
* @typedef {Object} Buffer
243+
* @property {boolean} [enableSeekDecorrelationFix=true]
244+
* Enables a workaround for playback start on some devices, e.g. WebOS 4.9.
245+
* It is necessary because some browsers do not support setting currentTime on video element to a value that is outside of current buffer.
246+
*
247+
* If you experience unexpected seeking triggered by BufferController, you can try setting this value to false.
242248
* @property {boolean} [fastSwitchEnabled=true]
243249
* When enabled, after an ABR up-switch in quality, instead of requesting and appending the next fragment at the end of the current buffer range it is requested and appended closer to the current time.
244250
*
@@ -761,6 +767,7 @@ function Settings() {
761767
keepProtectionMediaKeys: false
762768
},
763769
buffer: {
770+
enableSeekDecorrelationFix: true,
764771
fastSwitchEnabled: true,
765772
flushBufferAtTrackSwitch: false,
766773
reuseExistingSourceBuffers: true,

src/streaming/controllers/BufferController.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,17 @@ function BufferController(config) {
346346
range = getRangeAt(seekTarget, segmentDuration);
347347
if (!range) return;
348348

349-
if (currentTime < range.start) {
349+
if (settings.get().streaming.buffer.enableSeekDecorrelationFix && Math.abs(currentTime - seekTarget) > segmentDuration) {
350+
// If current video model time is decorrelated from seek target (and appended buffer) then seek video element
351+
// (in case of live streams on some browsers/devices for which we can't set video element time at unavalaible range)
352+
353+
// Check if appended segment is not anterior from seek target (segments timeline/template tolerance)
354+
if (seekTarget <= range.end) {
355+
// Seek video element to seek target or range start if appended buffer starts after seek target (segments timeline/template tolerance)
356+
playbackController.seek(Math.max(seekTarget, range.start), false, true);
357+
seekTarget = NaN;
358+
}
359+
} else if (currentTime < range.start) {
350360
// If appended buffer starts after seek target (segments timeline/template tolerance) then seek to range start
351361
playbackController.seek(range.start, false, true);
352362
seekTarget = NaN;

0 commit comments

Comments
 (0)