|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sk.baka.ambient.PlaylistPlayer
public final class PlaylistPlayer
This is THE component :) Combines player and playlist. Emits
IPlaylistPlayerListener
messages.
Field Summary | |
---|---|
(package private) IPlayer |
playerService
The player service invocator. |
Constructor Summary | |
---|---|
PlaylistPlayer(AmbientApplication app)
Creates new player instance. |
Method Summary | |
---|---|
void |
add(int index,
List<TrackMetadataBean> tracks)
Inserts given tracks before track with given index. |
void |
add(int index,
TrackMetadataBean track)
Adds track to the playlist after given track |
void |
add(TrackMetadataBean track)
Adds track to the end of the playlist. |
void |
clearQueue()
Clears queue from queued. |
void |
close()
Closes and deactivates the player. |
void |
dequeue(int track)
Dequeues given track if it was queued previously. |
void |
dynamicPlaylist()
Changes the playlist backend to be a dynamic playlist. |
int |
getCurrentlyPlaying()
Returns currently playing track. |
PlaylistItem |
getCurrentlyPlayingItem()
Returns currently playing track. |
TrackMetadataBean |
getCurrentlyPlayingTrack()
Returns currently playing track. |
PlayerStateEnum |
getPlaybackState()
Returns the playback state. |
List<PlaylistItem> |
getPlayItems()
Returns list of playlist items. |
int |
getPosition()
Returns current position in millis of the playback. |
List<Integer> |
getQueue()
Returns currently queued tracks. |
Random |
getRandom()
Returns current random mode. |
Repeat |
getRepeat()
Returns the repeat mode. |
boolean |
isDynamic()
Returns true if the playlist is a dynamic playlist. |
Interval |
move(Interval interval,
int targetIndex)
Moves selected tracks before track with given index. |
Interval |
moveBy(Interval interval,
int delta)
Moves selected tracks up or down at least delta tracks,
depending on the 'delta' value. |
int |
next()
Moves to next track to be played. |
void |
pause()
Pauses the player, or resumes playback if the player was paused. |
int |
peekNext()
Peeks at the next track without actually changing the current track. |
void |
play()
Plays current track from the beginning. |
int |
play(int trackToPlay)
Plays given track. |
void |
playWithSeek(int startSeekMillis)
Plays current track from the beginning. |
int |
playWithSeek(int trackToPlay,
int startSeekMillis)
Plays given track. |
int |
previous()
Returns previous track to be played. |
(package private) void |
psPlay(int track,
int startSeekMillis)
Requests the player service to play given track. |
void |
queue(int track)
Queues given track, after all other queued tracks. |
void |
queue(Interval tracks)
Queue this track for playing, after all other queued tracks. |
void |
reinit()
Reinitializes the playlist - recomputes new random track ordering etc. |
void |
reinit(AppState state)
Cherry-picks values from the application state and reinitializes itself. |
void |
reinit(IPlaylistStrategy strategy)
Reinits the player with given playlist strategy. |
PlaylistItem |
remove(int index)
Removes a track with given index from the playlist. |
void |
remove(Interval interval)
Removes tracks with given index from the playlist. |
void |
replaceLocations(Map<String,String> locationMap)
Modifies the playlist by changing all PlaylistItem locations. |
void |
seek(int position)
Seeks to given position. |
void |
setRandom(Random random)
Sets the random mode. |
void |
setRepeat(Repeat repeat)
Sets the repeat mode. |
void |
shuffle()
Randomize the playlist. |
int |
size()
Returns the playlist length. |
void |
sortByAlbumOrder()
Sorts the playlist with album order ordering. |
void |
staticPlaylist()
Changes the playlist backend to be an empty static playlist. |
void |
stop()
Stops the playback. |
void |
storeState(AppState result)
Stores the components state into the global state. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
IPlayer playerService
Constructor Detail |
---|
PlaylistPlayer(AmbientApplication app)
app
- the application instance.Method Detail |
---|
public void stop()
public PlayerStateEnum getPlaybackState()
public void pause()
public void seek(int position)
position
- Seek to this position in milliseconds.public void add(int index, TrackMetadataBean track)
index
- insert given track after track with this index.track
- the track to add.public void add(int index, List<TrackMetadataBean> tracks)
IPlaylistStrategy
add
in interface IPlaylistStrategy
index
- the index, must not be negative.tracks
- the tracks meta, must not be null
.public void add(TrackMetadataBean track)
track
- the track to add.public void clearQueue()
IPlaylistStrategy
clearQueue
in interface IPlaylistStrategy
public void dequeue(int track)
IPlaylistStrategy
dequeue
in interface IPlaylistStrategy
track
- the track to dequeue.public int getCurrentlyPlaying()
IPlaylistStrategy
getCurrentlyPlaying
in interface IPlaylistStrategy
-1
if nothing is being
played. Index to the IPlaylistStrategy.getPlayItems()
list.public TrackMetadataBean getCurrentlyPlayingTrack()
null
if no track is being played (
getCurrentlyPlaying()
returns -1
).public PlaylistItem getCurrentlyPlayingItem()
null
if no track is being played (
getCurrentlyPlaying()
returns -1
).public List<PlaylistItem> getPlayItems()
IPlaylistStrategy
Returns list of playlist items. The operation must be quick - it should for example provide immutable view on an internal playlist structure, it should not recompute the list anew on each call.
Each PlaylistItem in the list must be an unique instance.
getPlayItems
in interface IPlaylistStrategy
public int next()
IPlaylistStrategy
-1
if no more
tracks are to be played - this also causes the
IPlaylistStrategy.getCurrentlyPlaying()
method to return -1
.
Calling this method while not playing anything will start to play first
track.
next
in interface IPlaylistStrategy
-1
if no more items are
to be played. Index to the IPlaylistStrategy.getPlayItems()
list.public int play(int trackToPlay)
IPlaylistStrategy
play
in interface IPlaylistStrategy
trackToPlay
- the track to play. Index to the IPlaylistStrategy.getPlayItems()
list.
If -1
then the current track pointer is moved
before first track and the playback is stopped.
public int playWithSeek(int trackToPlay, int startSeekMillis)
trackToPlay
- the track to play. Index to the getPlayItems()
list.
If -1
then the current track pointer is moved
before first track and the playback is stopped.startSeekMillis
- start playback here. Ignored when the stream is not seekable.
public void play()
public void playWithSeek(int startSeekMillis)
startSeekMillis
- start playback here. Ignored when the stream is not seekable.public int previous()
IPlaylistStrategy
-1
if we are
at the beginning of the playing track sequence. Calling this method while
not playing anything will start to play last track.
previous
in interface IPlaylistStrategy
-1
if
we are at the beginning of the playing track sequence.void psPlay(int track, int startSeekMillis)
playlist
is not updated.
track
- the track to play.startSeekMillis
- start seek time, in milliseconds.public void queue(int track)
track
- the track to queue, index to the getPlayItems()
list.public void queue(Interval tracks)
IPlaylistStrategy
queue
in interface IPlaylistStrategy
tracks
- the tracks to queue, index to the IPlaylistStrategy.getPlayItems()
list.public void reinit()
IPlaylistStrategy
IPlaylistStrategy.getCurrentlyPlaying()
will return -1
).
reinit
in interface IPlaylistStrategy
public PlaylistItem remove(int index)
index
- the index.
public boolean isDynamic()
true
if the playlist is a dynamic playlist.
true
if current playlist is dynamic.public void remove(Interval interval)
IPlaylistStrategy
-1
.
remove
in interface IPlaylistStrategy
interval
- the interval to removepublic void setRandom(Random random)
IPlaylistStrategy
setRandom
in interface IPlaylistStrategy
random
- the random mode, never null
.public Random getRandom()
IPlaylistStrategy
getRandom
in interface IPlaylistStrategy
null
.public void shuffle()
IPlaylistStrategy
shuffle
in interface IPlaylistStrategy
public int size()
IPlaylistStrategy
size
in interface IPlaylistStrategy
public void sortByAlbumOrder()
IPlaylistStrategy
sortByAlbumOrder
in interface IPlaylistStrategy
public void dynamicPlaylist()
public void staticPlaylist()
public void close()
public void setRepeat(Repeat repeat)
repeat
- repeat mode, must not be null
.public Repeat getRepeat()
null
.public int getPosition()
public List<Integer> getQueue()
IPlaylistStrategy
getQueue
in interface IPlaylistStrategy
null
.public Interval move(Interval interval, int targetIndex)
IPlaylistStrategy
move
in interface IPlaylistStrategy
interval
- the interval to movetargetIndex
- move tracks before track with this index. If this index is
contained in the interval then nothing is done.
public void reinit(IPlaylistStrategy strategy)
strategy
- the deserialized strategypublic void reinit(AppState state)
AppState.IAppStateAware
reinit
in interface AppState.IAppStateAware
state
- the just-loaded statepublic void storeState(AppState result)
AppState.IAppStateAware
storeState
in interface AppState.IAppStateAware
result
- the object to store to.public Interval moveBy(Interval interval, int delta)
IPlaylistStrategy
Moves selected tracks up or down at least delta
tracks,
depending on the 'delta' value. The playlist may decide to move tracks by
more tracks than requested - for example, the dynamic playlist will skip
the currently playing/queued tracks. If the move is not possible (for
example there are not enough tracks) then move the tracks to the
beginning (or end) of the playlist.
Currently played track will not be changed, although the queue indices. Currently played track will not be changed, although the track index may change.
moveBy
in interface IPlaylistStrategy
interval
- the interval to movedelta
- move tracks up 'delta' tracks (if delta is negative), or down
'delta' tracks (if delta is positive). Do nothing if delta is
zero.
public int peekNext()
IPlaylistStrategy
peekNext
in interface IPlaylistStrategy
-1
when there's no track
left. Dynamic playlist may return -1
when there
are no upcoming tracks and the queue is empty.public void replaceLocations(Map<String,String> locationMap)
IPlaylistStrategy
PlaylistItem
locations.
replaceLocations
in interface IPlaylistStrategy
locationMap
- maps old locations to new locations.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |