YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.player.PlayOrder Class Reference

The order in which the items of a playlist are played, and which item follows or precedes another. More...

Collaboration diagram for de.yaacc.player.PlayOrder:
Collaboration graph

Public Member Functions

 PlayOrder (Random random)
 
synchronized void reset (int size, int firstIndex, boolean shuffle)
 Creates the order of a new playlist.
 
synchronized void setShuffle (boolean shuffle, int currentIndex)
 Switches shuffle on or off.
 
synchronized void fit (int size, int currentIndex)
 Adapts the order to a playlist of another size without touching the part that is already played.
 
synchronized void insert (int index, int count, int currentIndex)
 Makes room for items that were put into the middle of the list: the items of the order at index and after it move up by count, the new items are index to index + count - 1.
 
synchronized boolean isShuffle ()
 
synchronized int size ()
 
synchronized int first ()
 
synchronized int[] toArray ()
 
synchronized int next (int currentIndex, PlayMode.RepeatMode repeat, boolean autoAdvance)
 Which item plays after the current one.
 
synchronized int following (int currentIndex)
 
synchronized int preceding (int currentIndex)
 
synchronized int previous (int currentIndex)
 Which item plays when somebody skips back.
 
synchronized int positionOf (int index)
 
synchronized int itemAt (int position)
 
synchronized boolean move (int fromPosition, int toPosition)
 Moves the item at fromPosition to toPosition; the items in between move up or down by one (what a drag in a list does).
 
synchronized boolean remove (int index)
 Takes an item that was removed from the playlist out of the order.
 
synchronized boolean isAtOrBeforeCurrent (int position, int currentIndex)
 

Static Public Attributes

static final int NONE = -1
 Result of next, previous and following when there is no such item.
 

Detailed Description

The order in which the items of a playlist are played, and which item follows or precedes another.

Plain JVM, thread safe (the timer thread, the UI and the UPnP threads all ask).

Without shuffle the order is the list order. With shuffle it is a random permutation that is created once (when the playlist is set, shuffle is switched on, or the player is stopped) and then kept, so previous walks back through the order next walked along. A created order starts with the item that is playing, so every other item is still ahead: the list is played through once whatever the item was.

The position in the order is never stored: it is looked up from the index of the current item, which the player owns (an engine can change it too). A playlist that grew or shrank is adapted by fit.

Constructor & Destructor Documentation

◆ PlayOrder()

de.yaacc.player.PlayOrder.PlayOrder ( Random random)
Parameters
randomthe source of the shuffle; a seeded one makes the order reproducible in tests

Member Function Documentation

◆ first()

synchronized int de.yaacc.player.PlayOrder.first ( )
Returns
the item that plays first, NONE for an empty playlist

Referenced by de.yaacc.player.AbstractPlayer.setItems().

Here is the caller graph for this function:

◆ fit()

synchronized void de.yaacc.player.PlayOrder.fit ( int size,
int currentIndex )

Adapts the order to a playlist of another size without touching the part that is already played.

New items (added to the end of the list) are appended, or with shuffle inserted at a random place behind the current item. A smaller list creates the order again, current item first.

Referenced by de.yaacc.player.AbstractPlayer.getNextItemIndex(), de.yaacc.player.AbstractPlayer.getPlayOrder(), de.yaacc.player.AbstractPlayer.getPreviousItemIndex(), de.yaacc.player.AbstractPlayer.insertItems(), de.yaacc.player.AbstractPlayer.isPlaylistPositionLocked(), de.yaacc.player.AbstractPlayer.playItemAt(), de.yaacc.player.AbstractPlayer.removeItem(), de.yaacc.imageviewer.ImageViewerViewModel.setPlayMode(), and de.yaacc.player.AbstractPlayer.setPlayMode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ following()

synchronized int de.yaacc.player.PlayOrder.following ( int currentIndex)
Returns
the item behind the current one in the order, NONE at the end of the order (no wrap around); the first item for a current item that is not in the playlist

Referenced by de.yaacc.player.AbstractPlayer.getNextItemIndex(), and de.yaacc.player.PlayOrder.next().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insert()

synchronized void de.yaacc.player.PlayOrder.insert ( int index,
int count,
int currentIndex )

Makes room for items that were put into the middle of the list: the items of the order at index and after it move up by count, the new items are index to index + count - 1.

Without shuffle they take their place in the list order, with shuffle each one is placed at a random place behind the current item (what has been played stays).

Parameters
indexwhere the new items start in the list; clamped to the list
counthow many items; nothing happens for zero or less
currentIndexthe current item, before the insert

Referenced by de.yaacc.player.AbstractPlayer.insertItems().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isAtOrBeforeCurrent()

