com.breeweb.slimconnect.iface.delegate
Class Slimp3Delegate

java.lang.Object
  extended bycom.breeweb.slimconnect.iface.delegate.Slimp3Delegate
All Implemented Interfaces:
java.lang.Comparable

public class Slimp3Delegate
extends java.lang.Object
implements java.lang.Comparable

Author:
Bas de Bree

Method Summary
 void closeConnections()
          closes the connections of this delegate.
 int compareTo(java.lang.Object anObject)
           
 boolean equals(java.lang.Object anObject)
           
 Playlist getCurrentPlayList()
          Returns the current playlist
 Song getCurrentSong()
          Returns the current song playing
 DisplayReturnData getDisplay()
          Returns the current lines on the display.
 DisplayReturnData getDisplayNow()
          Shows exactly what's on the display, this includes any anymation.
static Slimp3Delegate getInstance(java.lang.String ip, int port)
          Returns a Slimp3Delegate interface to a SLIMP3 / Squeezebox server.
static Slimp3Delegate getInstance(java.lang.String ip, int port, Player aPlayer)
          Returns a Slimp3Delegate interface to a SLIMP3 / squizebox server, This method directly sets the player to which it should be bound.
 java.lang.String getMode()
          Gets the current mode.
 Player[] getPlayers()
          Returns an array of available Players
 double getSleep()
          Returns the time to play in seconds before going into sleep mode.
 int hashCode()
           
 boolean isPowerOn()
          indicates wether or not power is on.
 void play()
          Sends the "play" command
 void playlistAdd(java.lang.String url)
          Adds the specified song URL, playlist or directory contents to the end of the current playlist.
 void playlistAddAlbum(PlaylistSearchCriteria criteria)
          Appends all songs matching the specified criteria onto the end of the playlist.
 void playlistClear()
          Removes any song that is on the playlist.
 void playlistDelete(int index)
          Deletes the song at the specified index from the current playlist.
 int playlistGetIndex()
          Queries the song that is currently playing by index.
 void playlistInsert(java.lang.String url)
          Inserts the specified song URL, playlist or directory contents to be played immediately after the current song in the current playlist.
 void playlistLoadAlbum(PlaylistSearchCriteria criteria)
          Puts songs matching the specified genre artist and album criteria on the playlist.
 void playlistMove(int indexFrom, int indexTo)
          Moves the song at the specified index to a new index in the playlist.
 void playlistNext(int amount)
          next n numbers
 void playlistPlay(java.lang.String url)
          Puts the specified song URL, playlist or directory contents into the current playlist and plays starting at the first item.
 void playlistPrev(int amount)
          previous song
 void playlistResume(java.lang.String name)
          Replace the current playlist with the playlist specified by name, starting at the song that was playing when the file was saved.
 void playlistSave(java.lang.String name)
          Saves a playlist file in the saved playlists directory.
 void playlistSetIndex(int index)
          sets the current index within the playlist
 int repeat()
          returns the repeat mode (0,1,2).
 ReturnData setDisplay(java.lang.String line1, int timeInSeconds)
          Sets the text (line1) on the first line of the display for an number of seconds specified by timeInSeconds
 ReturnData setDisplay(java.lang.String line1, java.lang.String line2, int timeInSeconds)
          Sets the text (line1 and 2) on the display for an number of seconds specified by timeInSeconds
 void setPause(boolean on)
          Set or unset the pause mode.
 void setPlayer(Player aPlayer)
          Binds this interface instance to the given player
 void setPower(boolean on)
          Switch power on|off
 void setRepeat(int mode)
          Sets the repeat mode.
 void setShuffle(boolean on)
          set suffle mode (en-/disable) note this might be changed in future releases, three modes are able.
 void setSleep(double time)
          Sets the time to play in seconds before going into sleep mode.
 boolean shuffle()
          returns a boolean indicating if shuffle is enabled, now three modes are enabled (0,1,2).
 void stop()
          Sends the stop command
 void togglePause()
          Toggles the pause mode.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Slimp3Delegate getInstance(java.lang.String ip,
                                         int port)
                                  throws DataException
Returns a Slimp3Delegate interface to a SLIMP3 / Squeezebox server.

Parameters:
ip - the ipadress the server is working on.
port - the portnumber the server is working on.
Returns:
a Slimp3Delegate interface to a SLIMP3 / Squeezebox server.
Throws:
DataException

closeConnections

public void closeConnections()
closes the connections of this delegate.


setPlayer

public void setPlayer(Player aPlayer)
Binds this interface instance to the given player

