Skip to content

Commit

Permalink
Fix live playback on WebOS (#3750) (#3754)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
lkinasiewicz authored Sep 8, 2021
1 parent e18baf8 commit 257ddb4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ declare namespace dashjs {
keepProtectionMediaKeys?: boolean,
},
buffer?: {
enableSeekDecorrelationFix?: boolean,
fastSwitchEnabled?: boolean,
flushBufferAtTrackSwitch?: boolean,
reuseExistingSourceBuffers?: boolean,
Expand Down
7 changes: 7 additions & 0 deletions src/core/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import {HTTPRequest} from '../streaming/vo/metrics/HTTPRequest';
* keepProtectionMediaKeys: false
* },
* buffer: {
enableSeekDecorrelationFix: true,
* fastSwitchEnabled: true,
* flushBufferAtTrackSwitch: false,
* reuseExistingSourceBuffers: true,
Expand Down Expand Up @@ -239,6 +240,11 @@ import {HTTPRequest} from '../streaming/vo/metrics/HTTPRequest';

/**
* @typedef {Object} Buffer
* @property {boolean} [enableSeekDecorrelationFix=true]
* Enables a workaround for playback start on some devices, e.g. WebOS 4.9.
* It is necessary because some browsers do not support setting currentTime on video element to a value that is outside of current buffer.
*
* If you experience unexpected seeking triggered by BufferController, you can try setting this value to false.
* @property {boolean} [fastSwitchEnabled=true]
* 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.
*
Expand Down Expand Up @@ -761,6 +767,7 @@ function Settings() {
keepProtectionMediaKeys: false
},
buffer: {
enableSeekDecorrelationFix: true,
fastSwitchEnabled: true,
flushBufferAtTrackSwitch: false,
reuseExistingSourceBuffers: true,
Expand Down
12 changes: 11 additions & 1 deletion src/streaming/controllers/BufferController.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,17 @@ function BufferController(config) {
range = getRangeAt(seekTarget, segmentDuration);
if (!range) return;

if (currentTime < range.start) {
if (settings.get().streaming.buffer.enableSeekDecorrelationFix && Math.abs(currentTime - seekTarget) > segmentDuration) {
// If current video model time is decorrelated from seek target (and appended buffer) then seek video element
// (in case of live streams on some browsers/devices for which we can't set video element time at unavalaible range)

// Check if appended segment is not anterior from seek target (segments timeline/template tolerance)
if (seekTarget <= range.end) {
// Seek video element to seek target or range start if appended buffer starts after seek target (segments timeline/template tolerance)
playbackController.seek(Math.max(seekTarget, range.start), false, true);
seekTarget = NaN;
}
} else if (currentTime < range.start) {
// If appended buffer starts after seek target (segments timeline/template tolerance) then seek to range start
playbackController.seek(range.start, false, true);
seekTarget = NaN;
Expand Down

0 comments on commit 257ddb4

Please sign in to comment.