Rate this page:

AudioFile

Methods

initWithLocalFile

Copy URL

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

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

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

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

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

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

Stops playing of the audio file.

Returns

Props

looped

Copy URL

Whether the audio file should be played repeatedly or once.

name

Copy URL

Local audio file name.

url

Copy URL

HTTP URL of the stream to play.