declare namespace Titanium { namespace Media { /** * Base event for class Titanium.Media.Sound */ interface SoundBaseEvent extends Ti.Event { /** * Source object that fired the event. */ source: Titanium.Media.Sound; } /** * Fired when the state of the playback changes. */ interface Sound_change_Event extends SoundBaseEvent { /** * Text description of the state of playback. */ description: string; /** * Current state of playback. */ state: number; } /** * Fired when the audio has finished playing. */ interface Sound_complete_Event extends SoundBaseEvent { /** * Error code. * Error code will be `0` if `success` is `true`, nonzero otherwise. If the error * was generated by the operating system, that system's error value is used. * Otherwise, this value will be `-1`. */ code: number; /** * Error message, if any returned. Will be undefined if `success` is `true`. */ error: string; /** * Indicates if the sound was played successfully. * Returns `true` if request succeeded, `false` otherwise. */ success: boolean; } /** * Fired when an error occurs while playing the audio. */ interface Sound_error_Event extends SoundBaseEvent { /** * Error code. * If the error was generated by the operating system, that system's error value * is used. Otherwise, this value will be `-1`. */ code: number; /** * Error message, if any returned. May be `undefined`. */ error: string; /** * Error message. * @deprecated Use the `error` property instead */ message: never; /** * Indicates a successful operation. Returns `false`. */ success: boolean; } /** * Fired when audio playback is interrupted by the device. */ interface Sound_interrupted_Event extends SoundBaseEvent { } /** * Fired when audio playback is resumed after an interruption. */ interface Sound_resume_Event extends SoundBaseEvent { /** * Indicates if the resume was from an interruption. */ interruption: boolean; } interface SoundEventMap extends ProxyEventMap { change: Sound_change_Event; complete: Sound_complete_Event; error: Sound_error_Event; interrupted: Sound_interrupted_Event; resume: Sound_resume_Event; } /** * An object for playing basic audio resources. */ class Sound extends Titanium.Proxy { /** * Used to identify the volume of audio streams for alarms. */ readonly AUDIO_TYPE_ALARM: number; /** * Used to identify the volume of audio streams for media playback. */ readonly AUDIO_TYPE_MEDIA: number; /** * Used to identify the volume of audio streams for notifications. */ readonly AUDIO_TYPE_NOTIFICATION: number; /** * Used to identify the volume of audio streams for the phone ring. */ readonly AUDIO_TYPE_RING: number; /** * Used to identify the volume of audio streams for DTMF tones or beeps. */ readonly AUDIO_TYPE_SIGNALLING: number; /** * Used to identify the volume of audio streams for voice calls. */ readonly AUDIO_TYPE_VOICE: number; /** * Audio data is being buffered from the network. */ readonly STATE_BUFFERING: number; /** * Audio playback is being initialized. */ readonly STATE_INITIALIZED: number; /** * Playback is paused. */ readonly STATE_PAUSED: number; /** * Audio playback is active. */ readonly STATE_PLAYING: number; /** * Audio playback is starting. */ readonly STATE_STARTING: number; /** * Audio playback is stopped. */ readonly STATE_STOPPED: number; /** * Audio playback is stopping. */ readonly STATE_STOPPING: number; /** * Player is waiting for audio data from the network. */ readonly STATE_WAITING_FOR_DATA: number; /** * Player is waiting for audio data to fill the queue. */ readonly STATE_WAITING_FOR_QUEUE: number; /** * Determines whether the audio should continue playing even when its activity is paused. */ allowBackground: boolean; /** * Changes the audio-stream-type. */ audioType: number; /** * Duration of the audio resource. */ readonly duration: number; /** * Determines whether the audio should loop upon completion. */ looping: boolean; /** * Indicates if the audio is paused. */ paused: boolean; /** * Indicates if the audio is playing. */ readonly playing: boolean; /** * Current playback position of the audio. */ time: number; /** * URL identifying the audio resource. */ url: string; /** * Volume of the audio from 0.0 (muted) to 1.0 (loudest). */ volume: number; /** * Adds the specified callback as an event listener for the named event. */ addEventListener(name: K, callback: (this: Titanium.Media.Sound, event: SoundEventMap[K]) => void): void; /** * Adds the specified callback as an event listener for the named event. */ addEventListener(name: string, callback: (param0: Titanium.Event) => void): void; /** * Fires a synthesized event to any registered listeners. */ fireEvent(name: K, event?: SoundEventMap[K]): void; /** * Fires a synthesized event to any registered listeners. */ fireEvent(name: string, event?: any): void; /** * Returns the value of the [looping](Titanium.Media.Sound.looping) property. * @deprecated Use the property instead. */ isLooping(): boolean; /** * Returns the value of the [paused](Titanium.Media.Sound.paused) property. * @deprecated Use the property instead. */ isPaused(): boolean; /** * Returns the value of the [playing](Titanium.Media.Sound.playing) property. * @deprecated Use the property instead. */ isPlaying(): boolean; /** * Pauses the audio. */ pause(): void; /** * Starting playing the sound, or resume playing a paused sound. */ play(): void; /** * Releases all internal resources. */ release(): void; /** * Removes the specified callback as an event listener for the named event. */ removeEventListener(name: K, callback: (this: Titanium.Media.Sound, event: SoundEventMap[K]) => void): void; /** * Removes the specified callback as an event listener for the named event. */ removeEventListener(name: string, callback: (param0: Titanium.Event) => void): void; /** * Resets the audio playback position to the beginning. */ reset(): void; /** * Sets the value of the [looping](Titanium.Media.Sound.looping) property. * @deprecated Set the value of the [looping](Titanium.Media.Sound.looping) property directly. */ setLooping(looping: boolean): void; /** * Sets the value of the [paused](Titanium.Media.Sound.paused) property. * @deprecated It is preferable to use the [pause](Titanium.Media.Sound.pause) and * [play](Titanium.Media.Sound.play) methods instead. * */ setPaused(paused: boolean): void; /** * Stops playing the audio and resets the playback position to the beginning of the clip. */ stop(): void; } } }