Rate this page:

AudioFile

Methods

initWithLocalFile
Copy URL
initWithLocalFile(name: 

string

,
type:

string

,
usage:

AudioFileUsage

):

Promise<void>

Initializes an AudioFile instance to play local audio file.On android, the audio file should 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>

Initializes an 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

Removes a handler for the specified AudioFile event.

Parameters

  • event:

    Function

    Optional

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

Returns

  • type:

    void

on
Copy URL
on(eventType: 

AudioFileEventTypes

,
event:

Function

):

void

Registers 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>

Starts playing the audio file repeatedly or once.

Parameters

  • looped:

    boolean

    Whether the audio file should be played repeatedly or once

Returns

releaseResources
Copy URL
releaseResources(): 

void

Releases all resources allocated to play the audio file.Should be called even if the audio file has not been played.

Returns

  • type:

    void

stop
Copy URL
stop(): 

Promise<AudioFileEventTypes.Stopped>

Stops playing of the audio file.

Returns

Props

looped
Copy URL
looped: 

boolean

Whether 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.

Rate this page: