AudioFile
Methods
initWithLocalFile
initWithLocalFile(name: string
, type: string
, usage: ): Promise<void>
Initialize AudioFile instance to play local audio file.On android, the audio file must be located in resources "raw" folder.
Parameters
name:
string
Local audio file name
type:
string
Local audio file type/format, for example ".mp3"
usage:
Audio file usage mode. ANDROID ONLY.
Returns
type:
Promise<void>
loadFile
loadFile(url: string
, usage: ): Promise<void>
Initialize AudioFile to play a stream from a network.
Parameters
url:
string
HTTP URL of the stream to play
usage:
Audio file usage mode. ANDROID ONLY.
Returns
type:
Promise<void>
off
off(eventType: , event: Function
): void
Remove a handler for the specified AudioFile event.
Parameters
eventType:
event:
Function
OptionalHandler function. If not specified, all handlers for the event will be removed.
Returns
type:
void
on
on(eventType: , event: Function
): void
Register a handler for the specified AudioFile event. One event can have more than one handler. Use the [AudioFile#off] method to delete a handler.
Parameters
eventType:
event:
Function
Returns
type:
void
play
play(looped: boolean
): Promise<AudioFileEventTypes.Started>
Start playing the audio file repeatedly or once.
Parameters
looped:
boolean
Indicate if the audio file should be played repeatedly or once
Returns
type:
Promise<AudioFileEventTypes.Started>
releaseResources
releaseResources(): void
Release all resources allocated to play the audio file.Must be called even if the audio file was not played.
Returns
type:
void
stop
stop(): Promise<AudioFileEventTypes.Stopped>
Stop playing of the audio file.
Returns
type:
Promise<AudioFileEventTypes.Stopped>
Props
looped
looped: boolean
Indicate if the audio file should be played repeatedly or once
name
name: string
| null
Local audio file name
url
url: string
| null
HTTP URL of the stream to play