Skip to content

Commit

Permalink
fix(player): hls tracks not initializing correctly
Browse files Browse the repository at this point in the history
closes #1211
  • Loading branch information
mihar-22 committed Mar 20, 2024
1 parent 20cc205 commit edddf3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/vidstack/src/providers/hls/hls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,12 @@ export class HLSController {
const event = new DOMEvent<HLS.NonNativeTextTracksData>(eventType, { detail: data });

let currentTrack = -1;

for (let i = 0; i < data.tracks.length; i++) {
const nonNativeTrack = data.tracks[i],
init = nonNativeTrack.subtitleTrack ?? nonNativeTrack.closedCaptions,
track = new TextTrack({
id: `hls-${nonNativeTrack!.kind}${i}`,
id: `hls-${nonNativeTrack!.kind}-${i}`,
src: init?.url,
label: nonNativeTrack!.label,
language: init?.lang,
Expand All @@ -116,9 +117,13 @@ export class HLSController {
}

private _onCuesParsed(eventType: string, data: HLS.CuesParsedData) {
const track = this._ctx.textTracks.getById(`hls-${data.track}`);
const index = this._instance?.subtitleTrack,
track = this._ctx.textTracks.getById(`hls-${data.type}-${index}`);

if (!track) return;

const event = new DOMEvent<HLS.CuesParsedData>(eventType, { detail: data });

for (const cue of data.cues) {
cue.positionAlign = 'auto';
track.addCue(cue, event);
Expand Down
1 change: 1 addition & 0 deletions packages/vidstack/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default defineConfig({
build: {
target: 'es2019',
},
publicDir: 'sandbox/public',
resolve: {
alias: {
'$test-utils': '/src/test-utils',
Expand Down

0 comments on commit edddf3b

Please sign in to comment.