Skip to content

Commit fdd9652

Browse files
authored
fix: Detect and skip stall correctly (#8390)
1 parent 5f18231 commit fdd9652

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/media/gap_jumping_controller.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,26 @@ shaka.media.GapJumpingController = class {
304304
const threshold = this.config_.stallThreshold;
305305
const skip = this.config_.stallSkip;
306306

307-
const onStall = (at, duration) => {
307+
const onStall = async (at, duration) => {
308308
goog.asserts.assert(this.video_, 'Must have video');
309+
const bufferedInfo =
310+
shaka.media.TimeRangesUtils.getBufferedInfo(this.video_.buffered);
311+
if (!bufferedInfo.length) {
312+
// Nothing in the buffer.
313+
return;
314+
}
309315
shaka.log.debug(`Stall detected at ${at} for ${duration} seconds.`);
310316

311317
if (skip) {
312318
shaka.log.debug(`Seeking forward ${skip} seconds to break stall.`);
313319
this.video_.currentTime += skip;
314320
} else {
321+
shaka.log.debug(
322+
'Wait for play to avoid reject a possible other play call.');
323+
await this.video_.play();
324+
if (!this.video_) {
325+
return;
326+
}
315327
shaka.log.debug('Pausing and unpausing to break stall.');
316328
this.video_.pause();
317329
this.video_.play();

0 commit comments

Comments
 (0)