declare namespace Titanium { namespace Media { /** * Base event for class Titanium.Media.AudioPlayer */ interface AudioPlayerBaseEvent extends Ti.Event { /** * Source object that fired the event. */ source: Titanium.Media.AudioPlayer; } /** * Fired when the state of the playback changes. */ interface AudioPlayer_change_Event extends AudioPlayerBaseEvent { /** * Text description of the state of playback. */ description: number; /** * Current state of playback. */ state: number; } /** * Fired when the audio has finished playing. */ interface AudioPlayer_complete_Event extends AudioPlayerBaseEvent { /** * 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 the timed metadata was encountered most recently within the media as it plays. */ interface AudioPlayer_metadata_Event extends AudioPlayerBaseEvent { /** * An array of metadata items containing relevant information about the current media item. */ items: TiMetadataItemType[]; } /** * Fired when there's an error. */ interface AudioPlayer_error_Event extends AudioPlayerBaseEvent { /** * Error code. Different between android and iOS. */ code: number; /** * Error message. */ error: string; } /** * Fired once per second with the current progress during playback. */ interface AudioPlayer_progress_Event extends AudioPlayerBaseEvent { /** * Current progress, in milliseconds. */ progress: number; } /** * Fired once the [seekToTime](Titanium.Media.AudioPlayer.seek) method completes. */ interface AudioPlayer_seek_Event extends AudioPlayerBaseEvent { /** * The event for any prior seek request that is still in process will be invoked * immediately with the `finished` parameter set to `false`. * If the new request completes without being interrupted by another seek * request or by any other operation this event will be invoked with * the `finished` parameter set to `true`. */ finished: boolean; } interface AudioPlayerEventMap extends ProxyEventMap { change: AudioPlayer_change_Event; complete: AudioPlayer_complete_Event; error: AudioPlayer_error_Event; metadata: AudioPlayer_metadata_Event; progress: AudioPlayer_progress_Event; seek: AudioPlayer_seek_Event; } /** * An audio player object used for streaming audio to the device, and low-level control of the audio playback. */ class AudioPlayer 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. * @deprecated Use [Titanium.Media.AUDIO_STATE_BUFFERING](Titanium.Media.AUDIO_STATE_BUFFERING) instead. */ readonly STATE_BUFFERING: number; /** * Audio playback is being initialized. * @deprecated Use [Titanium.Media.AUDIO_STATE_INITIALIZED](Titanium.Media.AUDIO_STATE_INITIALIZED) instead. */ readonly STATE_INITIALIZED: number; /** * Playback is paused. * @deprecated Use [Titanium.Media.AUDIO_STATE_PAUSED](Titanium.Media.AUDIO_STATE_PAUSED) instead. */ readonly STATE_PAUSED: number; /** * Audio playback is active. * @deprecated Use [Titanium.Media.AUDIO_STATE_PLAYING](Titanium.Media.AUDIO_STATE_PLAYING) instead. */ readonly STATE_PLAYING: number; /** * Audio playback is starting. * @deprecated Use [Titanium.Media.AUDIO_STATE_STARTING](Titanium.Media.AUDIO_STATE_STARTING) instead. */ readonly STATE_STARTING: number; /** * Audio playback is stopped. * @deprecated Use [Titanium.Media.AUDIO_STATE_STOPPED](Titanium.Media.AUDIO_STATE_STOPPED) instead. */ readonly STATE_STOPPED: number; /** * Audio playback is stopping. * @deprecated Use [Titanium.Media.AUDIO_STATE_STOPPING](Titanium.Media.AUDIO_STATE_STOPPING) instead. */ readonly STATE_STOPPING: number; /** * Player is waiting for audio data from the network. * @deprecated Use [Titanium.Media.AUDIO_STATE_WAITING_FOR_DATA](Titanium.Media.AUDIO_STATE_WAITING_FOR_DATA) instead. */ readonly STATE_WAITING_FOR_DATA: number; /** * Player is waiting for audio data to fill the queue. * @deprecated Use [Titanium.Media.AUDIO_STATE_WAITING_FOR_QUEUE](Titanium.Media.AUDIO_STATE_WAITING_FOR_QUEUE) instead. */ readonly STATE_WAITING_FOR_QUEUE: number; /** * Boolean to indicate if audio should continue playing even if the associated * Android [Activity](Titanium.Android.Activity) is paused. */ allowBackground: boolean; /** * Indicates whether the player allows switching to "external playback" mode. */ allowsExternalPlayback: boolean; /** * Focuses on the current audio player and stops other audio playing. */ audioFocus: boolean; /** * Returns the audio session id. */ readonly audioSessionId: number; /** * Changes the audio-stream-type. */ audioType: number; /** * Bit rate of the current playback stream. */ bitRate: number; /** * Size of the buffer used for streaming, in milliseconds. */ bufferSize: number; /** * Estimated duration in milliseconds of the file being played. */ readonly duration: number; /** * Indicates whether the player is currently playing video in "external playback" mode. */ readonly externalPlaybackActive: boolean; /** * Boolean indicating if the player is idle. */ readonly idle: boolean; /** * Indicates whether or not audio output of the player is muted. */ muted: boolean; /** * Boolean indicating if audio playback is paused. */ paused: boolean; /** * Boolean indicating if audio is currently playing. */ readonly playing: boolean; /** * Current playback progress, in milliseconds. */ readonly progress: number; /** * Indicates the desired rate of playback; 0.0 means "paused", 1.0 indicates a * desire to play at the natural rate of the current item. In addition, 2.0 * would mean that the audio plays twice as fast. */ rate: number; /** * Current state of playback, specified using one of the `STATE` constants defined on this object. */ readonly state: number; /** * Current playback position of the audio. */ time: number; /** * URL for the audio stream. */ url: string; /** * Volume of the audio, from 0.0 (muted) to 1.0 (loudest). */ volume: number; /** * Boolean indicating if the playback is waiting for audio data from the network. */ readonly waiting: boolean; /** * Adds the specified callback as an event listener for the named event. */ addEventListener(name: K, callback: (this: Titanium.Media.AudioPlayer, event: AudioPlayerEventMap[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?: AudioPlayerEventMap[K]): void; /** * Fires a synthesized event to any registered listeners. */ fireEvent(name: string, event?: any): void; /** * Returns the audio session id. * @deprecated Use the [audioSessionId](Titanium.Media.AudioPlayer.audioSessionId) property instead */ getAudioSessionId(): number; /** * Returns the value of the [paused](Titanium.Media.AudioPlayer.paused) property. * @deprecated Use the cross-platform API property instead. */ getPaused: never; /** * Returns the value of the [playing](Titanium.Media.AudioPlayer.playing) property. * @deprecated Use the cross-platform API property instead. */ getPlaying: never; /** * Returns the value of the [paused](Titanium.Media.AudioPlayer.paused) property. * @deprecated Use the cross-platform API property instead. */ isPaused: never; /** * Returns the value of the [playing](Titanium.Media.AudioPlayer.playing) property. * @deprecated Use the cross-platform API property instead. */ isPlaying: never; /** * Pauses audio playback. */ pause(): void; /** * Starts or resumes audio playback. * @deprecated Use the cross-platform API [Titanium.Media.AudioPlayer.start](Titanium.Media.AudioPlayer.start) instead. */ play(): void; /** * Stops buffering audio data and releases audio resources. */ release(): void; /** * Removes the specified callback as an event listener for the named event. */ removeEventListener(name: K, callback: (this: Titanium.Media.AudioPlayer, event: AudioPlayerEventMap[K]) => void): void; /** * Removes the specified callback as an event listener for the named event. */ removeEventListener(name: string, callback: (param0: Titanium.Event) => void): void; /** * Restarts (stops and stars) audio playback. */ restart(): void; /** * Moves the playback cursor and invokes the specified block when the seek * operation has either been completed or been interrupted. */ seekToTime(time: number): void; /** * Sets the value of the [paused](Titanium.Media.AudioPlayer.paused) property. * @deprecated Use the cross-platform API [Titanium.Media.AudioPlayer.pause](Titanium.Media.AudioPlayer.pause) instead. */ setPaused: never; /** * Starts or resumes audio playback. */ start(): void; /** * Converts a [state](Titanium.Media.AudioPlayer.state) value into a text description * suitable for display. */ stateDescription(state: number): string; /** * Stops audio playback. */ stop(): void; } } } /** * An abstract type to represent a metadata item inside the `metadata` event (iOS only). */ interface TiMetadataItemType { /** * A dictionary of the additional attributes. */ extraAttributes?: any; /** * The key of the metadata item, e.g. "title". */ key?: string; /** * The key-path of the metadata item. */ keySpace?: string; /** * The value of the metadata item. Can be represented as various types. */ value?: string | number | boolean; }