API Docs for: 1.0.1

Grape.Audio Class

Represents a sound. It decides from the extension of the given url which to use.

Constructor

Grape.Audio

(
  • opts
  • url1
  • url2
  • url3
)

Parameters:

  • opts Object

    Audio options

  • url1 String

    Audio URL

  • url2 String

    Audio URL fallback if url1 extension is not supported

  • url3 String

    Audio URL fallback if url2 extension is not supported

Methods

getResourceKey

()

An abstract method which should return the same key when the resource is the same, it is used as cache key. A typical key is the url.

loadResource

(
  • onFinish
  • onError
  • onProgress
)

This method is called when we want to load the resource and it is not in the cache.

Parameters:

  • onFinish Function

    Should be called when the resource is ready. The parameter is the loaded data.

  • onError Function

    Should be called when an error occurs

  • onProgress Function

    Should be called when the loading progress changes (0-100)

play

()

Plays the audio.

process

(
  • (*)
)

This method is called after load is called. If load is called multiple times, this method is not called more than once. It should initialize the resource with the loaded data.

Parameters:

  • (*) Object

    data The loaded data (passed to the onFinish method in loadResource