Skip to content

Commit

Permalink
fix(player): native renderer might be null due to race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
mihar-22 committed Nov 6, 2023
1 parent 5820094 commit 5e2d90c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion packages/vidstack/src/core/api/media-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ export interface MediaAutoplayEvent extends MediaEvent<MediaAutoplayEventDetail>
* that has been configured. The `eager` strategy will be immediate, and `lazy` once the provider
* has entered the viewport.
*/
export interface MediaCanLoadEvent extends MediaEvent<void> {}
export interface MediaCanLoadEvent extends MediaEvent<void> {
request?: RE.MediaStartLoadingRequestEvent;
}

/**
* Fired when the user agent can play the media, but estimates that **not enough** data has been
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ export class TextRenderers {
// See `native-hls-text-tracks.ts` for discovery.
if (this._nativeDisplay || currentTrack?.[TextTrackSymbol._nativeHLS]) {
this._customRenderer?.changeTrack(null);
this._nativeRenderer!.setDisplay(true);
this._nativeRenderer!.changeTrack(currentTrack);
this._nativeRenderer?.setDisplay(true);
this._nativeRenderer?.changeTrack(currentTrack);
return;
}

this._nativeRenderer!.setDisplay(false);
this._nativeRenderer!.changeTrack(null);
this._nativeRenderer?.setDisplay(false);
this._nativeRenderer?.changeTrack(null);

if (!currentTrack) {
this._customRenderer?.changeTrack(null);
Expand Down

0 comments on commit 5e2d90c

Please sign in to comment.