synchronized boolean de.yaacc.player.PlayOrder.isAtOrBeforeCurrent ( int position,
int currentIndex )
Returns
true if the position is the one of the current item or before it: what has been played (or plays) is not edited. False for a current item that is not in the order.

Referenced by de.yaacc.player.AbstractPlayer.isPlaylistPositionLocked().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ itemAt()

synchronized int de.yaacc.player.PlayOrder.itemAt ( int position)
Returns
the item that plays at the position, NONE for a position outside the order

◆ move()

synchronized boolean de.yaacc.player.PlayOrder.move ( int fromPosition,
int toPosition )

Moves the item at fromPosition to toPosition; the items in between move up or down by one (what a drag in a list does).

Only the order changes, the items keep their indexes.

Returns
false (and nothing changed) if a position is outside the order or both are the same

Referenced by de.yaacc.player.AbstractPlayer.moveInPlayOrder().

Here is the caller graph for this function:

◆ next()

synchronized int de.yaacc.player.PlayOrder.next ( int currentIndex,
PlayMode.RepeatMode repeat,
boolean autoAdvance )

Which item plays after the current one.

Parameters
currentIndexthe item that plays now
repeatthe repeat mode
autoAdvancetrue when the current item ended by itself, false when somebody skips to the next one. Repeat one only repeats an ended item; skipping goes on (and, like in ExoPlayer, treats repeat one as off: it does not wrap around at the end)
Returns
the item index; NONE at the end of the order unless the repeat mode is all
Here is the call graph for this function:

◆ positionOf()

synchronized int de.yaacc.player.PlayOrder.positionOf ( int index)
Returns
the position of the item in the order, -1 if the item is not in it. With shuffle off the position of an item is its index.

Referenced by de.yaacc.player.PlayOrder.fit(), de.yaacc.player.PlayOrder.following(), de.yaacc.player.PlayOrder.isAtOrBeforeCurrent(), de.yaacc.player.PlayOrder.next(), de.yaacc.player.PlayOrder.preceding(), de.yaacc.player.PlayOrder.remove(), and de.yaacc.player.AbstractPlayer.removeItem().

Here is the caller graph for this function:

◆ preceding()

synchronized int de.yaacc.player.PlayOrder.preceding ( int currentIndex)
Returns
the item before the current one in the order, NONE before the first one (no wrap around)

Referenced by de.yaacc.player.AbstractPlayer.getPreviousItemIndex(), and de.yaacc.player.PlayOrder.previous().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ previous()

synchronized int de.yaacc.player.PlayOrder.previous ( int currentIndex)

Which item plays when somebody skips back.

Before the first item it goes to the last one (what the players always did); NONE only for an empty playlist.

Here is the call graph for this function:

◆ remove()

synchronized boolean de.yaacc.player.PlayOrder.remove ( int index)

Takes an item that was removed from the playlist out of the order.

The order of the other items is kept (unlike fit, which creates a shuffled order again), their indexes behind the removed one move down by one like the list does.

Parameters
indexthe index of the removed item
Returns
false (and nothing changed) if the item is not in the order

Referenced by de.yaacc.player.AbstractPlayer.removeItem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

synchronized void de.yaacc.player.PlayOrder.reset ( int size,
int firstIndex,
boolean shuffle )

Creates the order of a new playlist.

Parameters
sizethe number of items
firstIndexthe item that comes first, NONE (or out of range) for a random first one (a shuffled playlist that starts playing); ignored without shuffle
shuffletrue for a random order

Referenced by de.yaacc.player.AbstractPlayer.adoptDeviceState(), de.yaacc.player.PlayOrder.fit(), de.yaacc.player.AbstractPlayer.resetPlayOrder(), de.yaacc.player.AbstractPlayer.setItems(), and de.yaacc.player.PlayOrder.setShuffle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setShuffle()

synchronized void de.yaacc.player.PlayOrder.setShuffle ( boolean shuffle,
int currentIndex )

Switches shuffle on or off.

The current item stays the current one: switched on, it becomes the first of a new random order; switched off, the items go on in list order after it.

Referenced by de.yaacc.imageviewer.ImageViewerViewModel.setPlayMode(), and de.yaacc.player.AbstractPlayer.setPlayMode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toArray()

synchronized int[] de.yaacc.player.PlayOrder.toArray ( )
Returns
a copy of the order: the item index played at each position

Referenced by de.yaacc.player.PlayOrder.fit(), de.yaacc.player.AbstractPlayer.getPlayOrder(), de.yaacc.player.PlayOrder.insert(), and de.yaacc.player.PlayOrder.reset().

Here is the caller graph for this function:

The documentation for this class was generated from the following file: