Skip to content

Commit

Permalink
fix(FEC-11052): audio stutters/lag in the newest V7 versions (#548)
Browse files Browse the repository at this point in the history
### Description of the Changes

Issue is that audio stutters when audio entry is playing and moving from entry's tab to other tabs and vice-versa on the browser.
The stutter is caused by a fix for the following iOS bug - [FEC-10014](#452).

Solution is to limit the change was made in FEC-10014 to only iOS (and not for progressive).

Solves [FEC-11052](https://kaltura.atlassian.net/browse/FEC-11052).
  • Loading branch information
lianbenjamin committed Mar 2, 2021
1 parent 3f8d095 commit 10b1f20
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/engines/html5/media-source/adapters/native-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ export default class NativeAdapter extends BaseMediaSourceAdapter {
* @static
*/
static _drmProtocol: ?Function = null;
/**
* The supported progressive mime types by the native adapter.
* @member {Array<string>} _progressiveMimeTypes
* @static
* @private
*/
static _progressiveMimeTypes: Array<string> = ['video/mp4', 'audio/mp3'];
/**
* The DRM handler playback.
* @type {?FairPlayDrmHandler}
Expand Down Expand Up @@ -286,7 +293,7 @@ export default class NativeAdapter extends BaseMediaSourceAdapter {
* @private
*/
_isProgressivePlayback(): boolean {
return this._sourceObj ? this._sourceObj.mimetype === 'video/mp4' : false;
return this._sourceObj ? NativeAdapter._progressiveMimeTypes.includes(this._sourceObj.mimetype.toLowerCase()) : false;
}

/**
Expand All @@ -310,14 +317,16 @@ export default class NativeAdapter extends BaseMediaSourceAdapter {
this._eventManager.listen(this._videoElement, Html5EventType.ABORT, () => this._clearHeartbeatTimeout());
this._eventManager.listen(this._videoElement, Html5EventType.SEEKED, () => this._syncCurrentTime());
// Sometimes when playing live in safari and switching between tabs the currentTime goes back with no seek events
this._eventManager.listen(window, 'focus', () =>
setTimeout(() => {
// In IOS HLS, sometimes when coming back from lock screen/Idle mode, the stream will get stuck, and only a small seek nudge will fix it.
this._videoElement.currentTime =
this._videoElement.currentTime > NUDGE_SEEK_AFTER_FOCUS ? this._videoElement.currentTime - NUDGE_SEEK_AFTER_FOCUS : 0;
this._syncCurrentTime();
}, BACK_TO_FOCUS_TIMEOUT)
);
this._eventManager.listen(window, 'focus', () => {
if (!this._isProgressivePlayback()) {
setTimeout(() => {
// In IOS HLS, sometimes when coming back from lock screen/Idle mode, the stream will get stuck, and only a small seek nudge will fix it.
this._videoElement.currentTime =
this._videoElement.currentTime > NUDGE_SEEK_AFTER_FOCUS ? this._videoElement.currentTime - NUDGE_SEEK_AFTER_FOCUS : 0;
this._syncCurrentTime();
}, BACK_TO_FOCUS_TIMEOUT);
}
});
if (this._isProgressivePlayback()) {
this._setProgressiveSource();
}
Expand Down

0 comments on commit 10b1f20

Please sign in to comment.