amip.api.highlevel
Class Playlist

java.lang.Object
  extended by amip.api.highlevel.Playlist

public class Playlist
extends java.lang.Object

This class provides an easy read-only access to the playlist. You can get the whole playlist as an ArrayList. There are 2 ways to get the playlist, the async way and sync. If you are connecting to remote AMIP over a slow connection or playlist is very large or you want your GUI to stay responsive, consider using async way.

The simpliest way to get the playlist is the syncAndGetCopy method. Playlist instance itself is returned by Client.getPlaylist(). Client and Server must be already initialized before making any calls to the Playlist methods.


Method Summary
 void addSyncCompleteListener(SyncCompleteEventListener l)
          Adds listener which is notified when playlist synchronization with player is complete.
 java.util.ArrayList getCopy()
          Once playlist is synced with the sync() method you can get its copy using this method, it's recommended to call this method in your SyncCompleteEventListener class to be sure that the list is in sync.
 int getSize()
          Returns the number of entries in the playlist.
 java.lang.String getTitle(int index)
          Gets the title from playlist with the specified index.
 boolean isAutoSynchronize()
           
 boolean isInSync()
          Checks if AMIP's playlist is in sync with the players playlist.
 void removeSyncCompleteListener(SyncCompleteEventListener l)
          Removes previously added listener.
 void setAutoSynchronize(boolean autoSynchronize)
          Enables the automatic sync mode.
 void sync()
          Synchronizes playlist with player and AMIP, if AMIP's and player's lists are not in sync, it automatically invokes reindexing in AMIP.
 java.util.ArrayList syncAndGetCopy()
          The easiest way to get the playlist, it automatically invokes sync with the player, waits until sync is complete and returns a copy like getCopy() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addSyncCompleteListener

public void addSyncCompleteListener(SyncCompleteEventListener l)
Adds listener which is notified when playlist synchronization with player is complete.

Parameters:
l - listener.

removeSyncCompleteListener

public void removeSyncCompleteListener(SyncCompleteEventListener l)
Removes previously added listener.

Parameters:
l - listener.

isAutoSynchronize

public boolean isAutoSynchronize()

getSize

public int getSize()
Returns the number of entries in the playlist.

Returns:
the size of the playlist, 0 is returned in case playlist is not synced.

getTitle

public java.lang.String getTitle(int index)
Gets the title from playlist with the specified index.

Parameters:
index - the index of title.
Returns:
playlist title or null if index is not within bounds or title is not available.

getCopy

public java.util.ArrayList getCopy()
Once playlist is synced with the sync() method you can get its copy using this method, it's recommended to call this method in your SyncCompleteEventListener class to be sure that the list is in sync.

Returns:
a copy of the playlist as a Java ArrayList, returns empty array list if the list is not synced.

syncAndGetCopy

public java.util.ArrayList syncAndGetCopy()
                                   throws GeneralClientException,
                                          java.lang.InterruptedException
The easiest way to get the playlist, it automatically invokes sync with the player, waits until sync is complete and returns a copy like getCopy() method.

Returns:
a copy of the playlist as a Java ArrayList, returns empty array list if the list is not synced.
Throws:
GeneralClientException
java.lang.InterruptedException

isInSync

public boolean isInSync()
Checks if AMIP's playlist is in sync with the players playlist.

Returns:
true if the list is in sync, false otherwise.

setAutoSynchronize

public void setAutoSynchronize(boolean autoSynchronize)
                        throws GeneralClientException
Enables the automatic sync mode. In this mode when the playlist is changed in player, AMIP will automatically sync with it. It just adds the PlaylistChangeEventListener and calls sync() method in it.

Parameters:
autoSynchronize - true/false.
Throws:
GeneralClientException

sync

public void sync()
          throws GeneralClientException
Synchronizes playlist with player and AMIP, if AMIP's and player's lists are not in sync, it automatically invokes reindexing in AMIP. Once sync is complete, SyncCompleteEventListener listeners are notified about it.

Throws:
GeneralClientException