Titanium.Media

Submodule of Titanium.
Platform Since
Android 0.1
iPhone 0.1
iPad 0.1

Summary

The top level Media module. The Media module is used accessing the device's media related functionality such as playing audio or recording video.

Objects

Name Summary
Titanium.Media.AudioPlayer

The AudioPlayer object is returned by Titanium.Media.createAudioPlayer and is used for streaming audio to the device and low-level control of the audio playback.

Titanium.Media.AudioRecorder

The AudioRecorder object is returned by Titanium.Media.createAudioRecorder and is used for recording audio from the device microphone. (iPhone, iPad only.)

Titanium.Media.Item

A representation of a media item returned by the music picker as part of the items array in the dictionary passed to its success function. (iPhone, iPad only.)

Titanium.Media.MusicPlayer

The MusicPlayer instance returned from Titanium.Media.createMusicPlayer. This object represents a music controller. (iPhone, iPad only.)

Titanium.Media.Sound

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.

Titanium.Media.VideoPlayer

The VideoPlayer object is returned by Titanium.Media.createVideoPlayer and is useful for playing videos.

Methods

Name Summary
addEventListener

Adds the specified callback as an event listener for the named event.

beep

play a device beep notification (iPhone, iPad only.)

createAudioPlayer

Create and return an instance of Titanium.Media.AudioPlayer.

createAudioRecorder

Create and return an instance of Titanium.Media.AudioRecorder. (iPhone, iPad only.)

createItem

Create and return an instance of Titanium.Media.Item. (iPhone, iPad only.)

createMusicPlayer

Create and return an instance of Titanium.Media.MusicPlayer. (iPhone, iPad only.)

createSound

Create and return an instance of Titanium.Media.Sound.

createVideoPlayer

Create and return an instance of Titanium.Media.VideoPlayer.

fireEvent

Fires a synthesized event to any registered listeners.

hideCamera

hide the device camera UI. this must be called after calling showCamera and only when autohide is set to false. this method will cause the media capture device be hidden. (iPhone, iPad only.)

hideMusicLibrary

hide the music library. This must be called after calling showMusicLibrary and only when autohide is set to false. (iPhone, iPad only.)

isMediaTypeSupported

return boolean to indicate if the media type is supported (iPhone, iPad only.)

openPhotoGallery

open the photo gallery picker

queryMusicLibrary

run a search for music library items matching the specified search predicates. (iPhone, iPad only.)

removeEventListener

Removes the specified callback as an event listener for the named event.

saveToPhotoGallery

save media to photo gallery / camera roll

showCamera

show the camera

showMusicLibrary

show the music library. (iPhone, iPad only.)

startMicrophoneMonitor

start the monitoring of microphone sound level (iPhone, iPad only.)

stopMicrophoneMonitor

stop the monitoring of microphone sound level (iPhone, iPad only.)

takePicture

use the device camera to capture a photo. this must be called after calling showCamera and only when autohide is set to false. this method will cause the media capture device to capture a photo and call the success callback.

takeScreenshot

take a screen shot of the visible UI on the device

vibrate

play a device vibration

Properties

Name Type Summary
AUDIO_FILEFORMAT_3GP2 Number

audio file format 3GPP-2 (iPhone, iPad only.) read-only

AUDIO_FILEFORMAT_3GPP Number

audio file format 3GPP (iPhone, iPad only.) read-only

AUDIO_FILEFORMAT_AIFF Number

audio file format AIFF (iPhone, iPad only.) read-only

AUDIO_FILEFORMAT_AMR Number

audio file format AMR (iPhone, iPad only.) read-only

AUDIO_FILEFORMAT_CAF Number

audio file format Apple Compressed Audio Format (CAF) (iPhone, iPad only.) read-only

AUDIO_FILEFORMAT_MP3 Number

audio file format MP3 (iPhone, iPad only.) read-only

AUDIO_FILEFORMAT_MP4 Number

audio file format MP4 (iPhone, iPad only.) read-only

AUDIO_FILEFORMAT_MP4A Number

audio file format MP4A (iPhone, iPad only.) read-only

AUDIO_FILEFORMAT_WAVE Number

audio file format WAVE (iPhone, iPad only.) read-only

AUDIO_FORMAT_AAC Number

audio format MPEG4 AAC encoding (iPhone, iPad only.) read-only

AUDIO_FORMAT_ALAW Number

audio format 8-bit aLaw encoding (iPhone, iPad only.) read-only

AUDIO_FORMAT_APPLE_LOSSLESS Number

audio format apple lossless encoding (iPhone, iPad only.) read-only

AUDIO_FORMAT_ILBC Number

audio format iLBC encoding (iPhone, iPad only.) read-only

AUDIO_FORMAT_IMA4 Number

audio format Apple IMA4 encoding (iPhone, iPad only.) read-only

AUDIO_FORMAT_LINEAR_PCM Number

audio format Linear 16-bit, PCM encoding (iPhone, iPad only.) read-only

AUDIO_FORMAT_ULAW Number

audio format 8-bit muLaw encoding (iPhone, iPad only.) read-only

AUDIO_HEADPHONES Number

constant for line type headphones (iPhone, iPad only.) read-only

AUDIO_HEADPHONES_AND_MIC Number

constant line type headphones and microphone (iPhone, iPad only.) read-only

AUDIO_HEADSET_INOUT Number

constant line type headset in/out (iPhone, iPad only.) read-only

AUDIO_LINEOUT Number

constant line type line out (iPhone, iPad only.) read-only

AUDIO_MICROPHONE Number

constant line type microphone (iPhone, iPad only.) read-only

AUDIO_MUTED Number

constant line type muted switch is on (iPhone, iPad only.) read-only

AUDIO_RECEIVER_AND_MIC Number

constant line type receiver and microphone (iPhone, iPad only.) read-only

AUDIO_SESSION_MODE_AMBIENT Number

For long-duration sounds such as rain, car engine noise, and so on. It is also for 'play along' style applications, such a virtual piano that a user plays over iPod audio. (iPhone, iPad only.) read-only

AUDIO_SESSION_MODE_PLAYBACK Number

For playing recorded music or other sounds that are central to the successful use of your application. When using this mode, your application audio continues with the Ring/Silent switch set to silent or when the screen locks. This property normally disallows iPod audio to mix with application audio (iPhone, iPad only.) read-only

AUDIO_SESSION_MODE_PLAY_AND_RECORD Number

Allows recording (input) and playback (output) of audio, such as for a VOIP (voice over IP) application. This category is appropriate for simultaneous recording and playback, and also for applications that record and play back but not simultaneously. If you want to ensure that sounds such as Messages alerts do not play while your application is recording, use Titanium.Media.AUDIO_SESSION_MODE_RECORD instead. This category normally disallows iPod audio to mix with application audio. (iPhone, iPad only.) read-only

AUDIO_SESSION_MODE_RECORD Number

For recording audio; it silences playback audio. (iPhone, iPad only.) read-only

AUDIO_SESSION_MODE_SOLO_AMBIENT Number

The solo ambient sound category is for long-duration sounds such as rain, car engine noise, and so on. When you use this category, audio from built-in applications, such as the iPod, is silenced. Your audio is silenced when the Ring/Silent switch is set to silent or when the screen locks. (iPhone, iPad only.) read-only

AUDIO_SPEAKER Number

constant line type speaker (iPhone, iPad only.) read-only

AUDIO_UNAVAILABLE Number

constant line type unavailable (iPhone, iPad only.) read-only

AUDIO_UNKNOWN Number

constant line type unknown or not determined (iPhone, iPad only.) read-only

DEVICE_BUSY Number

constant for media device busy error read-only

MEDIA_TYPE_PHOTO Number

media type constant to signify photo read-only

MEDIA_TYPE_VIDEO Number

media type constant to signify video read-only

MUSIC_MEDIA_GROUP_ALBUM Number

The constant for grouping query results by album (iPhone, iPad only.) read-only

MUSIC_MEDIA_GROUP_ALBUM_ARTIST Number

The constant for grouping query results by album artist (iPhone, iPad only.) read-only

MUSIC_MEDIA_GROUP_ARTIST Number

The constant for grouping query results by artist (iPhone, iPad only.) read-only

MUSIC_MEDIA_GROUP_COMPOSER Number

The constant for grouping query results by composer (iPhone, iPad only.) read-only

MUSIC_MEDIA_GROUP_GENRE Number

The constant for grouping query results by genre (iPhone, iPad only.) read-only

MUSIC_MEDIA_GROUP_PLAYLIST Number

The constant for grouping query results by playlist (iPhone, iPad only.) read-only

MUSIC_MEDIA_GROUP_PODCAST_TITLE Number

The constant for grouping query results by podcast title (iPhone, iPad only.) read-only

MUSIC_MEDIA_GROUP_TITLE Number

The constant for grouping query results by title (iPhone, iPad only.) read-only

MUSIC_MEDIA_TYPE_ALL Number

media containing any content (iPhone, iPad only.) read-only

MUSIC_MEDIA_TYPE_ANY_AUDIO Number

media containing any audio content (iPhone, iPad only.) read-only

MUSIC_MEDIA_TYPE_AUDIOBOOK Number

media containing audiobook content (iPhone, iPad only.) read-only

