com.bramosystems.oss.player.core.client.playlist
Class PlaylistManager

java.lang.Object
  extended by com.bramosystems.oss.player.core.client.playlist.PlaylistManager
All Implemented Interfaces:
PlaylistSupport

public class PlaylistManager
extends java.lang.Object
implements PlaylistSupport

Provides playlist emulation support for media plugins

Since:
1.2
Author:
Sikiru Braheem

Nested Class Summary
static interface PlaylistManager.PlayerCallback
          Interface defines the methods required by the PlaylistManager to interact with a player widget
 
Constructor Summary
PlaylistManager()
          Creates the PlaylistManager object.
PlaylistManager(AbstractMediaPlayer player)
          Creates PlaylistManager for the specified player widget.
 
Method Summary
 void addToPlaylist(java.util.List<MRL> mediaLocators)
          Adds the media locators to the players' playlist.
 void addToPlaylist(MRL mediaLocator)
          Adds the media locator to the players' playlist.
 void addToPlaylist(java.lang.String... mediaURLs)
          Adds the media at the specified URLs to the players' playlist.
 void addToPlaylist(java.lang.String mediaURL)
          Adds the media at the specified URL to the players' playlist.
 void clearPlaylist()
          Removes all entries in the players' playlist
protected  void flushMessageCache()
          Fires debug events with messages that have been cached since the manager is created.
 java.lang.String getCurrentItem()
          Returns the URL at the current playlist reference index
 int getPlaylistIndex()
          Returns the current playlist index
 int getPlaylistSize()
          Returns the number of entries in the playlist
protected  PlaylistManager.PlayerCallback initCallback()
          Returns a player callback handler links this manager to its associated player.
 boolean isShuffleEnabled()
          Checks if this player is in shuffle mode.
 void load(int index)
          Load the URL at the specified index
 void loadAlternative()
          Play another alternative URL for the current resource index
 void loadNext()
          Load the next URL in the playlist
 void play(int index)
          Play playlist entry at the specified index
 void playNext()
          Plays the next item in the playlist
 void playNext(boolean force)
          Plays the next item in the playlist
 void playPrevious()
          Plays the previous item in the playlist
 void playPrevious(boolean force)
          Plays the previous item in the playlist
 void removeFromPlaylist(int index)
          Removes the entry at the specified index from the players' playlist.
 void setShuffleEnabled(boolean enable)
          Enables or disables players' shuffle mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlaylistManager

public PlaylistManager()
Creates the PlaylistManager object.


PlaylistManager

public PlaylistManager(AbstractMediaPlayer player)
Creates PlaylistManager for the specified player widget.

Parameters:
player - the player widget
Method Detail

initCallback

protected PlaylistManager.PlayerCallback initCallback()
Returns a player callback handler links this manager to its associated player.

This is a convenience method that should be overridden by sub-classes.

Returns:
a PlayerCallback implementation

flushMessageCache

protected void flushMessageCache()
Fires debug events with messages that have been cached since the manager is created.

This method should ONLY be called by subclasses when the attached player is ready.


isShuffleEnabled

public boolean isShuffleEnabled()
Description copied from interface: PlaylistSupport
Checks if this player is in shuffle mode.

Specified by:
isShuffleEnabled in interface PlaylistSupport
Returns:
true if player is in shuffle mode, false otherwise.

setShuffleEnabled

public void setShuffleEnabled(boolean enable)
Description copied from interface: PlaylistSupport
Enables or disables players' shuffle mode.

Specified by:
setShuffleEnabled in interface PlaylistSupport
Parameters:
enable - true to enable shuffle, false otherwise

addToPlaylist

public void addToPlaylist(java.lang.String mediaURL)
Description copied from interface: PlaylistSupport
Adds the media at the specified URL to the players' playlist.

In respect of the same domain policy of some plugins/browsers, the URL should point to a destination on the same domain where the application is hosted.

Specified by:
addToPlaylist in interface PlaylistSupport
Parameters:
mediaURL - the URL of the media.

addToPlaylist

