Skip to content

Commit

Permalink
fix(player): add missing media event details
Browse files Browse the repository at this point in the history
  • Loading branch information
mihar-22 committed Nov 1, 2023
1 parent 815335d commit e79ad85
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions packages/vidstack/src/core/api/media-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,26 @@ export interface MediaAudioTrackChangeEvent extends MediaEvent<AudioTrack | null
*/
export interface MediaAutoplayChangeEvent extends MediaEvent<boolean> {}

export interface MediaAutoplayFailEventDetail {
muted: boolean;
error: Error;
}

/**
* Fired when an autoplay attempt has failed. The event detail contains the error that
* had occurred on the last autoplay attempt which caused it to fail.
*/
export interface MediaAutoplayFailEvent
extends MediaEvent<{
muted: boolean;
error: Error;
}> {}
export interface MediaAutoplayFailEvent extends MediaEvent<MediaAutoplayFailEventDetail> {}

export interface MediaAutoplayEventDetail {
muted: boolean;
}

/**
* Fired when an autoplay attempt has successfully been made (ie: media playback has automatically
* started). The event detail whether media is `muted` before any attempts are made.
*/
export interface MediaAutoplayEvent extends MediaEvent<{ muted: boolean }> {}
export interface MediaAutoplayEvent extends MediaEvent<MediaAutoplayEventDetail> {}

/**
* Fired when the provider can begin loading media. This depends on the type of `loading`
Expand Down Expand Up @@ -373,17 +378,18 @@ export interface MediaPlaysinlineChangeEvent extends MediaEvent<boolean> {}
*/
export interface MediaPosterChangeEvent extends MediaEvent<string> {}

export interface MediaProgressEventDetail {
buffered: TimeRanges;
seekable: TimeRanges;
}

/**
* Fired periodically as the browser loads a resource.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/progress_event}
* @detail progress
*/
export interface MediaProgressEvent
extends MediaEvent<{
buffered: TimeRanges;
seekable: TimeRanges;
}> {}
export interface MediaProgressEvent extends MediaEvent<MediaProgressEventDetail> {}

/**
* Fired when the new media provider loader has been selected and rendered. This will be `null` if
Expand Down Expand Up @@ -518,17 +524,18 @@ export interface MediaReplayEvent extends MediaEvent<void> {
request?: RE.MediaPlayRequestEvent;
}

export interface MediaTimeUpdateEventDetail {
currentTime: number;
played: TimeRanges;
}

/**
* Fired when the `currentTime` property value changes due to media playback or the
* user seeking.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/timeupdate_event}
*/
export interface MediaTimeUpdateEvent
extends MediaEvent<{
currentTime: number;
played: TimeRanges;
}> {}
export interface MediaTimeUpdateEvent extends MediaEvent<MediaTimeUpdateEventDetail> {}

/**
* Fired when the `streamType` property changes value. The event detail contains the type of
Expand Down

0 comments on commit e79ad85

Please sign in to comment.