MUSIC_MEDIA_TYPE_MUSIC Number

media containing music content (iPhone, iPad only.) read-only

MUSIC_MEDIA_TYPE_PODCAST Number

media containing podcast content (iPhone, iPad only.) read-only

MUSIC_PLAYER_REPEAT_ALL Number

constant for repeating all setting (iPhone, iPad only.) read-only

MUSIC_PLAYER_REPEAT_DEFAULT Number

constant for user default repeat setting (iPhone, iPad only.) read-only

MUSIC_PLAYER_REPEAT_NONE Number

constant for no repeat setting (iPhone, iPad only.) read-only

MUSIC_PLAYER_REPEAT_ONE Number

constant for repeating one item setting (iPhone, iPad only.) read-only

MUSIC_PLAYER_SHUFFLE_ALBUMS Number

constant for shuffling complete albums setting (iPhone, iPad only.) read-only

MUSIC_PLAYER_SHUFFLE_DEFAULT Number

constant for user default shuffle setting (iPhone, iPad only.) read-only

MUSIC_PLAYER_SHUFFLE_NONE Number

constant for no shuffle setting (iPhone, iPad only.) read-only

MUSIC_PLAYER_SHUFFLE_SONGS Number

constant for shuffling songs setting (iPhone, iPad only.) read-only

MUSIC_PLAYER_STATE_INTERRUPTED Number

constant for interrupted state (iPhone, iPad only.) read-only

MUSIC_PLAYER_STATE_PAUSED Number

constant for paused state (iPhone, iPad only.) read-only

MUSIC_PLAYER_STATE_PLAYING Number

constant for playing state (iPhone, iPad only.) read-only

MUSIC_PLAYER_STATE_SEEK_BACKWARD Number

constant for backward seek state (iPhone, iPad only.) read-only

MUSIC_PLAYER_STATE_SKEEK_FORWARD Number

constant for forward seek state (iPhone, iPad only.) read-only

MUSIC_PLAYER_STATE_STOPPED Number

constant for stopped state (iPhone, iPad only.) read-only

NO_CAMERA Number

constant for media no camera error read-only

NO_VIDEO Number

constant for media no video error read-only

QUALITY_HIGH Number

media type constant to use high-quality video recording. Recorded files are suitable for on-device playback and for wired transfer to the Desktop using Image Capture; they are likely to be too large for transfer using Wi-Fi. (iPhone, iPad only.) read-only

QUALITY_LOW Number

media type constant to use use low-quality video recording. Recorded files can usually be transferred over the cellular network. (iPhone, iPad only.) read-only

QUALITY_MEDIUM Number

media type constant to use medium-quality video recording. Recorded files can usually be transferred using Wi-Fi. This is the default video quality setting. (iPhone, iPad only.) read-only

UNKNOWN_ERROR Number

constant for unknown media error read-only

VIDEO_CONTROL_DEFAULT Number

constant for video controls default read-only

VIDEO_CONTROL_EMBEDDED Number

Controls for an embedded view. Used in conjunction with movieControlStyle property of Titanium.Media.VideoPlayer in iPhone 3.2+ read-only

VIDEO_CONTROL_FULLSCREEN Number

Controls for fullscreen. Used in conjunction with movieControlStyle property of Titanium.Media.VideoPlayer in iPhone 3.2+ read-only

VIDEO_CONTROL_HIDDEN Number

constant for video controls hidden read-only

VIDEO_CONTROL_NONE Number

No controls. Used in conjunction with movieControlStyle property of Titanium.Media.VideoPlayer in iPhone 3.2+ read-only

VIDEO_CONTROL_VOLUME_ONLY Number

Deprecated constant for video controls volume only (iPhone, iPad only.) read-only

VIDEO_FINISH_REASON_PLAYBACK_ENDED Number

the video playback ended normally (iPhone, iPad only.) read-only

VIDEO_FINISH_REASON_PLAYBACK_ERROR Number

the video playback ended abnormally (iPhone, iPad only.) read-only

VIDEO_FINISH_REASON_USER_EXITED Number

the video playback ended by user action (such as clicking the Done button) (iPhone, iPad only.) read-only

VIDEO_LOAD_STATE_PLAYABLE Number

the current media is playable read-only

VIDEO_LOAD_STATE_PLAYTHROUGH_OK Number

playback will be automatically started in this state when autoplay is true read-only

VIDEO_LOAD_STATE_STALLED Number

playback will be automatically paused in this state, if started read-only

VIDEO_LOAD_STATE_UNKNOWN Number

the current load state is not known read-only

VIDEO_MEDIA_TYPE_AUDIO Number

A audio type of media in the movie returned by Titanium.Media.VideoPlayer mediaTypes property (iPhone, iPad only.) read-only

