Titanium.Media

submodule of Titanium
           
0.1

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 Description
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.

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.

Titanium.Media.MusicPlayer

The MusicPlayer instance returned from Titanium.Media.createMusicPlayer. This object represents a music controller.

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 Description
addEventListener add an event listener for the instance to receive view triggered events
beep

play a device beep notification

createAudioPlayer create and return an instance of Titanium.Media.AudioPlayer
createAudioRecorder create and return an instance of Titanium.Media.AudioRecorder
createItem create and return an instance of Titanium.Media.Item
createMusicPlayer create and return an instance of Titanium.Media.MusicPlayer
createSound create and return an instance of Titanium.Media.Sound
createVideoPlayer create and return an instance of Titanium.Media.VideoPlayer
fireEvent fire a synthesized event to the views listener
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.

hideMusicLibrary

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

isMediaTypeSupported

return boolean to indicate if the media type is supported

openPhotoGallery

open the photo gallery picker

removeEventListener remove a previously added event listener
saveToPhotoGallery

save media to photo gallery / camera roll

showCamera

show the camera

showMusicLibrary

show the music library. iPhone and iPad only.

startMicrophoneMonitor

start the monitoring of microphone sound level

stopMicrophoneMonitor

stop the monitoring of microphone sound level

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 Description
AUDIO_FILEFORMAT_3GP2 int

audio file format 3GPP-2

AUDIO_FILEFORMAT_3GPP int

audio file format 3GPP

AUDIO_FILEFORMAT_AIFF int

audio file format AIFF

AUDIO_FILEFORMAT_AMR int

audio file format AMR

AUDIO_FILEFORMAT_CAF int

audio file format Apple Compressed Audio Format (CAF)

AUDIO_FILEFORMAT_MP3 int

audio file format MP3

AUDIO_FILEFORMAT_MP4 int

audio file format MP4

AUDIO_FILEFORMAT_MP4A int

audio file format MP4A

AUDIO_FILEFORMAT_WAVE int

audio file format WAVE

AUDIO_FORMAT_AAC int

audio format MPEG4 AAC encoding

AUDIO_FORMAT_ALAW int

audio format 8-bit aLaw encoding

AUDIO_FORMAT_APPLE_LOSSLESS int

audio format apple lossless encoding

AUDIO_FORMAT_ILBC int

audio format iLBC encoding

AUDIO_FORMAT_IMA4 int

audio format Apple IMA4 encoding

AUDIO_FORMAT_LINEAR_PCM int

audio format Linear 16-bit, PCM encoding

AUDIO_FORMAT_ULAW int

audio format 8-bit muLaw encoding

AUDIO_HEADPHONES int

constant for line type headphones

AUDIO_HEADPHONES_AND_MIC int

constant line type headphones and microphone

AUDIO_HEADSET_INOUT int

constant line type headset in/out

AUDIO_LINEOUT int

constant line type line out

AUDIO_MICROPHONE int

constant line type microphone

AUDIO_MUTED int

constant line type muted switch is on

AUDIO_RECEIVER_AND_MIC int

constant line type receiver and microphone

AUDIO_SESSION_MODE_AMBIENT int

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.

AUDIO_SESSION_MODE_PLAYBACK int

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

AUDIO_SESSION_MODE_PLAY_AND_RECORD int

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.

AUDIO_SESSION_MODE_RECORD int

For recording audio; it silences playback audio.

AUDIO_SESSION_MODE_SOLO_AMBIENT int

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.

AUDIO_SPEAKER int

constant line type speaker

AUDIO_UNAVAILABLE int

constant line type unavailable

AUDIO_UNKNOWN int

constant line type unknown or not determined

DEVICE_BUSY int

constant for media device busy error

MEDIA_TYPE_PHOTO int

media type constant to signify photo

MEDIA_TYPE_VIDEO int

media type constant to signify video

MUSIC_MEDIA_TYPE_ALL int

media containing any content

MUSIC_MEDIA_TYPE_ANY_AUDIO int

media containing any audio content

MUSIC_MEDIA_TYPE_AUDIOBOOK int

media containing audiobook content

MUSIC_MEDIA_TYPE_MUSIC int

media containing music content

MUSIC_MEDIA_TYPE_PODCAST int

media containing podcast content

MUSIC_PLAYER_REPEAT_ALL int

constant for repeating all setting

MUSIC_PLAYER_REPEAT_DEFAULT int

constant for user default repeat setting

MUSIC_PLAYER_REPEAT_NONE int

constant for no repeat setting

MUSIC_PLAYER_REPEAT_ONE int

constant for repeating one item setting

MUSIC_PLAYER_SHUFFLE_ALBUMS int

constant for shuffling complete albums setting

MUSIC_PLAYER_SHUFFLE_DEFAULT int

constant for user default shuffle setting

MUSIC_PLAYER_SHUFFLE_NONE int

constant for no shuffle setting

MUSIC_PLAYER_SHUFFLE_SONGS int

constant for shuffling songs setting

MUSIC_PLAYER_STATE_INTERRUPTED int

constant for interrupted state

MUSIC_PLAYER_STATE_PAUSED int

constant for paused state

MUSIC_PLAYER_STATE_PLAYING int

constant for playing state

