Rate this page:

AudioFile

Methods

initWithLocalFile

Copy URL
initWithLocalFile(name: 

string

,
type:

string

,
usage:

AudioFileUsage

):

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"

  • Audio file usage mode. ANDROID ONLY.

Returns

  • type:

    Promise<void>

loadFile

Copy URL
loadFile(url: 

string

,
usage:

AudioFileUsage

):

Promise<void>

Initialize AudioFile to play a stream from a network.

Parameters

  • url:

    string

    HTTP URL of the stream to play

  • Audio file usage mode. ANDROID ONLY.

Returns

  • type:

    Promise<void>

off

Copy URL
off(eventType: 

AudioFileEventTypes

,
event:

Function

):

void

Remove a handler for the specified AudioFile event.

Parameters

  • event:

    Function

    Optional

    Handler function. If not specified, all handlers for the event will be removed.

Returns

  • type:

    void

on

Copy URL
on(eventType: 

AudioFileEventTypes

,
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

Returns

  • type:

    void

play

Copy URL
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

releaseResources

Copy URL
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

Copy URL
stop(): 

Promise<AudioFileEventTypes.Stopped>

Stop playing of the audio file.

Returns

Props

looped

Copy URL
looped: 

boolean

Indicate if the audio file should be played repeatedly or once

name

Copy URL
name: 

string

|

null

Local audio file name

url

Copy URL
url: 

string

|

null

HTTP URL of the stream to play