VIDEO_MEDIA_TYPE_NONE Number

An unknown type of media in the movie returned by Titanium.Media.VideoPlayer mediaTypes property. (iPhone, iPad only.) read-only

VIDEO_MEDIA_TYPE_VIDEO Number

A video type of media in the movie returned by Titanium.Media.VideoPlayer mediaTypes property (iPhone, iPad only.) read-only

VIDEO_PLAYBACK_STATE_INTERRUPTED Number

playback has been interrupted (iPhone, iPad only.) read-only

VIDEO_PLAYBACK_STATE_PAUSED Number

playback is paused read-only

VIDEO_PLAYBACK_STATE_PLAYING Number

playback is playing read-only

VIDEO_PLAYBACK_STATE_SEEKING_BACKWARD Number

playback is rewinding (iPhone, iPad only.) read-only

VIDEO_PLAYBACK_STATE_SEEKING_FORWARD Number

playback is seeking forward (iPhone, iPad only.) read-only

VIDEO_PLAYBACK_STATE_STOPPED Number

playback has stopped read-only

VIDEO_REPEAT_MODE_NONE Number

constant for repeating no videos (IE, the one video will NOT repeat) during playback read-only

VIDEO_REPEAT_MODE_ONE Number

constant for repeating one video (IE, the one video will repeat constantly) during playback read-only

VIDEO_SCALING_ASPECT_FILL Number

constant for video aspect where the movie will be scaled until the movie fills the entire screen. Content at the edges of the larger of the two dimensions is clipped so that the other dimension fits the screen exactly. The aspect ratio of the movie is preserved. read-only

VIDEO_SCALING_ASPECT_FIT Number

constant for video aspect fit where the movie will be scaled until one dimension fits on the screen exactly. In the other dimension, the region between the edge of the movie and the edge of the screen is filled with a black bar. The aspect ratio of the movie is preserved. read-only

VIDEO_SCALING_MODE_FILL Number

constant for video aspect where the movie will be scaled until both dimensions fit the screen exactly. The aspect ratio of the movie is not preserved. read-only

VIDEO_SCALING_NONE Number

constant for video scaling where the scaling is turn off. The movie will not be scaled. read-only

VIDEO_SOURCE_TYPE_FILE Number

the video source type is a file. Related to the sourceType property of Titanium.Media.VideoPlayer (iPhone, iPad only.) read-only

VIDEO_SOURCE_TYPE_STREAMING Number

the video source type is a remote stream. Related to the sourceType property of Titanium.Media.VideoPlayer (iPhone, iPad only.) read-only

VIDEO_SOURCE_TYPE_UNKNOWN Number

the video source type is unknown. Related to the sourceType property of Titanium.Media.VideoPlayer (iPhone, iPad only.) read-only

VIDEO_TIME_OPTION_EXACT Number

use the exact time (iPhone, iPad only.) read-only

VIDEO_TIME_OPTION_NEAREST_KEYFRAME Number

use the closest keyframe in the time (iPhone, iPad only.) read-only

appMusicPlayer Object

an instance of Titanium.Media.MusicPlayer representing the app-specific music player. (iPhone, iPad only.)

audioLineType Number

returns the line type constant for the current line type (iPhone, iPad only.)

audioPlaying Boolean

returns true if the device is playing audio (iPhone, iPad only.)

audioSessionMode Number

a constant for the audio session mode to be used. Must be set while the audio session is inactive (no sounds are playing, no listeners for audio properties on the Media module, but the iPod may be active). (iPhone, iPad only.)

availableCameraMediaTypes Array<Object>

return an array of media type constants supported for the camera (iPhone, iPad only.)

availablePhotoGalleryMediaTypes Array<Object>

return an array of media type constants supported for saving to the photo gallery (iPhone, iPad only.)

availablePhotoMediaTypes Array<Object>

return an array of media type constants supported for the photo (iPhone, iPad only.)

averageMicrophonePower Number

return the current average microphone level in dB or -1 if microphone monitoring is disabled (iPhone, iPad only.)

canRecord Boolean

returns true if the device has recording input device available (iPhone, iPad only.)

isCameraSupported Boolean

returns true if the device has camera support (iPhone, iPad only.)

peakMicrophonePower Number

return the current microphone level peak power in dB or -1 if microphone monitoring is disabled (iPhone, iPad only.)

systemMusicPlayer Object

an instance of Titanium.Media.MusicPlayer representing the system-wide music player. (iPhone, iPad only.)

volume Number

the current volume of the playback device (iPhone, iPad only.)

Events

Name Summary
linechange

fired when a audio line type change is detected

recordinginput

fired when availablity of recording input changes

volume

fired when the volume output changes