Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for subtitle loading after hls.stopload() was used #3063

Merged
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/controller/subtitle-stream-controller.js
Expand Up @@ -38,6 +38,19 @@ export class SubtitleStreamController extends BaseStreamController {
// lastAVStart stores the time in seconds for the start time of a level load
this.lastAVStart = 0;
this._onMediaSeeking = this.onMediaSeeking.bind(this);
this._onMediaSeeked = this.onMediaSeeked.bind(this);
}

startLoad () {
this.stopLoad();
this.state = State.IDLE;

// Check if we already have a track with necessary details to load fragments
const currentTrack = this.tracks[this.currentTrackId];
if (currentTrack && currentTrack.details) {
this.setInterval(TICK_INTERVAL);
this.tick();
}
}

onSubtitleFragProcessed (data) {
Expand Down Expand Up @@ -79,6 +92,7 @@ export class SubtitleStreamController extends BaseStreamController {
onMediaAttached ({ media }) {
this.media = media;
media.addEventListener('seeking', this._onMediaSeeking);
media.addEventListener('seeked', this._onMediaSeeked);
this.state = State.IDLE;
}

Expand All @@ -87,6 +101,7 @@ export class SubtitleStreamController extends BaseStreamController {
return;
}
this.media.removeEventListener('seeking', this._onMediaSeeking);
this.media.removeEventListener('seeked', this._onMediaSeeked);
this.fragmentTracker.removeAllFragments();
this.currentTrackId = -1;
this.tracks.forEach((track) => {
Expand Down Expand Up @@ -237,6 +252,7 @@ export class SubtitleStreamController extends BaseStreamController {

stopLoad () {
this.lastAVStart = 0;
this.fragPrevious = null;
super.stopLoad();
}

Expand All @@ -245,6 +261,10 @@ export class SubtitleStreamController extends BaseStreamController {
}

onMediaSeeking () {
this.fragPrevious = null;
this.stopLoad();
}

onMediaSeeked () {
this.startLoad();
netTrekfd marked this conversation as resolved.
Show resolved Hide resolved
}
}