| Platform | Since |
|---|---|
| Android | 0.8 |
| iPhone | 0.8 |
| iPad | 0.8 |
The Sound object is returned by Titanium.Media.createSound and is useful for playing basic sounds. The Sound object loads the entire media resource in memory before playing. If you need to support streaming, use the Titanium.Media.createAudioPlayer API.
Simple example of playing a WAVE file from the Resources directory.
var player = Ti.Media.createSound({url:"sound.wav"}); player.play();
| Name | Summary |
|---|---|
| addEventListener |
Adds the specified callback as an event listener for the named event. |
| fireEvent |
Fires a synthesized event to any registered listeners. |
| getAllowBackground |
Gets the value of the allowBackground property. (Android only.) |
| getDuration |
Gets the value of the duration property. |
| getLooping |
Gets the value of the looping property. |
| getPaused |
Gets the value of the paused property. |
| getPlaying |
Gets the value of the playing property. |
| getTime |
return the current time position of the audio |
| getUrl |
Gets the value of the url property. |
| getVolume |
return the value of the audio |
| isLooping |
returns true if the audio will loop |
| isPaused |
returns true if the audio is paused |
| isPlaying |
returns true if the audio is playing |
| pause |
temporarily pause the audio. to resume, invoke |
| play |
starting playing the source. if paused, will resume. |
| release |
release all internal resources. this is typically unnecessary but can be useful if you load a large audio file in |
| removeEventListener |
Removes the specified callback as an event listener for the named event. |
| reset |
reset the audio to the beginning. |
| setAllowBackground |
Sets the value of the allowBackground property. (Android only.) |
| setDuration |
Sets the value of the duration property. |
| setLooping |
control whether the audio should loop |
| setPaused |
control whether the audio is paused |
| setPlaying |
Sets the value of the playing property. |
| setTime |
set the time position of the audio |
| setUrl |
Sets the value of the url property. |
| setVolume |
set the volume of the audio |
| stop |
stop playing the audio and reset it to the beginning. |
| Name | Type | Summary |
|---|---|---|
| allowBackground | Boolean |
boolean to indicate if audio should continue playing even if Activity is paused (Android only.) |
| duration | Number |
the duration of the audio. |
| looping | Boolean |
boolean to indicate if the audio should loop upon completion |
| paused | Boolean |
boolean to indicate if the audio is paused |
| playing | Boolean |
boolean to indicate if the audio is playing |
| time | Number |
the time position of the audio. |
| url | String |
url to the audio |
| volume | Number |
the volume of the audio. this volume only affects the media, not the device audio. |
| Name | Summary |
|---|---|
| complete |
fired when the audio has completed |
| error |
called when an error is received playing the audio. |
| interrupted |
called when the audio is interrupted by the device. this is typically called during an interruption due to an incoming phone call. |
| resume |
called when the audio is resumed after an interruption. |