public void addToPlaylist(java.lang.String... mediaURLs)
Description copied from interface: PlaylistSupport
Adds the media at the specified URLs to the players' playlist.

The player chooses ONLY ONE of the mediaURLs it supports.

In respect of the same domain policy of some browsers, the URLs should point to a destination on the same domain where the application is hosted.

Specified by:
addToPlaylist in interface PlaylistSupport
Parameters:
mediaURLs - the alternative URLs of the same media (probably in different formats).

addToPlaylist

public void addToPlaylist(java.util.List<MRL> mediaLocators)
Description copied from interface: PlaylistSupport
Adds the media locators to the players' playlist.

Specified by:
addToPlaylist in interface PlaylistSupport
Parameters:
mediaLocators - list of alternative URLs of the same media

addToPlaylist

public void addToPlaylist(MRL mediaLocator)
Description copied from interface: PlaylistSupport
Adds the media locator to the players' playlist.

Specified by:
addToPlaylist in interface PlaylistSupport
Parameters:
mediaLocator - specifies alternative URLs of the same media

removeFromPlaylist

public void removeFromPlaylist(int index)
Description copied from interface: PlaylistSupport
Removes the entry at the specified index from the players' playlist.

Specified by:
removeFromPlaylist in interface PlaylistSupport
Parameters:
index - the index of the playlist entry.

clearPlaylist

public void clearPlaylist()
Description copied from interface: PlaylistSupport
Removes all entries in the players' playlist

Specified by:
clearPlaylist in interface PlaylistSupport

playNext

public void playNext()
              throws PlayException
Description copied from interface: PlaylistSupport
Plays the next item in the playlist

Specified by:
playNext in interface PlaylistSupport
Throws:
PlayException - if there are no more entries in the playlist to be played. Especially if we've advanced to the end of the playlist. Note: A player with a negative loop count (i.e. set to play forever!) may not throw this exception

playPrevious

public void playPrevious()
                  throws PlayException
Description copied from interface: PlaylistSupport
Plays the previous item in the playlist

Specified by:
playPrevious in interface PlaylistSupport
Throws:
PlayException - if there are no more entries in the playlist to be played. Especially if we've gotten to the beginning of the playlist. Note: A player with a negative loop count (i.e. set to play forever!) may not throw this exception

playNext

public void playNext(boolean force)
              throws PlayException
Plays the next item in the playlist

Parameters:
force - true if an end-of-playlist should roll over to the beginning, false otherwise.
Throws:
PlayException - if an end-of-playlist is reached. Only thrown if force is false

playPrevious

public void playPrevious(boolean force)
                  throws PlayException
Plays the previous item in the playlist

Parameters:
force - true if a start-of-playlist should roll over to the end, false otherwise.
Throws:
PlayException - if a start-of-playlist is reached. Only thrown if force is false

play

public void play(int index)
          throws java.lang.IndexOutOfBoundsException
Description copied from interface: PlaylistSupport
Play playlist entry at the specified index

Specified by:
play in interface PlaylistSupport
Parameters:
index - number of the playlist entry
Throws:
java.lang.IndexOutOfBoundsException - if index is outside the bounds of the playlist

loadAlternative

public void loadAlternative()
                     throws LoadException
Play another alternative URL for the current resource index

Throws:
LoadException - if no alternative URL can be found

load

public void load(int index)
Load the URL at the specified index

Parameters:
index - the index

loadNext

public void loadNext()
Load the next URL in the playlist


getCurrentItem

public java.lang.String getCurrentItem()
Returns the URL at the current playlist reference index

Returns:
the URL at the current playlist index

getPlaylistSize

public int getPlaylistSize()
Description copied from interface: PlaylistSupport
Returns the number of entries in the playlist

Specified by:
getPlaylistSize in interface PlaylistSupport
Returns:
number of entries in the playlist

getPlaylistIndex

public int getPlaylistIndex()
Returns the current playlist index

Returns:
the current playlist index


Copyright © 2009-2011. All Rights Reserved.