Package com.tagtraum.beatunes
Class InternalPlayer
- java.lang.Object
-
- com.tagtraum.beatunes.InternalPlayer
-
- All Implemented Interfaces:
AudioPlayer,PlayListPlayer,ApplicationComponent<BeaTunes>
public class InternalPlayer extends Object implements ApplicationComponent<BeaTunes>, PlayListPlayer
Internal playlist player.- Author:
- Hendrik Schreiber
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.tagtraum.audiokern.PlayListPlayer
PlayListPlayer.RepeatMode, PlayListPlayer.ScanMode
-
-
Constructor Summary
Constructors Constructor Description InternalPlayer(BeaTunes application)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAudioPlayerListener(AudioPlayerListener listener)voidaddPlayListPlayerInterceptor(PlayListPlayerInterceptor interceptor)Adds aPlayListPlayerInterceptor.voidaddPropertyChangeListener(PropertyChangeListener propertyChangeListener)voidaddPropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)voidclose()Closes the audio file and associated player resources.intcurrentIndex()Filtered index of the current song in the played list/component.voidfastForward()Plays the file forward at accelerated speed.protected voidfinalize()BeaTunesgetApplication()Returns the main application component.AudioDevicegetAudioDevice()Current audio device.JComponentgetComponent()Main display component for the currently active playlist.longgetDuration()Duration of the song in ms.StringgetId()Unique id for each instance of this object.PlayListIterator<AudioSong>getIterator()Returns the currently used iterator.LonggetPlayListId()Persistent identifier of the current playlist, if available.PlayListPlayer.RepeatModegetRepeatMode()The current repeat mode.ReplayGain.TypegetReplayGainType()Currently configured type of replay gain.PlayListPlayer.ScanModegetScanMode()The current scan mode.AudioSonggetSong()Returns the currently opened song.longgetTime()Returns the current time in ms.floatgetVolume()Returns the volume.voidinit()Initializes this component and its sub-components.booleanisDone()True, if the song was played to the end.booleanisMuted()Indicates whether the player is muted.booleanisPaused()Indicates whether the song is currently playing.voidnext()Move to next song.voidopen(AudioSong song)Opens a song.voidopen(PlayListIterator<AudioSong> iterator)Sets a song iterator.voidpause()Stops playback.voidplay()Starts playback.voidplayPause()Starts playback, if song is paused, otherwise pauses playback.voidprevious()Move to previous song.voidremoveAudioPlayerListener(AudioPlayerListener listener)voidremovePlayListPlayerInterceptor(PlayListPlayerInterceptor interceptor)Removed aPlayListPlayerInterceptor.voidremovePropertyChangeListener(PropertyChangeListener propertyChangeListener)voidremovePropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)voidreset()Positions the player at the beginning of the file.voidsetApplication(BeaTunes application)Sets the main application component.voidsetAudioDevice(AudioDevice audioDevice)Sets the desired audio device.voidsetMuted(boolean muted)Un/mutes this player.voidsetRepeatMode(PlayListPlayer.RepeatMode repeatMode)Sets the current repeat mode.voidsetReplayGainType(ReplayGain.Type type)Asks the player to respect the given kind of replay gain.voidsetScanMode(PlayListPlayer.ScanMode scanMode)Sets a new scan mode.voidsetTime(long time)Sets the current time in ms.voidsetVolume(float volume)Changes the volume.voidshutdown()Shuts down this component and its sub-components.
-
-
-
Constructor Detail
-
InternalPlayer
public InternalPlayer(BeaTunes application)
-
-
Method Detail
-
setAudioDevice
public void setAudioDevice(AudioDevice audioDevice) throws IllegalArgumentException
Description copied from interface:AudioPlayerSets the desired audio device.- Specified by:
setAudioDevicein interfaceAudioPlayer- Parameters:
audioDevice- audio device- Throws:
IllegalArgumentException- if the device is not supported
-
getAudioDevice
public AudioDevice getAudioDevice()
Description copied from interface:AudioPlayerCurrent audio device.- Specified by:
getAudioDevicein interfaceAudioPlayer- Returns:
- currently used audio device
-
setApplication
public void setApplication(BeaTunes application)
Description copied from interface:ApplicationComponentSets the main application component.- Specified by:
setApplicationin interfaceApplicationComponent<BeaTunes>- Parameters:
application- main application component
-
getApplication
public BeaTunes getApplication()
Description copied from interface:ApplicationComponentReturns the main application component.- Specified by:
getApplicationin interfaceApplicationComponent<BeaTunes>- Returns:
- application object
-
getId
public String getId()
Description copied from interface:ApplicationComponentUnique id for each instance of this object.- Specified by:
getIdin interfaceApplicationComponent<BeaTunes>- Returns:
- id
-
init
public void init()
Description copied from interface:ApplicationComponentInitializes this component and its sub-components.- Specified by:
initin interfaceApplicationComponent<BeaTunes>
-
shutdown
public void shutdown() throws ShutdownVetoExceptionDescription copied from interface:ApplicationComponentShuts down this component and its sub-components.- Specified by:
shutdownin interfaceApplicationComponent<BeaTunes>- Throws:
ShutdownVetoException- if this component wants to veto the shutdown. This exception is not guaranteed to be honored, i.e. a calling component may simply ignore it
-
getIterator
public PlayListIterator<AudioSong> getIterator()
Description copied from interface:PlayListPlayerReturns the currently used iterator.- Specified by:
getIteratorin interfacePlayListPlayer- Returns:
- iterator
-
open
public void open(PlayListIterator<AudioSong> iterator) throws IOException
Sets a song iterator.- Specified by:
openin interfacePlayListPlayer- Parameters:
iterator- iterator- Throws:
IOException- if the first song (obtained throughListIterator.next()) cannot be opened- See Also:
AudioPlayer.open(AudioSong)
-
open
public void open(AudioSong song) throws IOException
Description copied from interface:AudioPlayerOpens a song.
Calling this method withnullas argument has the same effect as callingAudioPlayer.close().- Specified by:
openin interfaceAudioPlayer- Parameters:
song- song- Throws:
IOException- if the song cannot be opened
-
getPlayListId
public Long getPlayListId()
Description copied from interface:PlayListPlayerPersistent identifier of the current playlist, if available.- Specified by:
getPlayListIdin interfacePlayListPlayer- Returns:
- id or null, if not available.
-
getComponent
public JComponent getComponent()
Description copied from interface:PlayListPlayerMain display component for the currently active playlist.- Specified by:
getComponentin interfacePlayListPlayer- Returns:
- main display component for the currently active playlist
-
currentIndex
public int currentIndex()
Description copied from interface:PlayListPlayerFiltered index of the current song in the played list/component. This index may change dynamically, as the view of the list is filtered or sorted.- Specified by:
currentIndexin interfacePlayListPlayer- Returns:
- index
-
setRepeatMode
public void setRepeatMode(PlayListPlayer.RepeatMode repeatMode)
Description copied from interface:PlayListPlayerSets the current repeat mode.- Specified by:
setRepeatModein interfacePlayListPlayer- Parameters:
repeatMode- mode
-
getRepeatMode
public PlayListPlayer.RepeatMode getRepeatMode()
Description copied from interface:PlayListPlayerThe current repeat mode.- Specified by:
getRepeatModein interfacePlayListPlayer- Returns:
- current repeat mode
-
setScanMode
public void setScanMode(PlayListPlayer.ScanMode scanMode)
Description copied from interface:PlayListPlayerSets a new scan mode.- Specified by:
setScanModein interfacePlayListPlayer- Parameters:
scanMode- scan mode
-
getScanMode
public PlayListPlayer.ScanMode getScanMode()
Description copied from interface:PlayListPlayerThe current scan mode.- Specified by:
getScanModein interfacePlayListPlayer- Returns:
- current scan mode
-
addPlayListPlayerInterceptor
public void addPlayListPlayerInterceptor(PlayListPlayerInterceptor interceptor)
Description copied from interface:PlayListPlayerAdds aPlayListPlayerInterceptor.- Specified by:
addPlayListPlayerInterceptorin interfacePlayListPlayer- Parameters:
interceptor- interceptor
-
removePlayListPlayerInterceptor
public void removePlayListPlayerInterceptor(PlayListPlayerInterceptor interceptor)
Description copied from interface:PlayListPlayerRemoved aPlayListPlayerInterceptor.- Specified by:
removePlayListPlayerInterceptorin interfacePlayListPlayer- Parameters:
interceptor- interceptor
-
getSong
public AudioSong getSong()
Description copied from interface:AudioPlayerReturns the currently opened song.- Specified by:
getSongin interfaceAudioPlayer- Returns:
- currently opened song
-
isPaused
public boolean isPaused()
Description copied from interface:AudioPlayerIndicates whether the song is currently playing.- Specified by:
isPausedin interfaceAudioPlayer- Returns:
- false if the song is playing
-
fastForward
public void fastForward()
Description copied from interface:AudioPlayerPlays the file forward at accelerated speed.- Specified by:
fastForwardin interfaceAudioPlayer
-
reset
public void reset()
Description copied from interface:AudioPlayerPositions the player at the beginning of the file. Equivalent to callingAudioPlayer.setTime(long)with 0 as argument.- Specified by:
resetin interfaceAudioPlayer- See Also:
AudioPlayer.setTime(long)
-
getTime
public long getTime()
Description copied from interface:AudioPlayerReturns the current time in ms.- Specified by:
getTimein interfaceAudioPlayer- Returns:
- current time in ms
-
setTime
public void setTime(long time) throws IllegalArgumentExceptionDescription copied from interface:AudioPlayerSets the current time in ms.- Specified by:
setTimein interfaceAudioPlayer- Parameters:
time- time in ms- Throws:
IllegalArgumentException- if the time is not valid because it is either less than 0 or greater than duration- See Also:
AudioPlayer.reset(),AudioPlayer.getDuration()
-
getDuration
public long getDuration()
Description copied from interface:AudioPlayerDuration of the song in ms.- Specified by:
getDurationin interfaceAudioPlayer- Returns:
- the overall duration of the song in ms.
-
isDone
public boolean isDone()
Description copied from interface:AudioPlayerTrue, if the song was played to the end.- Specified by:
isDonein interfaceAudioPlayer- Returns:
- true if the song was played to the end.
-
getVolume
public float getVolume()
Description copied from interface:AudioPlayerReturns the volume.- Specified by:
getVolumein interfaceAudioPlayer- Returns:
- value between -1 and 1, negative values equating to silence
-
setVolume
public void setVolume(float volume) throws IllegalArgumentExceptionDescription copied from interface:AudioPlayerChanges the volume.- Specified by:
setVolumein interfaceAudioPlayer- Parameters:
volume- value between -1 and 1, negative values equating to silence. A volume value outside the valid range will lead to an IllegalArgumentException- Throws:
IllegalArgumentException- if the value is outside the valid range
-
setMuted
public void setMuted(boolean muted)
Description copied from interface:AudioPlayerUn/mutes this player.- Specified by:
setMutedin interfaceAudioPlayer- Parameters:
muted- muted
-
isMuted
public boolean isMuted()
Description copied from interface:AudioPlayerIndicates whether the player is muted.- Specified by:
isMutedin interfaceAudioPlayer- Returns:
- true to false
-
setReplayGainType
public void setReplayGainType(ReplayGain.Type type)
Description copied from interface:AudioPlayerAsks the player to respect the given kind of replay gain. Some players may ignore this property.- Specified by:
setReplayGainTypein interfaceAudioPlayer- Parameters:
type- type
-
getReplayGainType
public ReplayGain.Type getReplayGainType()
Description copied from interface:AudioPlayerCurrently configured type of replay gain.- Specified by:
getReplayGainTypein interfaceAudioPlayer- Returns:
- replay gain type
-
next
public void next()
Description copied from interface:PlayListPlayerMove to next song. If playback was active, keep on playing.- Specified by:
nextin interfacePlayListPlayer
-
previous
public void previous()
Description copied from interface:PlayListPlayerMove to previous song. If playback was active, keep on playing.- Specified by:
previousin interfacePlayListPlayer
-
play
public void play()
Description copied from interface:AudioPlayerStarts playback.- Specified by:
playin interfaceAudioPlayer
-
pause
public void pause()
Description copied from interface:AudioPlayerStops playback.- Specified by:
pausein interfaceAudioPlayer
-
playPause
public void playPause()
Description copied from interface:AudioPlayerStarts playback, if song is paused, otherwise pauses playback.- Specified by:
playPausein interfaceAudioPlayer
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
- Specified by:
addPropertyChangeListenerin interfaceAudioPlayer
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
- Specified by:
removePropertyChangeListenerin interfaceAudioPlayer
-
addPropertyChangeListener
public void addPropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
- Specified by:
addPropertyChangeListenerin interfaceAudioPlayer
-
removePropertyChangeListener
public void removePropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
- Specified by:
removePropertyChangeListenerin interfaceAudioPlayer
-
addAudioPlayerListener
public void addAudioPlayerListener(AudioPlayerListener listener)
- Specified by:
addAudioPlayerListenerin interfaceAudioPlayer
-
removeAudioPlayerListener
public void removeAudioPlayerListener(AudioPlayerListener listener)
- Specified by:
removeAudioPlayerListenerin interfaceAudioPlayer
-
finalize
protected void finalize() throws Throwable
-
close
public void close()
Description copied from interface:AudioPlayerCloses the audio file and associated player resources.- Specified by:
closein interfaceAudioPlayer
-
-