@@ -14,7 +14,7 @@ export type RegisterAudioPlayerErrorParams = {
1414 errCode ?: AudioPlayerErrorCode ;
1515} ;
1616
17- export type AudioDescriptor = {
17+ export type AudioPlayerDescriptor = {
1818 id : string ;
1919 src : string ;
2020 /** Audio duration in seconds. */
@@ -31,19 +31,25 @@ export type AudioPlayerPlayAudioParams = {
3131} ;
3232
3333export type AudioPlayerState = {
34+ /** Signals whether the browser can play the record. */
3435 canPlayRecord : boolean ;
3536 /** Current playback speed. Initiated with the first item of the playbackRates array. */
3637 currentPlaybackRate : number ;
38+ /** The audio element ref */
3739 elementRef : HTMLAudioElement | null ;
40+ /** Signals whether the playback is in progress. */
3841 isPlaying : boolean ;
42+ /** Keeps the latest playback error reference. */
3943 playbackError : Error | null ;
4044 /** An array of fractional numeric values of playback speed to override the defaults (1.0, 1.5, 2.0) */
4145 playbackRates : number [ ] ;
46+ /** Playback progress expressed in percent. */
4247 progressPercent : number ;
48+ /** Playback progress expressed in seconds. */
4349 secondsElapsed : number ;
4450} ;
4551
46- export type AudioPlayerOptions = AudioDescriptor & {
52+ export type AudioPlayerOptions = AudioPlayerDescriptor & {
4753 /** An array of fractional numeric values of playback speed to override the defaults (1.0, 1.5, 2.0) */
4854 playbackRates ?: number [ ] ;
4955 plugins ?: AudioPlayerPlugin [ ] ;
@@ -65,12 +71,15 @@ export const defaultRegisterAudioPlayerError = ({
6571export const elementIsPlaying = ( audioElement : HTMLAudioElement | null ) =>
6672 audioElement && ! ( audioElement . paused || audioElement . ended ) ;
6773
68- export type SeekFn = ( params : { clientX : number ; currentTarget : HTMLDivElement } ) => void ;
74+ export type SeekFn = ( params : {
75+ clientX : number ;
76+ currentTarget : HTMLDivElement ;
77+ } ) => Promise < void > ;
6978
7079export class AudioPlayer {
7180 state : StateStore < AudioPlayerState > ;
7281 /** The audio MIME type that is checked before the audio is played. If the type is not supported the controller registers error in playbackError. */
73- private _data : AudioDescriptor ;
82+ private _data : AudioPlayerDescriptor ;
7483 private _plugins = new Map < string , AudioPlayerPlugin > ( ) ;
7584 private playTimeout : ReturnType < typeof setTimeout > | undefined = undefined ;
7685 private unsubscribeEventListeners : ( ( ) => void ) | null = null ;
@@ -272,7 +281,7 @@ export class AudioPlayer {
272281 }
273282 } ;
274283
275- setDescriptor ( descriptor : AudioDescriptor ) {
284+ setDescriptor ( descriptor : AudioPlayerDescriptor ) {
276285 this . _data = { ...this . _data , ...descriptor } ;
277286 if ( descriptor . src !== this . src && this . elementRef ) {
278287 this . elementRef . src = descriptor . src ;
0 commit comments