# Titanium.Media.MusicPlayer

This object represents a music controller.

Availability
1.4.0
9.2.0

# Overview

A MusicPlayer lets you manage and playback a queue of media Titanium.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 Titanium.Media module's Titanium.Media.openMusicLibrary and Titanium.Media.queryMusicLibrary methods to access the media items in the device's media library.

# Properties

# currentPlaybackTime

Availability
1.4.0
9.2.0
currentPlaybackTime :Number

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.


# nowPlaying READONLY

Availability
1.4.0
9.2.0
nowPlaying :Titanium.Media.Item

An Item object representing the currently playing media item.


# repeatMode

Availability
1.4.0
9.2.0
repeatMode :Number

Repeat setting.


# shuffleMode

Availability
1.4.0
9.2.0
shuffleMode :Number

Shuffle setting.

# Methods

# pause

Availability
1.4.0
9.2.0
pause() void

Pauses playback of the current media item.

Returns

Type
void

# play

Availability
1.4.0
9.2.0
play() void

Begins playback of the current media item.

Returns

Type
void

# seekBackward

Availability
1.4.0
9.2.0
seekBackward() void

Begins seeking backward in the currently playing media.

Seeking speed increases as seeking continues.

Call stopSeeking to return to normal play.

Returns

Type
void

# seekForward

Availability
1.4.0
9.2.0
seekForward() void

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.

Returns

Type
void

# setQueue

Availability
1.4.0
9.2.0
setQueue(queue) void

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 persistentID property that identifies a media item uniquely.

Parameters

Name Type Description
queue Titanium.Media.Item | Array<Titanium.Media.Item> | String

One or more media items.

Returns

Type
void

# skipToBeginning

Availability
1.4.0
9.2.0
skipToBeginning() void

Skips to the beginning of the currently playing media item.

Returns

Type
void

# skipToNext

Availability
1.4.0
9.2.0
skipToNext() void

Skips to the next media item in the queue.

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

Returns

Type
void

# skipToPrevious

Availability
1.4.0
9.2.0
skipToPrevious() void

Skips to the previous media item in the queue.

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

Returns

Type
void

# stop

Availability
1.4.0
9.2.0
stop() void

Stops playback of the current media queue.

Returns

Type
void

# stopSeeking

Availability
1.4.0
9.2.0
stopSeeking() void

Ends a seek operation and returns to the previous playback state.

See also: seekForward and seekBackward.

Returns

Type
void

# Events

# playingchange

Availability
3.0.0
9.2.0

Fired when the currently playing media item changes.

See nowPlaying to identify the current media item.


# statechange

Availability
3.0.0
9.2.0

Fired when the music player's playback state changes.

See playbackState to identify the current playback state.