SourceForge.net Logo




com.qotsa.jni.controller
Class WinampController

java.lang.Object
  extended by com.qotsa.jni.controller.WinampController

public class WinampController
extends java.lang.Object

This class is a wrapper to call JNI functions to send Message to Winamp Window.


Field Summary
static int CURRENTTIME
          Constant used as parameter in getTime() method Value = 0
static int ISNOTPLAYING
          Constant used as return in getTime() Value = -1
static int PAUSED
          Constant used as return in getStatus() method Value = 3
static int PLAYING
          Constant used as return in getStatus() method Value = 1
static int STOPPED
          Constant used as return in getStatus() method Value = 0
static int TIMELENGTH
          Constant used as parameter in getTime() method Value = 1
 
Constructor Summary
WinampController()
           
 
Method Summary
static void appendToPlayList(java.lang.String filename)
          Append a File into the List.
static void clearPlayList()
          Clear Winamp's internal playlist.
static void decreaseVolume()
          Decrease Volume a little bit.
static void decreaseVolumePercent(int percent)
          Decrease Volume.
static void exit()
          Exit Winamp.
static void fwd5Secs()
          Fowards 5 seconds on the current song.
static void fwdTracks(int n)
          Fowards n Tracks in Play List.
static java.lang.String getFileNameInList(int pos)
          Get Current Track FileName.
static java.lang.String getFileNamePlaying()
          Get File Name Playing In Winamp.
static int getListPos()
          Get Current List Pos.
static int getPlayListLength()
          Return the PlayListLength.
static int getStatus()
          Get Winamp Status.
static int getTime(int mode)
          Get Song Time.
static java.lang.String getTitle()
          Get Current Track Title.
static void increaseVolume()
          Increase Volume a little bit.
static void increaseVolumePercent(int percent)
          Increase Volume.
static boolean isRepeatStatusOn()
          Verify if Repeat is On.
static boolean isShuffleStatusOn()
          Verify if Shuffle is On.
static void nextTrack()
          Go to Next Track in the play list.
static void pause()
          Pause Winamp.
static void play()
          Play current file in Winamp.
static void previousTrack()
          Go to Previous Track in the play list.
static void refreshPlayListCache()
          Flush the playlist cache buffer.
static void restart()
          Restarts Winamp.
static void resume()
          Resume current file in Winamp.
static void rew5Secs()
          Rewinds 5 seconds on the current song.
static void rewTracks(int n)
          Rewinds n Tracks in Play List.
static void run()
          Verify if Winamp is started and if not started, starts it.
static void setPlaylistPosition(int pos)
          Go to a Specified Position in the List.
static void setRepeatStatusOn(boolean mode)
          Turn on Repeat.
static void setShuffleStatusOn(boolean mode)
          Turn on Shuffle.
static void setVolume(int pos)
          Adjust Volume.
static void stop()
          Stop current file in Winamp.
static int writePlayListToFile()
          Write a Playlist in winampDirInstallation\\Winamp.m3u.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ISNOTPLAYING

public static final int ISNOTPLAYING
Constant used as return in getTime() Value = -1

See Also:
Constant Field Values

CURRENTTIME

public static final int CURRENTTIME
Constant used as parameter in getTime() method Value = 0

See Also:
Constant Field Values

TIMELENGTH

public static final int TIMELENGTH
Constant used as parameter in getTime() method Value = 1

See Also:
Constant Field Values

STOPPED

public static final int STOPPED
Constant used as return in getStatus() method Value = 0

See Also:
Constant Field Values

PLAYING

public static final int PLAYING
Constant used as return in getStatus() method Value = 1

See Also:
Constant Field Values

PAUSED

public static final int PAUSED
Constant used as return in getStatus() method Value = 3

See Also:
Constant Field Values
Constructor Detail

WinampController

public WinampController()
Method Detail

run

public static void run()
                throws java.lang.Exception
Verify if Winamp is started and if not started, starts it.

Throws:
java.lang.Exception - When the key HKEY_LOCAL_MACHINE\Software\Clients\Media\Winamp\shell\open\command is not found in the register. This key is used to find Winamp Directory installation to execute it.

exit

public static void exit()
                 throws InvalidHandle
Exit Winamp.

Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

play

public static void play()
                 throws InvalidHandle
Play current file in Winamp.

Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

stop

public static void stop()
                 throws InvalidHandle
Stop current file in Winamp.

Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

resume

public static void resume()
                   throws InvalidHandle
Resume current file in Winamp.

Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

pause

public static void pause()
                  throws InvalidHandle
Pause Winamp.

Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

previousTrack

public static void previousTrack()
                          throws InvalidHandle
Go to Previous Track in the play list.

Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

nextTrack

public static void nextTrack()
                      throws InvalidHandle
Go to Next Track in the play list.

Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

fwd5Secs

public static void fwd5Secs()
                     throws InvalidHandle
Fowards 5 seconds on the current song.

Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

rew5Secs

public static void rew5Secs()
                     throws InvalidHandle
Rewinds 5 seconds on the current song.

Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

increaseVolume

public static void increaseVolume()
                           throws InvalidHandle
Increase Volume a little bit.

Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

decreaseVolume

public static void decreaseVolume()
                           throws InvalidHandle
