# Titanium.Media.MusicPlayer
This object represents a music controller.
# 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
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
An Item
object representing the currently playing media item.
# playbackState READONLY
Playback state.
# shuffleMode
Shuffle setting.
# Methods
# seekBackward
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
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
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
Skips to the beginning of the currently playing media item.
Returns
- Type
- void
# skipToNext
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
Skips to the previous media item in the queue.
If there are no previous media items in the queue, ends playback.
Returns
- Type
- void
# stopSeeking
Ends a seek operation and returns to the previous playback state.
See also: seekForward and seekBackward.
Returns
- Type
- void
# Events
# playingchange
Fired when the currently playing media item changes.
See nowPlaying to identify the current media item.
# statechange
Fired when the music player's playback state changes.
See playbackState to identify the current playback state.