Parameters:
aPlayer - the player to which this interface instance should be bound.

getInstance

public static Slimp3Delegate getInstance(java.lang.String ip,
                                         int port,
                                         Player aPlayer)
                                  throws DataException
Returns a Slimp3Delegate interface to a SLIMP3 / squizebox server, This method directly sets the player to which it should be bound.

Parameters:
ip - the ipadress the server is working on.
port - the portnumber the server is working on.
aPlayer - the player to which this interface instance should be bound.
Returns:
a Slimp3Delegate interface to a SLIMP3 / squizebox server.
Throws:
DataException

equals

public boolean equals(java.lang.Object anObject)

hashCode

public int hashCode()

compareTo

public int compareTo(java.lang.Object anObject)
Specified by:
compareTo in interface java.lang.Comparable

setDisplay

public ReturnData setDisplay(java.lang.String line1,
                             int timeInSeconds)
                      throws DataException
Sets the text (line1) on the first line of the display for an number of seconds specified by timeInSeconds

Parameters:
line1 - the first line.
timeInSeconds - the number of seconds to display the line
Returns:
the ReturnData object, which represents the response of the server.
Throws:
DataException

setDisplay

public ReturnData setDisplay(java.lang.String line1,
                             java.lang.String line2,
                             int timeInSeconds)
                      throws DataException
Sets the text (line1 and 2) on the display for an number of seconds specified by timeInSeconds

Parameters:
line1 - the first line on the display
line2 - the second line on the display
timeInSeconds - the number of seconds to display the lines
Returns:
the ReturnData object, which represents the response of the server.
Throws:
DataException

getDisplay

public DisplayReturnData getDisplay()
                             throws DataException
Returns the current lines on the display. This will be a String containing a newLine char (\n) as line seperator. This text excludes any anymations, Text which is put on the display using the setDisplay command is threated as anymation also. use @see #getDisplayNow() to get the raw display data.

Returns:
the current lines on the display as DisplayReturnData.
Throws:
DataException
See Also:
DisplayReturnData

getDisplayNow

public DisplayReturnData getDisplayNow()
                                throws DataException
Shows exactly what's on the display, this includes any anymation. Text which is put on the display using set display is seen as anymation too.

Returns:
exactly what's on the display, this includes any anymation.
Throws:
DataException
See Also:
getDisplay()

getPlayers

public Player[] getPlayers()
                    throws DataException
Returns an array of available Players

Returns:
an array of available Players
Throws:
DataException
See Also:
Player

getCurrentSong

public Song getCurrentSong()
                    throws DataException
Returns the current song playing

Returns:
the current song playing
Throws:
DataException
See Also:
Song

play

public void play()
          throws DataException
Sends the "play" command

Throws:
DataException

togglePause

public void togglePause()
                 throws DataException
Toggles the pause mode.

Throws:
DataException

setPause

public void setPause(boolean on)
              throws DataException
Set or unset the pause mode.

Parameters:
on - boolean indicating wether or not to go into pause mode.
Throws:
DataException

stop

public void stop()
          throws DataException
Sends the stop command

Throws:
DataException

getMode

public java.lang.String getMode()
                         throws DataException
Gets the current mode. Note, this returnvalue might be replaced by a code object.

Returns:
the current mode.
Throws:
DataException

setPower

public void setPower(boolean on)
              throws DataException
Switch power on|off

Parameters:
on - on or if false off
Throws:
DataException

isPowerOn

public boolean isPowerOn()
                  throws DataException
indicates wether or not power is on.

Returns:
boolean, indicates wether or not power is on
Throws:
DataException

getCurrentPlayList

public Playlist getCurrentPlayList()
                            throws DataException
Returns the current playlist

Returns:
the current playlist
Throws:
DataException
See Also:
Playlist

shuffle

public boolean shuffle()
                throws DataException
returns a boolean indicating if shuffle is enabled, now three modes are enabled (0,1,2). this might be changed in future releases.

Returns:
a boolean indicating if shuffle is enabled,
Throws:
DataException
See Also:
setRepeat(int)

setShuffle

public void setShuffle(boolean on)
                throws DataException
set suffle mode (en-/disable) note this might be changed in future releases, three modes are able.

Parameters:
on - boolean for en-/disabling.
Throws:
DataException
See Also:
setRepeat(int)

repeat

public int repeat()
           throws DataException
returns the repeat mode (0,1,2).

Returns:
the repeat mode.
Throws:
DataException
See Also:
setRepeat(int)

setRepeat

public void setRepeat(int mode)
               throws DataException
