# Titanium.Media

> The top-level Media module.

- Source: https://titaniumsdk.com/docs/sdk/12.6.2/Titanium.Media
- Titanium SDK version: 12.6.2
- Kind: module
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 0.1
- Extends: Titanium.Module
- Inheritance: Titanium.Module > Titanium.Proxy

The Media module is used to access the device's media-related functionality, such
as using the device's camera and photo gallery, playing media files, or recording
audio or video.
For examples of using the Media APIs, refer to the
[Working with Media APIs guide](https://titaniumsdk.com/guide/Titanium_SDK/Titanium_SDK_How-tos/Working_with_Media_APIs/)
in addition to the other media submodule API documentation.
**Note**: Some third party Android camera apps may choose to ignore video recording quality
settings. If you wish to specifically set the video quality, don't assume
`EXTRA_VIDEO_QUALITY` intent will be respected by the camera app and use Titanium's built-in
camera window which can be used to assign the `overlay` property when calling the
`showCamera()` method.

## Properties

### appMusicPlayer

- Type: Titanium.Media.MusicPlayer
- Platforms: iPhone, iPad, macOS
- Permission: read-only

An instance of [Titanium.Media.MusicPlayer](https://titaniumsdk.com/docs/sdk/Titanium.Media.MusicPlayer.md) representing the app-specific music player.

### ASPECT_RATIO_16_9

- Type: Number
- Platforms: Android
- Since: Titanium SDK 12.2.0
- Permission: read-only

Aspect ratio 16:9

### ASPECT_RATIO_4_3

- Type: Number
- Platforms: Android
- Since: Titanium SDK 12.2.0
- Permission: read-only

Aspect ratio 4:3

### aspectRatio

- Type: Number
- Platforms: Android
- Since: Titanium SDK 12.2.0
- Permission: read-only
- Default: `Titanium.Media.ASPECT_RATIO_4_3`

Aspect ratio of the image.

Accepts: `Titanium.Media.ASPECT_RATIO_16_9`, `Titanium.Media.ASPECT_RATIO_4_3`

### AUDIO_FILEFORMAT_3GP2

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Audio file format 3GPP2.

### AUDIO_FILEFORMAT_3GPP

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Audio file format 3GPP.

### AUDIO_FILEFORMAT_AIFF

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Audio file format Audio Interchange File Format (AIFF).

### AUDIO_FILEFORMAT_AMR

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Audio file format Adaptive Multi-Rate (AMR).

### AUDIO_FILEFORMAT_CAF

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Audio file format Apple Compressed Audio Format (CAF).

### AUDIO_FILEFORMAT_MP3

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Audio file format MP3.

### AUDIO_FILEFORMAT_MP4

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Audio file format MP4.

### AUDIO_FILEFORMAT_MP4A

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Audio file format MP4A.

### AUDIO_FILEFORMAT_WAVE

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Audio file format WAVE.

### AUDIO_FORMAT_AAC

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Audio format MPEG4 AAC encoding.

### AUDIO_FORMAT_ALAW

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Audio format 8-bit [aLaw encoding](https://en.wikipedia.org/wiki/A-law_algorithm).

### AUDIO_FORMAT_APPLE_LOSSLESS

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Audio format Apple lossless encoding.

### AUDIO_FORMAT_ILBC

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Audio format [iLBC encoding](https://en.wikipedia.org/wiki/Internet_Low_Bitrate_Codec).

### AUDIO_FORMAT_IMA4

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Audio format Apple IMA4 encoding.

### AUDIO_FORMAT_LINEAR_PCM

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Audio format 16-bit, [linear PCM encoding](https://en.wikipedia.org/wiki/Pulse-code_modulation).

### AUDIO_FORMAT_ULAW

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Audio format 8-bit [muLaw encoding](https://en.wikipedia.org/wiki/M-law_algorithm).

### AUDIO_SESSION_CATEGORY_AMBIENT

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

For long-duration sounds such as rain, car engine noise, and so on.

Also used for for 'play along' style applications, such a virtual piano that a
user plays over iPod audio.

See also: [AUDIO_SESSION_CATEGORY_SOLO_AMBIENT](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#AUDIO_SESSION_CATEGORY_SOLO_AMBIENT).

### AUDIO_SESSION_CATEGORY_PLAY_AND_RECORD

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Session mode for 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_CATEGORY_RECORD](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#AUDIO_SESSION_CATEGORY_RECORD) instead. This category normally
disallows mixing iPod audio with application audio.

In this mode, by default audio playback is routed to the speaker in the iPhone receiver. To have audio playback through the iPhone speaker, use [Titanium.Media.setOverrideAudioRoute](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#setOverrideAudioRoute).

### AUDIO_SESSION_CATEGORY_PLAYBACK

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Session mode 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 mixing iPod audio
with application audio.

### AUDIO_SESSION_CATEGORY_RECORD

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Session mode for recording audio; it silences playback audio.

### AUDIO_SESSION_CATEGORY_SOLO_AMBIENT

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Session mode 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.

To use long-duration sounds without silencing built-in applications,
see [AUDIO_SESSION_CATEGORY_AMBIENT](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#AUDIO_SESSION_CATEGORY_AMBIENT).

### AUDIO_SESSION_OVERRIDE_ROUTE_NONE

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Constant that specifies audio should output to the default audio route. See [Titanium.Media.setOverrideAudioRoute](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#setOverrideAudioRoute) for more information.

### AUDIO_SESSION_OVERRIDE_ROUTE_SPEAKER

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Constant that specifies audio should output to the speaker. See [Titanium.Media.setOverrideAudioRoute](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#setOverrideAudioRoute) for more information.

### AUDIO_SESSION_PORT_AIRPLAY

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Constant for output on a remote Air Play device. This is an output port.

### AUDIO_SESSION_PORT_BLUETOOTHA2DP

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Constant for output on a Bluetooth A2DP device. This is an output port.

### AUDIO_SESSION_PORT_BLUETOOTHHFP

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Constant for input or output on a Bluetooth Hands-Free Profile device. This can be both an input and output port.

### AUDIO_SESSION_PORT_BLUETOOTHLE

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Constant for output on a Bluetooth Low Energy device. This is an output port. This is available on iOS7 and later.

### AUDIO_SESSION_PORT_BUILTINMIC

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Constant for built-in microphone on an iOS device. This is an input port.

### AUDIO_SESSION_PORT_BUILTINRECEIVER

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Constant for the speaker you hold to your ear when on a phone call. This is an output port.

### AUDIO_SESSION_PORT_BUILTINSPEAKER

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Constant for built-in speaker on an iOS device. This is an output port.

### AUDIO_SESSION_PORT_CARAUDIO

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Constant for Input or output via Car Audio. This can be both an input and output port. This is available on iOS7 and later.

### AUDIO_SESSION_PORT_HDMI

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Constant for output via High-Definition Multimedia Interface. This is an output port

### AUDIO_SESSION_PORT_HEADPHONES

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Constant for headphone or headset output. This is an output port.

### AUDIO_SESSION_PORT_HEADSETMIC

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Constant for microphone on a wired headset. This is an input port.

### AUDIO_SESSION_PORT_LINEIN

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Constant for line level input on a dock connector. This is an input port.

### AUDIO_SESSION_PORT_LINEOUT

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Constant for line level output on a dock connector. This is an output port.

### AUDIO_SESSION_PORT_USBAUDIO

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Constant for input or output on a Universal Serial Bus device. This can be both an input and output port.

### AUDIO_STATE_BUFFERING

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 7.5.0
- Permission: read-only

Audio data is being buffered from the network.

### AUDIO_STATE_INITIALIZED

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 7.5.0
- Permission: read-only

Audio playback is being initialized.

### AUDIO_STATE_PAUSED

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 7.5.0
- Permission: read-only

Playback is paused.

### AUDIO_STATE_PLAYING

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 7.5.0
- Permission: read-only

Audio playback is active.

### AUDIO_STATE_STARTING

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 7.5.0
- Permission: read-only

Audio playback is starting.

### AUDIO_STATE_STOPPED

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 7.5.0
- Permission: read-only

Audio playback is stopped.

### AUDIO_STATE_STOPPING

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 7.5.0
- Permission: read-only

Audio playback is stopping.

### AUDIO_STATE_WAITING_FOR_DATA

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 7.5.0
- Permission: read-only

Player is waiting for audio data from the network.

### audioPlaying

- Type: Boolean
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Returns `true` if the device is playing audio.

### audioSessionCategory

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2

A constant for the audio session category to be used.

Set to one of the `AUDIO_SESSION_CATEGORY` constants defined in [Titanium.Media](https://titaniumsdk.com/docs/sdk/Titanium.Media.md).

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

Accepts: `Titanium.Media.AUDIO_SESSION_CATEGORY_AMBIENT`, `Titanium.Media.AUDIO_SESSION_CATEGORY_PLAYBACK`, `Titanium.Media.AUDIO_SESSION_CATEGORY_PLAY_AND_RECORD`, `Titanium.Media.AUDIO_SESSION_CATEGORY_RECORD`, `Titanium.Media.AUDIO_SESSION_CATEGORY_SOLO_AMBIENT`

### availableCameraMediaTypes

- Type: Array<String>
- Platforms: iPhone, iPad, macOS

Array of media type constants supported for the camera.

Accepts: `Titanium.Media.MEDIA_TYPE_LIVEPHOTO`, `Titanium.Media.MEDIA_TYPE_PHOTO`, `Titanium.Media.MEDIA_TYPE_VIDEO`

### availableCameras

- Type: Array<Number>
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 3.2.0
- Permission: read-only

Array indicating which cameras are available, `CAMERA_FRONT`, `CAMERA_REAR` or both.

Accepts: `Titanium.Media.CAMERA_FRONT`, `Titanium.Media.CAMERA_REAR`

### availablePhotoGalleryMediaTypes

- Type: Array<String>
- Platforms: iPhone, iPad, macOS

Array of media type constants supported for saving to the device's camera roll or saved images album.

Accepts: `Titanium.Media.MEDIA_TYPE_LIVEPHOTO`, `Titanium.Media.MEDIA_TYPE_PHOTO`, `Titanium.Media.MEDIA_TYPE_VIDEO`

### availablePhotoMediaTypes

- Type: Array<String>
- Platforms: iPhone, iPad, macOS

Array of media type constants supported for the photo library.

Accepts: `Titanium.Media.MEDIA_TYPE_LIVEPHOTO`, `Titanium.Media.MEDIA_TYPE_PHOTO`, `Titanium.Media.MEDIA_TYPE_VIDEO`

### averageMicrophonePower

- Type: Number
- Platforms: iPhone, iPad, macOS

Current average microphone level in dB or -1 if microphone monitoring is disabled.

See [startMicrophoneMonitor](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#startMicrophoneMonitor),
[stopMicrophoneMonitor](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#stopMicrophoneMonitor).

### CAMERA_AUTHORIZATION_AUTHORIZED

- Type: Number
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 4.0.0
- Permission: read-only

Constant specifying that app is authorized to use camera. This is available on iOS7 and later.

### CAMERA_AUTHORIZATION_DENIED

- Type: Number
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 4.0.0
- Permission: read-only

Constant specifying that app is denied usage of camera. This is available on iOS7 and later.

### CAMERA_AUTHORIZATION_RESTRICTED

- Type: Number
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 4.0.0
- Permission: read-only

Constant specifying that app is restricted from using camera. This is available on iOS7 and later.

### CAMERA_AUTHORIZATION_UNKNOWN

- Type: Number
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 5.2.0
- Permission: read-only

Constant specifying that app is not yet authorized to use camera. This is available on iOS7 and later.

### CAMERA_FLASH_AUTO

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK Android 3.3.0, iPhone 1.4.0, iPad 1.4.0
- Permission: read-only

Constant specifying to have the device determine to use the flash or not.

### CAMERA_FLASH_OFF

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK Android 3.3.0, iPhone 1.4.0, iPad 1.4.0
- Permission: read-only

Constant specifying to never fire the flash.

### CAMERA_FLASH_ON

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK Android 3.3.0, iPhone 1.4.0, iPad 1.4.0
- Permission: read-only

Constant specifying to always fire the flash.

### CAMERA_FRONT

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 3.2.0
- Permission: read-only

Constant specifying the front camera.

### CAMERA_REAR

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 3.2.0
- Permission: read-only

Constant indicating the rear camera.

### cameraAuthorization

- Type: Number
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 5.2.0
- Permission: read-only

Returns the authorization status for the camera.

Accepts: `Titanium.Media.CAMERA_AUTHORIZATION_AUTHORIZED`, `Titanium.Media.CAMERA_AUTHORIZATION_DENIED`, `Titanium.Media.CAMERA_AUTHORIZATION_RESTRICTED`, `Titanium.Media.CAMERA_AUTHORIZATION_UNKNOWN`

### cameraFlashMode

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK Android 3.3.0, iPhone 1.4.0, iPad 1.4.0
- Default: `<Titanium.Media.CAMERA_FLASH_AUTO> on iOS, <Titanium.Media.CAMERA_FLASH_OFF> on Android`

Determines how the flash is fired when using the device's camera.

Accepts: `Titanium.Media.CAMERA_FLASH_AUTO`, `Titanium.Media.CAMERA_FLASH_OFF`, `Titanium.Media.CAMERA_FLASH_ON`

### cameraOutputSizes

- Type: Object
- Platforms: Android
- Since: Titanium SDK 12.2.0
- Permission: read-only

Returns an object of possible `targetImageWidth` and `targetImageHeight` values. The output
contains a `cameraType` (front or back) and object of width/height values. You have to set
`targetImageWidth` and `targetImageHeight` if you want to change the camera image output size.
Note: depeneding on your phone and camera the values won't be used or can be different.

### canRecord

- Type: Boolean
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 6.2.0
- Permission: read-only

`true` if the device has a recording input device available.

### currentRoute

- Type: RouteDescription
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2
- Permission: read-only

Returns a description of the current route, consisting of zero or more input ports and zero or more output ports.

### DEVICE_BUSY

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

Constant for media device busy error.

### IMAGE_SCALING_ASPECT_FILL

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 10.1.0
- Permission: read-only

Crops the image proportionally causing its content to be clipped either horizontally or vertically.

### IMAGE_SCALING_ASPECT_FIT

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 10.1.0
- Permission: read-only

Letterbox or pillarbox scales the image proportionally to fit the container.

### IMAGE_SCALING_AUTO

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 10.1.0
- Permission: read-only

Scales the image depending on how the view container is sized.

If a [width](https://titaniumsdk.com/docs/sdk/Titanium.UI.View.md#width) and [height](https://titaniumsdk.com/docs/sdk/Titanium.UI.View.md#height) are both conigured on the
image view, then it will use [IMAGE_SCALING_FILL](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#IMAGE_SCALING_FILL)
to stretch the image disproportionally to fill the view. Otherwise it will use
[IMAGE_SCALING_ASPECT_FIT](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#IMAGE_SCALING_ASPECT_FIT) to letterbox/pillarbox the image.

### IMAGE_SCALING_FILL

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 10.1.0
- Permission: read-only

Stretches the image disproportionally to completely fill the container's bounds.

### IMAGE_SCALING_NONE

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 10.1.0
- Permission: read-only

Disables scaling and displays the image as-is.

### isCameraSupported

- Type: Boolean
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

`true` if the device has camera support.

### maxZoomLevel

- Type: Number
- Platforms: Android
- Since: Titanium SDK 12.2.0
- Permission: read-only

Returns the max zoom level of the camera.

### MEDIA_TYPE_LIVEPHOTO

- Type: String
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 5.2.0
- Requires: iOS 9.1+
- Permission: read-only
- Value: `"com.apple.live-photo"`

Media type constant for live photo media.

### MEDIA_TYPE_PHOTO

- Type: String
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only
- Value: `"public.image"`

Media type constant for photo media.

### MEDIA_TYPE_VIDEO

- Type: String
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only
- Value: `"public.movie"`

Media type constant for video media.

### minZoomLevel

- Type: Number
- Platforms: Android
- Since: Titanium SDK 12.2.0
- Permission: read-only

Returns the min zoom level of the camera.

### MUSIC_MEDIA_GROUP_ALBUM

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only
- Value: `1`

Constant for grouping query results by album.

### MUSIC_MEDIA_GROUP_ALBUM_ARTIST

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only
- Value: `3`

Constant for grouping query results by album and artist.

### MUSIC_MEDIA_GROUP_ARTIST

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only
- Value: `2`

Constant for grouping query results by artist.

### MUSIC_MEDIA_GROUP_COMPOSER

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only
- Value: `4`

Constant for grouping query results by composer.

### MUSIC_MEDIA_GROUP_GENRE

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only
- Value: `5`

Constant for grouping query results by genre.

### MUSIC_MEDIA_GROUP_PLAYLIST

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only
- Value: `6`

Constant for grouping query results by playlist.

### MUSIC_MEDIA_GROUP_PODCAST_TITLE

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only
- Value: `7`

Constant for grouping query results by podcast title.

### MUSIC_MEDIA_GROUP_TITLE

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only
- Value: `0`

Constant for grouping query results by title.

### MUSIC_MEDIA_TYPE_ALL

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Music library media containing any type of content.

### MUSIC_MEDIA_TYPE_ANY_AUDIO

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Music library media containing any type of audio content.

### MUSIC_MEDIA_TYPE_AUDIOBOOK

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Music library media containing audiobook content.

### MUSIC_MEDIA_TYPE_MUSIC

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Music library media containing music content.

### MUSIC_MEDIA_TYPE_PODCAST

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Music library media containing podcast content.

### MUSIC_PLAYER_REPEAT_ALL

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Constant for "Repeat All" setting.

### MUSIC_PLAYER_REPEAT_DEFAULT

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Constant for user's default repeat setting.

### MUSIC_PLAYER_REPEAT_NONE

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Constant for "No Repeat" setting.

### MUSIC_PLAYER_REPEAT_ONE

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Constant for "Repeat one item" setting.

### MUSIC_PLAYER_SHUFFLE_ALBUMS

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Constant for shuffling complete albums setting.

### MUSIC_PLAYER_SHUFFLE_DEFAULT

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Constant for user's default shuffle setting.

### MUSIC_PLAYER_SHUFFLE_NONE

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Constant for "no shuffle" setting.

### MUSIC_PLAYER_SHUFFLE_SONGS

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Constant for shuffling songs setting.

### MUSIC_PLAYER_STATE_INTERRUPTED

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Constant for interrupted state.

### MUSIC_PLAYER_STATE_PAUSED

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Constant for paused state.

### MUSIC_PLAYER_STATE_PLAYING

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Constant for playing state.

### MUSIC_PLAYER_STATE_SEEK_BACKWARD

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Constant for backward seek state.

### MUSIC_PLAYER_STATE_SEEK_FORWARD

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Constant for forward seek state.

### MUSIC_PLAYER_STATE_STOPPED

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Constant for stopped state.

### NO_CAMERA

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

Constant for media no camera error.

### NO_FOCUS

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 12.2.1
- Permission: read-only

Constant for camera didn't focus when taking a trying to take a picture.

### NO_VIDEO

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

Constant for media no video error.

### peakMicrophonePower

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Current microphone level peak power in dB or -1 if microphone monitoring is disabled.

See [startMicrophoneMonitor](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#startMicrophoneMonitor),
[stopMicrophoneMonitor](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#stopMicrophoneMonitor).

### QUALITY_640x480

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK iPhone 0.9.0, iPad 0.9.0, Android 7.5.0
- Permission: read-only

Media type constant for medium-quality video recording.

If recording, specifies that you want to use VGA-quality video recording (pixel dimensions
of 640x480).

### QUALITY_FHD

- Type: Number
- Platforms: Android
- Since: Titanium SDK 12.2.0
- Permission: read-only

Media type constant for FHD video recording.

### QUALITY_HD

- Type: Number
- Platforms: Android
- Since: Titanium SDK 12.2.0
- Permission: read-only

Media type constant for HD video recording.

### QUALITY_HIGH

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK iPhone 0.9.0, iPad 0.9.0, Android 7.5.0
- Permission: read-only

Media type constant for 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_IFRAME_1280x720

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK Android 7.5.0, iPhone 6.0.0, iPad 6.0.0
- Permission: read-only

Media type constant for medium-quality video recording.

If recording, specifies that you want to use 1280x720 iFrame format.

### QUALITY_IFRAME_960x540

- Type: Number
- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 6.0.0
- Permission: read-only

Media type constant for medium-quality video recording.

If recording, specifies that you want to use 960x540 iFrame format.

### QUALITY_LOW

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK iPhone 0.9.0, iPad 0.9.0, Android 7.5.0
- Permission: read-only

Media type constant for low-quality video recording.

Recorded files can usually be transferred over the cellular network.

### QUALITY_MEDIUM

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Media type constant for medium-quality video recording.

Recorded files can usually be transferred using Wi-Fi. This is the default video
quality setting.

### QUALITY_SD

- Type: Number
- Platforms: Android
- Since: Titanium SDK 12.2.0
- Permission: read-only

Media type constant for SD video recording.

### QUALITY_UHD

- Type: Number
- Platforms: Android
- Since: Titanium SDK 12.2.0
- Permission: read-only

Media type constant for UHD video recording.

### scalingMode

- Type: Number
- Platforms: Android
- Since: Titanium SDK 12.2.0
- Permission: read-only
- Default: `Titanium.Media.IMAGE_SCALING_ASPECT_FILL`

Scaling mode of the preview image.

Accepts: `Titanium.Media.IMAGE_SCALING_ASPECT_FILL`, `Titanium.Media.IMAGE_SCALING_ASPECT_FIT`

### systemMusicPlayer

- Type: Titanium.Media.MusicPlayer
- Platforms: iPhone, iPad, macOS
- Permission: read-only

An instance of [Titanium.Media.MusicPlayer](https://titaniumsdk.com/docs/sdk/Titanium.Media.MusicPlayer.md) representing the system-wide music player.

### torch

- Type: Boolean
- Platforms: Android
- Since: Titanium SDK 12.2.0

Enable or disable the camera torch.

### UNKNOWN_ERROR

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

Constant for unknown media error.

### useCameraX

- Type: Boolean
- Platforms: Android
- Since: Titanium SDK 12.2.0
- Permission: read-only
- Default: `false`

To use the new CameraX classes for "camera with overlay" set `useCameraX` to `true`

### VERTICAL_ALIGN_BOTTOM

- Type: Number
- Platforms: Android
- Since: Titanium SDK 12.2.0
- Permission: read-only

Vertical align center

### VERTICAL_ALIGN_CENTER

- Type: Number
- Platforms: Android
- Since: Titanium SDK 12.2.0
- Permission: read-only

Vertical align center

### VERTICAL_ALIGN_TOP

- Type: Number
- Platforms: Android
- Since: Titanium SDK 12.2.0
- Permission: read-only

Vertical align center

### verticalAlign

- Type: Number
- Platforms: Android
- Since: Titanium SDK 12.2.0
- Permission: read-only
- Default: `Titanium.Media.VERTICAL_ALIGN_CENTER`

Vertical align of the preview image for aspect fit.

Accepts: `Titanium.Media.VERTICAL_ALIGN_BOTTOM`, `Titanium.Media.VERTICAL_ALIGN_CENTER`, `Titanium.Media.VERTICAL_ALIGN_TOP`

### VIDEO_CONTROL_DEFAULT

- Type: Number
- Platforms: Android
- Permission: read-only
- DEPRECATED since 7.0.0. This property has been removed for iOS in Titanium SDK 7.0.0 as of the official deprecation by Apple.

Constant for default video controls.

Used in conjunction with the
[mediaControlStyle](https://titaniumsdk.com/docs/sdk/Titanium.Media.VideoPlayer.md#mediaControlStyle) property
of [Titanium.Media.VideoPlayer](https://titaniumsdk.com/docs/sdk/Titanium.Media.VideoPlayer.md).

Removed on iOS in SDK 7.0.0.

### VIDEO_CONTROL_EMBEDDED

- Type: Number
- Platforms: Android
- Permission: read-only
- DEPRECATED since 7.0.0. This property has been removed for iOS in Titanium SDK 7.0.0 as of the official deprecation by Apple.

Constant for video controls for an embedded view.

Used in conjunction with the
[mediaControlStyle](https://titaniumsdk.com/docs/sdk/Titanium.Media.VideoPlayer.md#mediaControlStyle) property
of [Titanium.Media.VideoPlayer](https://titaniumsdk.com/docs/sdk/Titanium.Media.VideoPlayer.md).

On Android, this constant has the same effect as VIDEO_CONTROL_DEFAULT. Video controls may
only be shown or hidden.

Removed on iOS in SDK 7.0.0.

### VIDEO_CONTROL_FULLSCREEN

- Type: Number
- Platforms: Android
- Permission: read-only
- DEPRECATED since 7.0.0. This property has been removed for iOS in Titanium SDK 7.0.0 as of the official deprecation by Apple.

Constant for fullscreen video controls.

Used in conjunction with the
[mediaControlStyle](https://titaniumsdk.com/docs/sdk/Titanium.Media.VideoPlayer.md#mediaControlStyle) property
of [Titanium.Media.VideoPlayer](https://titaniumsdk.com/docs/sdk/Titanium.Media.VideoPlayer.md).

On iOS, use VIDEO_CONTROL_FULLSCREEN when creating a video player that occupies the entire
screen, that is, the parent window should be a fullscreen window
([fullscreen](https://titaniumsdk.com/docs/sdk/Titanium.UI.Window.md#fullscreen) set to `true`) and the video player should
occupy the entirety of the parent window.

If the user clicks the **Done** button in the fullscreen control bar, the video player
pauses playback and generates a [complete](https://titaniumsdk.com/docs/sdk/Titanium.Media.VideoPlayer.md#complete) event.

Note that if you create a video player that does *not* occupy the entire screen, and later
switch to fullscreen mode, the video controls are switched automatically. That is, if
`mediaControlStyle` is set to VIDEO_CONTROL_DEFAULT or VIDEO_CONTROL_EMBEDDED, it is
automatically switched to the fullscreen controls when the player enters fullscreen mode.
This is true whether the user initiates the mode switch by clicking the fullscreen button
in the embedded controls, or if you programmatically switch to full screen mode (by setting
the `fullscreen` property to true).

On Android, this constant has the same effect as VIDEO_CONTROL_DEFAULT. Video controls may
only be shown or hidden.

Removed on iOS in SDK 7.0.0.

### VIDEO_CONTROL_HIDDEN

- Type: Number
- Platforms: Android
- Permission: read-only
- DEPRECATED since 7.0.0. This property has been removed for iOS in Titanium SDK 7.0.0 as of the official deprecation by Apple.

Constant for video controls hidden.

Used in conjunction with the
[mediaControlStyle](https://titaniumsdk.com/docs/sdk/Titanium.Media.VideoPlayer.md#mediaControlStyle) property
of [Titanium.Media.VideoPlayer](https://titaniumsdk.com/docs/sdk/Titanium.Media.VideoPlayer.md).

Removed on iOS in SDK 7.0.0.

### VIDEO_CONTROL_NONE

- Type: Number
- Platforms: Android
- Permission: read-only
- DEPRECATED since 7.0.0. This property has been removed for iOS in Titanium SDK 7.0.0 as of the official deprecation by Apple.

Constant for no video controls.

Used in conjunction with the
[mediaControlStyle](https://titaniumsdk.com/docs/sdk/Titanium.Media.VideoPlayer.md#mediaControlStyle) property
of [Titanium.Media.VideoPlayer](https://titaniumsdk.com/docs/sdk/Titanium.Media.VideoPlayer.md).

Removed on iOS in SDK 7.0.0.

### VIDEO_FINISH_REASON_PLAYBACK_ENDED

- Type: Number
- Platforms: Android
- Permission: read-only

Video playback ended normally.

### VIDEO_FINISH_REASON_PLAYBACK_ERROR

- Type: Number
- Platforms: Android
- Permission: read-only

Video playback ended abnormally.

### VIDEO_FINISH_REASON_USER_EXITED

- Type: Number
- Platforms: Android
- Permission: read-only

Video playback ended by user action (such as clicking the `Done` button).

### VIDEO_LOAD_STATE_FAILED

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Indicates that the player can no longer play media items because of an error.

### VIDEO_LOAD_STATE_PLAYABLE

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

Current media is playable.

### VIDEO_LOAD_STATE_UNKNOWN

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

Current load state is not known.

### VIDEO_MEDIA_TYPE_AUDIO

- Type: String
- Platforms: iPhone, iPad, macOS
- Permission: read-only

The media contains audio media.

### VIDEO_MEDIA_TYPE_CLOSED_CAPTION

- Type: String
- Platforms: iPhone, iPad, macOS
- Permission: read-only

The media contains closed-caption content.

### VIDEO_MEDIA_TYPE_DEPTH_DATA

- Type: String
- Platforms: iPhone, iPad, macOS
- Permission: read-only

The media contains depth data.

### VIDEO_MEDIA_TYPE_METADATA

- Type: String
- Platforms: iPhone, iPad, macOS
- Permission: read-only

The media contains metadata.

### VIDEO_MEDIA_TYPE_METADATA_OBJECT

- Type: String
- Platforms: iPhone, iPad, macOS
- Permission: read-only

The media contains metadata objects.

### VIDEO_MEDIA_TYPE_MUXED

- Type: String
- Platforms: iPhone, iPad, macOS
- Permission: read-only

The media contains muxed media.

### VIDEO_MEDIA_TYPE_SUBTITLE

- Type: String
- Platforms: iPhone, iPad, macOS
- Permission: read-only

The media contains subtitles.

### VIDEO_MEDIA_TYPE_TEXT

- Type: String
- Platforms: iPhone, iPad, macOS
- Permission: read-only

The media contains text.

### VIDEO_MEDIA_TYPE_TIMECODE

- Type: String
- Platforms: iPhone, iPad, macOS
- Permission: read-only

The media contains a time code.

### VIDEO_MEDIA_TYPE_VIDEO

- Type: String
- Platforms: iPhone, iPad, macOS
- Permission: read-only

The media contains video.

### VIDEO_PLAYBACK_STATE_INTERRUPTED

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

Video playback has been interrupted.

### VIDEO_PLAYBACK_STATE_PAUSED

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

Video playback is paused.

### VIDEO_PLAYBACK_STATE_PLAYING

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

Video is being played.

### VIDEO_PLAYBACK_STATE_SEEKING_BACKWARD

- Type: Number
- Platforms: Android
- Permission: read-only

Video playback is rewinding.

This constant has been removed on iOS in SDK 7.0.0 by using the official Apple AVPlayer that does not expose this functionality so far.

### VIDEO_PLAYBACK_STATE_SEEKING_FORWARD

- Type: Number
- Platforms: Android
- Permission: read-only

Video playback is seeking forward.

This constant has been removed on iOS in SDK 7.0.0 by using the official Apple AVPlayer that does not expose this functionality so far.

### VIDEO_PLAYBACK_STATE_STOPPED

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

Video playback is stopped.

### VIDEO_REPEAT_MODE_NONE

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK Android 6.2.0, iPhone 0.9.0, iPad 0.9.0
- Permission: read-only

Constant for disabling repeat on video playback.

### VIDEO_REPEAT_MODE_ONE

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK Android 6.2.0, iPhone 0.9.0, iPad 0.9.0
- Permission: read-only

Constant for repeating one video (i.e., the one video will repeat constantly) during playback.

### VIDEO_SCALING_ASPECT_FILL

- Type: Number
- Platforms: Android
- Permission: read-only
- DEPRECATED since 7.0.0. Use <Titanium.Media.VIDEO_SCALING_RESIZE_ASPECT_FILL> instead. This property has been removed for iOS in Titanium SDK 7.0.0 as of the official deprecation by Apple.

Scale video to fill the screen, clipping edges if necessary.

Video is scaled until the video 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

- Type: Number
- Platforms: Android
- Permission: read-only
- DEPRECATED since 7.0.0. Use <Titanium.Media.VIDEO_SCALING_RESIZE_ASPECT> instead. This property has been removed for iOS in Titanium SDK 7.0.0 as of the official deprecation by Apple.

Scale video to fit the screen, letterboxing if necessary.

Video is scaled until the larger 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.

This constant was removed on iOS in SDK 7.0.0

### VIDEO_SCALING_MODE_FILL

- Type: Number
- Platforms: Android
- Permission: read-only
- DEPRECATED since 7.0.0. Use <Titanium.Media.VIDEO_SCALING_MODE_RESIZE> instead. This property has been removed for iOS in Titanium SDK 7.0.0 as of the official deprecation by Apple.

Video is scaled until both dimensions fit the screen exactly, stretching if necessary.

This constant was removed on iOS in SDK 7.0.0

### VIDEO_SCALING_NONE

- Type: Number
- Platforms: Android
- Permission: read-only
- DEPRECATED since 7.0.0. This property has been removed for iOS in Titanium SDK 7.0.0 as of the official deprecation by Apple.

Video scaling is disabled.

This constant was removed on iOS in SDK 7.0.0

### VIDEO_SCALING_RESIZE

- Type: String | Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK iPhone 7.0.0, iPad 7.0.0, Android 8.3.0
- Permission: read-only

Specifies that the video should be stretched to fill the bounds of layer.

This is a `String` on iOS, a `Number` on Android.

### VIDEO_SCALING_RESIZE_ASPECT

- Type: String | Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK iPhone 7.0.0, iPad 7.0.0, Android 8.3.0
- Permission: read-only

Specifies that the player should preserve the aspect ratio of video and fit the video within the bounds of layer.

This is a `String` on iOS, a `Number` on Android.

### VIDEO_SCALING_RESIZE_ASPECT_FILL

- Type: String | Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK iPhone 7.0.0, iPad 7.0.0, Android 8.3.0
- Permission: read-only

Specifies that the player should preserve the aspect ratio of video and fill the bounds of layer.

This is a `String` on iOS, a `Number` on Android.

### VIDEO_TIME_OPTION_CLOSEST_SYNC

- Type: Number
- Platforms: Android
- Since: Titanium SDK 3.6.0
- Permission: read-only

Use the closest sync (or key) frame at given the time.

### VIDEO_TIME_OPTION_EXACT

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Use the exact time.

### VIDEO_TIME_OPTION_NEAREST_KEYFRAME

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 3.6.0
- Permission: read-only

Use the closest keyframe in the time.

### VIDEO_TIME_OPTION_NEXT_SYNC

- Type: Number
- Platforms: Android
- Since: Titanium SDK 3.6.0
- Permission: read-only

Use the sync (or key) frame located right after or at given the time.

### VIDEO_TIME_OPTION_PREVIOUS_SYNC

- Type: Number
- Platforms: Android
- Since: Titanium SDK 3.6.0
- Permission: read-only

Use the sync (or key) frame located right before or at given the time.

### volume

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Current volume of the playback device.

A value in the range `0.0` to `1.0`, with `0.0` representing the minimum volume and `1.0` representing the maximum volume.

### zoomLevel

- Type: Number
- Platforms: Android
- Since: Titanium SDK 12.2.0

Sets the zoom level of the camera.

## Methods

### beep

- Platforms: iPhone, iPad, macOS

Plays a device beep notification.

### createAudioPlayer

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 0.9

Creates and returns an instance of [Titanium.Media.AudioPlayer](https://titaniumsdk.com/docs/sdk/Titanium.Media.AudioPlayer.md).

Parameters:

- `parameters` (Dictionary<Titanium.Media.AudioPlayer>, optional): Properties to set on a new object, including any defined by [Titanium.Media.AudioPlayer](https://titaniumsdk.com/docs/sdk/Titanium.Media.AudioPlayer.md) except those marked not-creation or read-only.

Returns: Titanium.Media.AudioPlayer

### createAudioRecorder

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK iPhone 0.9, iPad 0.9, Android 6.2.0

Creates and returns an instance of [Titanium.Media.AudioRecorder](https://titaniumsdk.com/docs/sdk/Titanium.Media.AudioRecorder.md).

Parameters:

- `parameters` (Dictionary<Titanium.Media.AudioRecorder>, optional): Properties to set on a new object, including any defined by [Titanium.Media.AudioRecorder](https://titaniumsdk.com/docs/sdk/Titanium.Media.AudioRecorder.md) except those marked not-creation or read-only.

Returns: Titanium.Media.AudioRecorder

### createSound

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 0.8

Creates and returns an instance of [Titanium.Media.Sound](https://titaniumsdk.com/docs/sdk/Titanium.Media.Sound.md).

Parameters:

- `parameters` (Dictionary<Titanium.Media.Sound>, optional): Properties to set on a new object, including any defined by [Titanium.Media.Sound](https://titaniumsdk.com/docs/sdk/Titanium.Media.Sound.md) except those marked not-creation or read-only.

Returns: Titanium.Media.Sound

### createSystemAlert

- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 6.1.0
- DEPRECATED since 8.0.0. This iOS-only API has been deprecated and moved to the [Ti.SystemAlert](https://github.com/appcelerator-modules/ti.systemalert) module in 8.0.0.

Creates and returns an instance of [Titanium.Media.SystemAlert](https://titaniumsdk.com/docs/sdk/Titanium.Media.SystemAlert.md).

Parameters:

- `parameters` (Dictionary<Titanium.Media.SystemAlert>, optional): Properties to set on a new object, including any defined by [Titanium.Media.SystemAlert](https://titaniumsdk.com/docs/sdk/Titanium.Media.SystemAlert.md) except those marked not-creation or read-only.

Returns: Titanium.Media.SystemAlert

### createVideoPlayer

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 0.9

Creates and returns an instance of [Titanium.Media.VideoPlayer](https://titaniumsdk.com/docs/sdk/Titanium.Media.VideoPlayer.md).

Parameters:

- `parameters` (Dictionary<Titanium.Media.VideoPlayer>, optional): Properties to set on a new object, including any defined by [Titanium.Media.VideoPlayer](https://titaniumsdk.com/docs/sdk/Titanium.Media.VideoPlayer.md) except those marked not-creation or read-only.

Returns: Titanium.Media.VideoPlayer

### hasAudioPermissions

- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 6.0.0
- DEPRECATED since 6.1.0, removed in 10.0.0. Use [Titanium.Media.hasAudioRecorderPermissions](Titanium.Media.hasAudioRecorderPermissions) instead.

Returns `true` if the app has audio permissions.

Recording audio requires explicit permission from the user. After the user
grants or denies permission, the system remembers the choice for future use in the same app.
If permission is not granted, or if the user has not yet responded to the permission prompt,
any audio recording sessions record only silence.

In addition, Apple introduced the Info.plist key `NSMicrophoneUsageDescription` that is used to display an
own description while authorizing microphone permissions. In iOS 10, this key is mandatory and the application
will crash if your app does not include the key. Check the [Apple docs](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html)
for more information.

Returns: Boolean

### hasAudioRecorderPermissions

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK Android 6.2.0, iPhone 6.1.0, iPad 6.1.0

Returns `true` if the app has audio permissions.

Recording audio requires explicit permission from the user. After the user
grants or denies permission, the system remembers the choice for future use in the same app.
If permission is not granted, or if the user has not yet responded to the permission prompt,
any audio recording sessions record only silence.

In addition, Apple introduced the Info.plist key `NSMicrophoneUsageDescription` that is used to display an
own description while authorizing microphone permissions. In iOS 10, this key is mandatory and the application
will crash if your app does not include the key. Check the [Apple docs](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html)
for more information.

Returns: Boolean

### hasCameraPermissions

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 5.1.0

Returns `true` if the app has camera access.

Returns: Boolean

### hasMusicLibraryPermissions

- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 6.0.0

Returns `true` if the app has music library access.

Music-library permissions are only needed in iOS 9.3 and later and will be ignored on older
iOS versions. Because of that, the method will return `true` for devices that run iOS < 9.3.

Returns: Boolean

### hasPhotoGalleryPermissions

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK Android 9.3.0, iPhone 6.0.0, iPad 6.0.0

Returns `true` if the app has photo gallery permissions.

If you use Android 13+ you have to add the following permissions to your tiapp.xml:
``` xml
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
```

You don't need to check this before using [Titanium.Media.requestPhotoGalleryPermissions](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#requestPhotoGalleryPermissions). If you already have the permission and use
[Titanium.Media.requestPhotoGalleryPermissions](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#requestPhotoGalleryPermissions) it will call the success event, no second permission request is displayed.

Returns: Boolean

### hideCamera

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 3.2.0

Hides the device camera UI.

Must be called after calling `showCamera` and only when `autohide` is set to `false`.
This method causes the media capture UI to be hidden.

### hideMusicLibrary

- Platforms: iPhone, iPad, macOS

Hides the music library.

Must be called after calling [openMusicLibrary](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#openMusicLibrary)
and only when `autohide` is set to `false`.

### isMediaTypeSupported

- Platforms: iPhone, iPad, macOS

Returns `true` if the source supports the specified media type.

You can query whether a given media type is supported by the device's
camera (`source` == 'camera') or photo library (`source` == 'photo').

An additional value, `photogallery` can be  used to query the media
supported by the device's camera roll or saved image album, which is a
subset of the iOS photo library. However, when calling
[openPhotoGallery](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#openPhotoGallery) on iOS, the entire
library is displayed, and there is currently no way to restrict the
gallery to show only the camera roll/saved images album.

Parameters:

- `source` (String): Media source specified as a string: `camera` for Camera or `photo` for Photo Library.
- `type` (String): Media type to check.

Returns: Boolean

### openMusicLibrary

- Platforms: iPhone, iPad, macOS

Shows the music library and allows the user to select one or more tracks.

If `autohide` is set to `false`, you must hide the library explicitly using
[hideMusicLibrary](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#hideMusicLibrary).

Parameters:

- `options` (MusicLibraryOptionsType): A dictionary of options as described in [MusicLibraryOptionsType](https://titaniumsdk.com/docs/sdk/MusicLibraryOptionsType.md).

### openPhotoGallery

- Platforms: Android, iPhone, iPad, macOS

Opens the photo gallery image picker.

In iOS 6, Apple introduced the Info.plist key `NSPhotoLibraryUsageDescription` that is used to display an
own description while authorizing gallery permissions. In iOS 10, this key is mandatory and the application
will crash if your app does not include the key. Check the [Apple docs](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html)
for more information.

Parameters:

- `options` (PhotoGalleryOptionsType): Photo gallery options as described in [PhotoGalleryOptionsType](https://titaniumsdk.com/docs/sdk/PhotoGalleryOptionsType.md).

### pauseVideoCapture

- Platforms: Android
- Since: Titanium SDK 12.2.0

Pauses video capturing.

### previewImage

- Platforms: Android

Displays the given image.

Parameters:

- `options` (Dictionary<PreviewImageOptions>): Dictionary containing the image and callback functions.

### queryMusicLibrary

- Platforms: iPhone, iPad, macOS

Searches the music library for items matching the specified search predicates.

Use [Titanium.Media.hasMusicLibraryPermissions](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#hasMusicLibraryPermissions) to check the granted permissions and
[Titanium.Media.requestMusicLibraryPermissions](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#requestMusicLibraryPermissions) to request the permissions. This is especially important
when running on an iOS 10 device, because the music-library access will crash without having the privacy-key
`NSAppleMusicUsageDescription` that is specified in [Titanium.Media.requestMusicLibraryPermissions](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#requestMusicLibraryPermissions).

Parameters:

- `query` (MediaQueryType): The query object to extract information from.

Returns: Array<Titanium.Media.Item>

### requestAudioRecorderPermissions

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK Android 6.2.0, iPhone 6.1.0, iPad 6.1.0

Request the user's permission for audio recording.

Recording audio requires explicit permission from the user. After the user
grants or denies permission, the system remembers the choice for future use in the same app.
If permission is not granted, or if the user has not yet responded to the permission prompt,
any audio recording sessions record only silence.

In addition, Apple introduced the Info.plist key `NSMicrophoneUsageDescription` that is used to display an
own description while authorizing microphone permissions. In iOS 10, this key is mandatory and the application
will crash if your app does not include the key. Check the [Apple docs](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html)
for more information.

Parameters:

- `callback` (Callback<MediaAuthorizationResponse>, optional): Callback function to execute when the users responds to the authorization alert. Optional on SDK 10, as this method will return a `Promise`, which may be used to handle the result.

Returns: Promise<MediaAuthorizationResponse> - On SDK 10+, this method will return a `Promise` whose resolved value is equivalent to that passed to the optional callback argument.

### requestCameraPermissions

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 5.1.0

Requests for camera access.

On Android, the request view will show if the permission is not accepted by the user, and the user did
not check the box "Never ask again" when denying the request. If the user checks the box "Never ask again,"
the user has to manually enable the permission in device settings.

This method requests `Manifest.permission.CAMERA`, `Manifest.permission.READ_EXTERNAL_STORAGE` and `Manifest.permission.WRITE_EXTERNAL_STORAGE` on Android.
If you require other permissions, you can also use [Titanium.Android.requestPermissions](https://titaniumsdk.com/docs/sdk/Titanium.Android.md#requestPermissions).

In iOS 6, Apple introduced the Info.plist key `NSCameraUsageDescription` that is used to display an
own description while authorizing camera permissions. In iOS 10, this key is mandatory when taking a photo
and the application will crash if your app does not include the key. Check the [Apple docs](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html)
for more information. When using the camera to take a video, you also need the `NSMicrophoneUsageDescription` key.
In addition, the authorization dialog will only show if user has not made a decision, yet.
If the user has, the callback will return the earlier decision. To change the permission the user needs to
change it in the device settings.

Parameters:

- `callback` (Callback<RequestCameraAccessResult>, optional): Function to call indicating if permission was granted or denied. Optional on SDK 10, as this method will return a `Promise`, which may be used to handle the result.

Returns: Promise<RequestCameraAccessResult> - On SDK 10+, this method will return a `Promise` whose resolved value is equivalent to that passed to the optional callback argument.

### requestMusicLibraryPermissions

- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 6.0.0

Request permissions for the native music-library.

Music-library permissions are only needed in iOS 9.3 and later and will be ignored on older
iOS versions. Because of that, the callback will ignore the permission-check and always return
`{success: true}` for devices that run iOS < 9.3.

Important: On iOS 10, Apple introduced the Info.plist key `NSAppleMusicUsageDescription` that is used to
display an own description while authorizing the music library. This key is mandatory and the application
will crash if your app does not include the key. Check the [Apple docs](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html)
for more information.

Parameters:

- `callback` (Callback<RequestMusicLibraryAccessResult>): Function to call indicating if permission was granted or denied.

### requestPhotoGalleryPermissions

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK Android 9.3.0, iPhone 6.0.0, iPad 6.0.0

Requests for photo gallery permissions.

In iOS 6, Apple introduced the Info.plist key `NSPhotoLibraryUsageDescription` that is used to display an
own description while authorizing photo gallery permissions. In iOS 10, this key is mandatory when accessing the
photo gallery and the application will crash if your app does not include the key. Check the [Apple docs](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html)
for more information. If the user has, the callback will return the earlier decision. To change the permission the
user needs to change it in the device settings.

iOS Apps that do not include this method, will present the system-dialog while the dialog is opened with [Titanium.Media.openPhotoGallery](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#openPhotoGallery).

If you use Android 13+ you have to add the following permissions to your tiapp.xml:
``` xml
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
```
When you only want to use it for images you can use `[Titanium.Android.requestPermissions](https://titaniumsdk.com/docs/sdk/Titanium.Android.md#requestPermissions)` and request `android.permission.READ_MEDIA_IMAGES`.

Parameters:

- `callback` (Callback<RequestPhotoGalleryAccessResult>, optional): Function to call indicating if permission was granted or denied. Optional on SDK 10, as this method will return a `Promise`, which may be used to handle the result.

Returns: Promise<RequestPhotoGalleryAccessResult> - On SDK 10+, this method will return a `Promise` whose resolved value is equivalent to that passed to the optional callback argument.

### resumeVideoCapture

- Platforms: Android
- Since: Titanium SDK 12.2.0

Resumes video capturing.

### saveToPhotoGallery

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 3.3.0

Saves media to the device's photo gallery / camera roll.

This operation is asynchronous. The caller can supply callbacks to be triggered when the
save operation completes.

Media can be passed as either a `Blob` object or a `File` object. If the `media` argument
is not one of these types, an error is generated.

Note that when passing a file (or a blob created from a file), the file name must
have the appropriate extension for the data--for example, `image.jpg` or `video1.mov` work,
but `video1.tmp` does not. Currently, the `.mp4` extension is not supported, but MP4
files may be imported by saving them with the `.mov` extension.

Make sure to check for gallery access permissions with [Titanium.Media.hasPhotoGalleryPermissions](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#hasPhotoGalleryPermissions)
and request the permissions with [Titanium.Media.requestPhotoGalleryPermissions](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#requestPhotoGalleryPermissions) if not granted.
On iOS, the `NSPhotoLibraryAddUsageDescription` plist key is required in the tiapp.xml in order
to use this API.

On Android, this method does not support saving videos to the gallery prior to Titanium SDK 6.1.0.

Parameters:

- `media` (Titanium.Blob | Titanium.Filesystem.File): Media to save to the camera roll or media gallery.
- `callbacks` (Object): Pass a dictionary with the following supported keys: `success` a function that will be called when the save succeeds, and `error` a function that will be called upon receiving an error.

### setOverrideAudioRoute

- Platforms: iPhone, iPad, macOS

Overrides the default audio route when using the [Titanium.Media.AUDIO_SESSION_CATEGORY_PLAY_AND_RECORD](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#AUDIO_SESSION_CATEGORY_PLAY_AND_RECORD) session mode.

By default, when using the [Titanium.Media.AUDIO_SESSION_CATEGORY_PLAY_AND_RECORD](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#AUDIO_SESSION_CATEGORY_PLAY_AND_RECORD) session mode,
the audio output is routed to the speaker in the receiver. This method lets you specify
that audio should be routed to the built-in speaker.

If you override the audio route while audio is playing the changes won't not take effect until  the audio is restarted.

Parameters:

- `route` (Number): The specified audio route.

### showCamera

- Platforms: Android, iPhone, iPad, macOS

Shows the camera.

By default, the native camera controls are displayed. To add your own camera controls,
you can add an overlay view by setting the `overlay` property on the `options` argument.

#### Android Platform Notes

* To suppress the default controls, set `autohide` to `false` and then set the
`overlay` property to a view that contains a control (such as a button) to
take the photo. You must then control the camera explicitly, using
the [takePicture](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#takePicture) and [hideCamera](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#hideCamera)
methods.
* Setting `saveToPhotoGallery` to `false` is not guaranteed to work with all camera apps. If this setting is desired, then you should use Titanium's internal camera overlay instead.
* You can only use one or the other (video or photo) types in the array.

#### iOS Platform Notes

To suppress the default controls, set `showControls` and `autohide` to `false`.

If the `showControls` option is `false`, you must control the camera explicitly, using
the [takePicture](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#takePicture) and [hideCamera](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#hideCamera)
methods.

Images taken with the camera will not have accurate geolocation data embedded in the images;
the latitude and longitude will be set to '0'.  This is not an error, but a limitation which
Apple has put on the camera API.

Important: Use [Titanium.Media.hasCameraPermissions](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#hasCameraPermissions) and [Titanium.Media.requestCameraPermissions](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#requestCameraPermissions)
to ask for camera permissions. This is especially important when running on iOS 10 and later, since
the application may crash otherwise.

Parameters:

- `options` (CameraOptionsType): A dictionary of camera options as described in [CameraOptionsType](https://titaniumsdk.com/docs/sdk/CameraOptionsType.md).

### startMicrophoneMonitor

- Platforms: iPhone, iPad, macOS

Starts monitoring the microphone sound level.

### startVideoCapture

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 5.4.0

Starts video capture using the camera specified.

### stopMicrophoneMonitor

- Platforms: iPhone, iPad, macOS

Stops monitoring the microphone sound level.

### stopVideoCapture

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 5.4.0

Stops video capture using the camera specified.

### switchCamera

- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK Android 3.2.0, iPhone 1.8.1, iPad 1.8.1

Switches between front and rear-facing cameras. Make sure to set one of the below constants to determine
the camera you want to switch to.

In Android, this can only be called when using a custom overlay (see [Titanium.Media.showCamera](https://titaniumsdk.com/docs/sdk/Titanium.Media.md#showCamera)).

Parameters:

- `camera` (Number): Constant indicating to which camera you want to switch.

### takePicture

- Platforms: Android, iPhone, iPad, macOS

Uses the device camera to capture a photo.

Must be called after calling `showCamera` and only when `autohide` is set to `false`.

This method causes the media capture device to capture a photo and call the
`success` callback.

### takeScreenshot

- Platforms: Android, iPhone, iPad, macOS

Takes a screen shot of the visible UI on the device.

This method is asynchronous. The screenshot is returned in the callback argument.
The callback argument's `media` property contains the screenshot image as a
[Blob](https://titaniumsdk.com/docs/sdk/Titanium.Blob.md) object.

Parameters:

- `callback` (Callback<ScreenshotResult>): Function to call upon capture.

### vibrate

- Platforms: Android, iPhone, iPad, macOS

Makes the device vibrate.

On Android, a `pattern` argument can be provided to specify a
vibration pattern.

The `pattern` is an array of Number values.  Each number in the array is
interpreted as a duration in milliseconds. The first number is the *delay*
before the pattern starts, and the remaining numbers are interpreted as
alternating periods of on and off times. For example, the following pattern:

``` js
[ 0, 500, 100, 500, 100, 500 ]
```

Would cause the vibration to start immediately (delay = 0), and perform three
long vibrations (500 ms) separated by short pauses (100ms).

Parameters:

- `pattern` (Array<Number>, optional): Array of values identifying a vibrate pattern (only used on Android).

## Events

### cameraready

- Platforms: Android
- Since: Titanium SDK 6.0.0

Fires when the camera overlay is ready to take pictures.

### routechange

- Platforms: iPhone, iPad, macOS
- Since: Titanium SDK 3.4.2

Fired when an audio line type change is detected.

Event properties:

- `reason` (String): The reason for route change.
- `oldRoute` (RouteDescription): Returns a description of the old route, consisting of zero or more input ports and zero or more output ports.
- `currentRoute` (RouteDescription): Returns a description of the current route, consisting of zero or more input ports and zero or more output ports.

### volume

- Platforms: iPhone, iPad, macOS

Fired when the volume output changes.

Event properties:

- `volume` (Number): New volume level in dB.

## Inherited members

7 members are inherited. Each is documented on the type that declares it.

- [Titanium.Proxy](https://titaniumsdk.com/docs/sdk/12.6.2/Titanium.Proxy.md): `addEventListener`, `apiName`, `applyProperties`, `bubbleParent`, `fireEvent`, `lifecycleContainer`, `removeEventListener`

---

- This corpus documents Titanium SDK 13.4.1. Anything here that does not name a version describes 13.4.1.
- Titanium is maintained by TiDev. The Appcelerator toolchain is retired: there is no `appc` CLI, no Appcelerator Studio and no hosted build service. The supported CLI is `titanium` on npm, invoked as `ti`.