MUSIC_PLAYER_STATE_SEEK_BACKWARD int

constant for backward seek state

MUSIC_PLAYER_STATE_SKEEK_FORWARD int

constant for forward seek state

MUSIC_PLAYER_STATE_STOPPED int

constant for stopped state

NO_CAMERA int

constant for media no camera error

NO_VIDEO int

constant for media no video error

QUALITY_HIGH int

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.

QUALITY_LOW int

media type constant to use use low-quality video recording. Recorded files can usually be transferred over the cellular network.

QUALITY_MEDIUM int

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.

UNKNOWN_ERROR int

constant for unknown media error

VIDEO_CONTROL_DEFAULT int

constant for video controls default

VIDEO_CONTROL_EMBEDDED int

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

VIDEO_CONTROL_FULLSCREEN int

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

VIDEO_CONTROL_HIDDEN int

constant for video controls hidden

VIDEO_CONTROL_NONE int

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

VIDEO_CONTROL_VOLUME_ONLY int

constant for video controls volume only

VIDEO_FINISH_REASON_PLAYBACK_ENDED int

the video playback ended normally

VIDEO_FINISH_REASON_PLAYBACK_ERROR int

the video playback ended abnormally

VIDEO_FINISH_REASON_USER_EXITED int

the video playback ended by user action (such as clicking the Done button)

VIDEO_LOAD_STATE_PLAYABLE int

the current media is playable

VIDEO_LOAD_STATE_PLAYTHROUGH_OK int

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

VIDEO_LOAD_STATE_STALLED int

playback will be automatically paused in this state, if started

VIDEO_LOAD_STATE_UNKNOWN int

the current load state is not known

VIDEO_MEDIA_TYPE_AUDIO int

A audio type of media in the movie returned by Titanium.Media.VideoPlayer mediaTypes property

VIDEO_MEDIA_TYPE_NONE int

An unknown type of media in the movie returned by Titanium.Media.VideoPlayer mediaTypes property.

VIDEO_MEDIA_TYPE_VIDEO int

A video type of media in the movie returned by Titanium.Media.VideoPlayer mediaTypes property

VIDEO_PLAYBACK_STATE_INTERRUPTED int

playback has been interrupted

VIDEO_PLAYBACK_STATE_PAUSED int

playback is paused

VIDEO_PLAYBACK_STATE_PLAYING int

playback is playing

VIDEO_PLAYBACK_STATE_SEEKING_BACKWARD int

playback is rewinding

VIDEO_PLAYBACK_STATE_SEEKING_FORWARD int

playback is seeking forward

VIDEO_PLAYBACK_STATE_STOPPED int

playback has stopped

VIDEO_REPEAT_MODE_NONE int

the video will not repeat

VIDEO_REPEAT_MODE_ONE int

the video will repeat once

VIDEO_SCALING_ASPECT_FILL int

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.

VIDEO_SCALING_ASPECT_FIT int

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.

VIDEO_SCALING_MODE_FILL int

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.

VIDEO_SCALING_NONE int

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

VIDEO_SOURCE_TYPE_FILE int

the video source type is a file. Related to the sourceType property of Titanium.Media.VideoPlayer

VIDEO_SOURCE_TYPE_STREAMING int

the video source type is a remote stream. Related to the sourceType property of Titanium.Media.VideoPlayer

VIDEO_SOURCE_TYPE_UNKNOWN int

the video source type is unknown. Related to the sourceType property of Titanium.Media.VideoPlayer

VIDEO_TIME_OPTION_EXACT int

use the exact time

VIDEO_TIME_OPTION_NEAREST_KEYFRAME int

use the closest keyframe in the time

appMusicPlayer object

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

audioLineType int

returns the line type constant for the current line type

audioPlaying boolean

returns true if the device is playing audio

availableCameraMediaTypes array

return an array of media type constants supported for the camera

availablePhotoGalleryMediaTypes array

return an array of media type constants supported for saving to the photo gallery

availablePhotoMediaTypes array

return an array of media type constants supported for the photo

averageMicrophonePower float

return the current average microphone level in dB or -1 if microphone monitoring is disabled

canRecord boolean

returns true if the device has recording input device available

defaultAudioSessionMode int

a constant for the default audio session mode to be used. One of Titanium.Media.AUDIO_SESSION_MODE_AMBIENT, Titanium.Media.AUDIO_SESSION_MODE_SOLO_AMBIENT Titanium.Media.AUDIO_SESSION_MODE_PLAYBACK Titanium.Media.AUDIO_SESSION_MODE_RECORD, Titanium.Media.AUDIO_SESSION_MODE_PLAY_AND_RECORD.

isCameraSupported boolean

returns true if the device has camera support

peakMicrophonePower float

return the current microphone level peak power in dB or -1 if microphone monitoring is disabled

systemMusicPlayer object

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

volume float

the current volume of the playback device

Events

Name Description
linechange

fired when a audio line type change is detected

Event properties

sourcethe source object that fired the event
typethe name of the event fired
recordinginput

fired when availablity of recording input changes

Event properties

available

bool indicating availability of recording device

sourcethe source object that fired the event
typethe name of the event fired
volume

fired when the volume output changes

Event properties

sourcethe source object that fired the event
typethe name of the event fired
volume

float of the new volume in dB