Sets the repeat mode. 0: off 1: current song 2: current album

Parameters:
mode - (0, 1, 2)
Throws:
DataException

getSleep

public double getSleep()
                throws DataException
Returns the time to play in seconds before going into sleep mode. Returns 0 if no sleep mode is set.

Returns:
the time to play in seconds before going into sleep mode, or 0 when no mode is set.
Throws:
DataException

setSleep

public void setSleep(double time)
              throws DataException
Sets the time to play in seconds before going into sleep mode. Note the player will slowly turn down the playing volume (at sleep=0) and will be turned off after a while. This means the player won't be off directly when time seconds are over.

Parameters:
time - in seconds
Throws:
DataException

playlistPlay

public void playlistPlay(java.lang.String url)
                  throws DataException
Puts the specified song URL, playlist or directory contents into the current playlist and plays starting at the first item. Any songs previously in the playlist are discarded.

Parameters:
url - The URL, playlist or directory which should be played.
Throws:
DataException

playlistAdd

public void playlistAdd(java.lang.String url)
                 throws DataException
Adds the specified song URL, playlist or directory contents to the end of the current playlist. Any songs currently playing or already on the playlist are not affected.

Parameters:
url - The URL, playlist or directory which should be added
Throws:
DataException

playlistInsert

public void playlistInsert(java.lang.String url)
                    throws DataException
Inserts the specified song URL, playlist or directory contents to be played immediately after the current song in the current playlist. Any songs currently playing or already on the playlist are not affected.

Parameters:
url - The URL, playlist or directory which should be inserted
Throws:
DataException

playlistMove

public void playlistMove(int indexFrom,
                         int indexTo)
                  throws DataException
Moves the song at the specified index to a new index in the playlist. An offset of zero is the first song in the playlist.

Parameters:
indexFrom - index which should be moved.
indexTo - index to which the before index should be moved to.
Throws:
DataException

playlistDelete

public void playlistDelete(int index)
                    throws DataException
Deletes the song at the specified index from the current playlist.

Parameters:
index - the index in the playlist which should be deleted.
Throws:
DataException

playlistResume

public void playlistResume(java.lang.String name)
                    throws DataException
Replace the current playlist with the playlist specified by name, starting at the song that was playing when the file was saved. (Resuming works only with M3U files saved with the playlist save command.) Shortcut: use a bare playlist name (without leading directories or trailing .m3u suffix to load a playlist in the saved playlists folder.

Parameters:
name - the name of the playlist which should be resumed.
Throws:
DataException

playlistSave

public void playlistSave(java.lang.String name)
                  throws DataException
Saves a playlist file in the saved playlists directory. Accepts a playlist filename (without .m3u suffix) and saves in the top level of the playlists directory. Shortcut: use a bare playlist name (without leading directories or trailing .m3u suffix to load a playlist in the saved playlists folder.

Parameters:
name - the name of the playlist.
Throws:
DataException

playlistLoadAlbum

public void playlistLoadAlbum(PlaylistSearchCriteria criteria)
                       throws DataException
Puts songs matching the specified genre artist and album criteria on the playlist. Any songs previously in the playlist are discarded. The genre, artist and album parameters are wrapped in a PlaylistSearchCriteria

Parameters:
criteria - The criteria for which songs should be loaded.
Throws:
DataException
See Also:
PlaylistSearchCriteria

playlistAddAlbum

public void playlistAddAlbum(PlaylistSearchCriteria criteria)
                      throws DataException
Appends all songs matching the specified criteria onto the end of the playlist. Any songs currently playing or already on the playlist are not affected. The genre ,artist and album parameters are wrapped in a PlaylistSearchCriteria

Parameters:
criteria - The criteria for which songs should be appended.
Throws:
DataException
See Also:
PlaylistSearchCriteria

playlistClear

public void playlistClear()
                   throws DataException
Removes any song that is on the playlist. If a song is currently playing, it is stopped.

Throws:
DataException

playlistGetIndex

public int playlistGetIndex()
                     throws DataException
Queries the song that is currently playing by index.

Throws:
DataException

playlistSetIndex

public void playlistSetIndex(int index)
                      throws DataException
sets the current index within the playlist

Parameters:
index - the index.
Throws:
DataException

playlistNext

public void playlistNext(int amount)
                  throws DataException
next n numbers

Parameters:
amount - the amount of numbers forward
Throws:
DataException

playlistPrev

public void playlistPrev(int amount)
                  throws DataException
previous song

Parameters:
amount - the amount of numbers back
Throws:
DataException