Decrease Volume a little bit.

Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

increaseVolumePercent

public static void increaseVolumePercent(int percent)
                                  throws InvalidHandle,
                                         InvalidParameter
Increase Volume.

Parameters:
percent - Percent to Increase Volume.
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)
InvalidParameter - If percent not between 0 and 100

decreaseVolumePercent

public static void decreaseVolumePercent(int percent)
                                  throws InvalidHandle,
                                         InvalidParameter
Decrease Volume.

Parameters:
percent - Percent to Decrease Volume.
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)
InvalidParameter - If percent not between 0 and 100

setVolume

public static void setVolume(int pos)
                      throws InvalidHandle,
                             InvalidParameter
Adjust Volume. Note that the pos must be between 0(0%) and 255 (100%).

Parameters:
pos - Position to Set Volume.
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)
InvalidParameter - If pos not between 0 and 255

restart

public static void restart()
                    throws InvalidHandle,
                           java.lang.Exception
Restarts Winamp.

Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)
java.lang.Exception - When failed to restart Winamp.

setPlaylistPosition

public static void setPlaylistPosition(int pos)
                                throws InvalidHandle,
                                       InvalidParameter
Go to a Specified Position in the List. This method doesn´t play. Just set list position. If you wanna play call play() after set position. Parameter pos is Zero-based index.

Parameters:
pos - Position.
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)
InvalidParameter - If pos is negative or greater than List Length.

clearPlayList

public static void clearPlayList()
                          throws InvalidHandle
Clear Winamp's internal playlist.

Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

refreshPlayListCache

public static void refreshPlayListCache()
                                 throws InvalidHandle
Flush the playlist cache buffer. Call this if you want it to go refetch titles for tracks in the list.

Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

getPlayListLength

public static int getPlayListLength()
                             throws InvalidHandle
Return the PlayListLength.

Returns:
List Length.
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

writePlayListToFile

public static int writePlayListToFile()
                               throws InvalidHandle
Write a Playlist in winampDirInstallation\\Winamp.m3u. This is default Winamp IPC Default. If you wanna change this, just rename the file you´ve created.

Returns:
Current List Position.
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

isShuffleStatusOn

public static boolean isShuffleStatusOn()
                                 throws InvalidHandle
Verify if Shuffle is On.

Returns:
True - On ; False - Off.
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

isRepeatStatusOn

public static boolean isRepeatStatusOn()
                                throws InvalidHandle
Verify if Repeat is On.

Returns:
True - On ; False - Off.
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

setRepeatStatusOn

public static void setRepeatStatusOn(boolean mode)
                              throws InvalidHandle
Turn on Repeat.

Parameters:
mode - True - Turn on Repeat ; False - Turn off Repeat.
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

setShuffleStatusOn

public static void setShuffleStatusOn(boolean mode)
                               throws InvalidHandle
Turn on Shuffle.

Parameters:
mode - True - Turn on Shuffle ; False - Turn off Shuffle.
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

appendToPlayList

public static void appendToPlayList(java.lang.String filename)
                             throws InvalidHandle,
                                    InvalidParameter
Append a File into the List.

Parameters:
filename - FileName to Append in the list.
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)
InvalidParameter - If the filename is an invalid path.

getStatus

public static int getStatus()
                     throws InvalidHandle
Get Winamp Status.

Returns:
STOPPED - Stop PLAYING - play PAUSED - Paused
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

getListPos

public static int getListPos()
                      throws InvalidHandle
Get Current List Pos.

Returns:
Current List Position.
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

getTitle

public static java.lang.String getTitle()
                                 throws InvalidHandle
Get Current Track Title.

Returns:
Current Track Title
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)

getFileNameInList

public static java.lang.String getFileNameInList(int pos)
                                          throws InvalidHandle,
                                                 InvalidParameter
Get Current Track FileName. Parameter pos is Zero-based index.

Parameters:
pos - Track Position in the Current PlayList
Returns:
Current Track FileName
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)
InvalidParameter - If pos is negative or greater than List Length

getTime

public static int getTime(int mode)
                   throws InvalidHandle,
                          InvalidParameter
Get Song Time.

Parameters:
mode - CURRENTTIME - Currently Time in Milliseconds TIMELENGHT - Song Time Length in seconds
Returns:
Time Song (depends on Param mode) or ISNOTPLAYING if there is no info about time because it not starts to play.
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)
InvalidParameter - if parameter is not CURRENTTIME or TIMELENGTH.

fwdTracks

public static void fwdTracks(int n)
                      throws InvalidParameter,
                             InvalidHandle
Fowards n Tracks in Play List.

Parameters:
n - Number of Tracks to Foward
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)
InvalidParameter - if n is negative or Zero.

rewTracks

public static void rewTracks(int n)
                      throws InvalidParameter,
                             InvalidHandle
Rewinds n Tracks in Play List.

Parameters:
n - Number of Tracks to Rewind
Throws:
InvalidHandle - When the Winamp Windows is not handle(in most case, it means that winamp is not running)
InvalidParameter - if n is negative or Zero.

getFileNamePlaying

public static java.lang.String getFileNamePlaying()
                                           throws InvalidHandle
Get File Name Playing In Winamp.

Returns:
Current File Name.
Throws:
InvalidHandle