Skip to content
Titanium SDK
Version12.6.4

You are reading 12.6.4. See this page in 13.4.1.

Titanium.Media.MusicPlayer

proxyiPhoneiPadmacOSsince 1.4.0

Extends Titanium.Proxy

This object represents a music controller.

A MusicPlayer lets you manage and playback a queue of media Item objects.

To retrieve an instance of a MusicPlayer object, use either the Titanium.Media.appMusicPlayer or the Titanium.Media.systemMusicPlayer property.

Use the Media module's openMusicLibrary and queryMusicLibrary methods to access the media items in the device's media library.

Properties 7

apiName

Stringsince Android 3.2.0, iPhone 3.2.0, iPad 3.2.0, macOS 9.2.0read-only

Inherited from Titanium.Proxy

The name of the API that this proxy corresponds to.

bubbleParent

Booleansince Android 3.0.0, iPhone 3.0.0, iPad 3.0.0, macOS 9.2.0

Inherited from Titanium.Proxy

Indicates if the proxy will bubble an event to its parent.

Default: true

Current point in song playback, in seconds.

This property is read/write, so you can update the music player's current position by setting this property.

Methods 14

Inherited from Titanium.Proxy

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

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to invoke when the event is fired.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

Inherited from Titanium.Proxy

Fires a synthesized event to any registered listeners.

Parameters
ParametersTypeDescription
nameString

Name of the event.

event?Dictionary

A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.

Pauses playback of the current media item.

Begins playback of the current media item.

Inherited from Titanium.Proxy

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

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to remove. Must be the same function passed to addEventListener.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

Begins seeking backward in the currently playing media.

Seeking speed increases as seeking continues.

Call stopSeeking to return to normal play.

Begins seeking forward in the currently playing media item.

While seeking forward audio plays faster than usual. The speed increases as seeking continues.

Call stopSeeking to return to normal play.

Sets the media queue.

Sets the media queue to a single media item or a list of items.

Starting in Titanium 6.1.0 you can also pass a String that identifies the Media item. This string has to be the Titanium.Media.Item.persistentID property that identifies a media item uniquely.

Parameters
ParametersTypeDescription
queueTitanium.Media.Item | Array<Titanium.Media.Item> | String

One or more media items.

Skips to the beginning of the currently playing media item.

Skips to the next media item in the queue.

If there are no more media items in the queue, ends playback.

Skips to the previous media item in the queue.

If there are no previous media items in the queue, ends playback.

Stops playback of the current media queue.

Events 2

playingchange

since 3.0.0

Fired when the currently playing media item changes.

See nowPlaying to identify the current media item.

statechange

since 3.0.0

Fired when the music player's playback state changes.

See playbackState to identify the current playback state.