Package com.tagtraum.audiokern.player
Class JavaPlayer
- java.lang.Object
-
- com.tagtraum.audiokern.player.JavaPlayer
-
- All Implemented Interfaces:
AudioPlayer
public class JavaPlayer extends Object implements AudioPlayer
Plays anAudioSongusing standard Java APIs.- Author:
- Hendrik Schreiber
-
-
Constructor Summary
Constructors Constructor Description JavaPlayer()JavaPlayer(ExecutorService serializer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAudioPlayerListener(AudioPlayerListener listener)voidaddPropertyChangeListener(PropertyChangeListener propertyChangeListener)voidaddPropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)voidclose()Closes the audio file and associated player resources.voidfastForward()Plays the file forward at accelerated speed.protected voidfinalize()AudioDevicegetAudioDevice()Current audio device.floatgetBufferSizeInSeconds()Buffer size.longgetDuration()Duration of the song in ms.ReplayGain.TypegetReplayGainType()Currently configured type of replay gain.AudioSonggetSong()Returns the currently opened song.longgetTime()Returns the current time in ms.floatgetVolume()Returns the volume.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.voidopen(AudioSong song)Opens a song.voidpause()Stops playback.voidplay()Starts playback.voidplayPause()Starts playback, if song is paused, otherwise pauses playback.voidremoveAudioPlayerListener(AudioPlayerListener listener)voidremovePropertyChangeListener(PropertyChangeListener propertyChangeListener)voidremovePropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)voidreset()Positions the player at the beginning of the file.voidsetAudioDevice(AudioDevice audioDevice)Sets the desired audio device.voidsetBufferSizeInSeconds(float bufferSizeInSeconds)Buffer size.voidsetMuted(boolean muted)Un/mutes this player.voidsetReplayGainType(ReplayGain.Type type)Asks the player to respect the given kind of replay gain.voidsetTime(long time)Sets the current time in ms.voidsetVolume(float volume)Changes the volume.StringtoString()
-
-
-
Constructor Detail
-
JavaPlayer
public JavaPlayer()
-
JavaPlayer
public JavaPlayer(ExecutorService serializer)
-
-
Method Detail
-
getBufferSizeInSeconds
public float getBufferSizeInSeconds()
Buffer size.- Returns:
- buffer size in seconds
-
setBufferSizeInSeconds
public void setBufferSizeInSeconds(float bufferSizeInSeconds)
Buffer size.- Parameters:
bufferSizeInSeconds- buffer size in seconds
-
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
-
getSong
public AudioSong getSong()
Description copied from interface:AudioPlayerReturns the currently opened song.- Specified by:
getSongin interfaceAudioPlayer- Returns:
- currently opened song
-
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
-
playPause
public void playPause()
Description copied from interface:AudioPlayerStarts playback, if song is paused, otherwise pauses playback.- Specified by:
playPausein interfaceAudioPlayer
-
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
-
fastForward
public void fastForward()
Description copied from interface:AudioPlayerPlays the file forward at accelerated speed.- Specified by:
fastForwardin interfaceAudioPlayer
-
close
public void close()
Description copied from interface:AudioPlayerCloses the audio file and associated player resources.- Specified by:
closein 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)
-
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.
-
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
-
setVolume
public void setVolume(float volume)
Description 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
-
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
-
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
-
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)
Description copied from interface:AudioPlayerSets the current time in ms.- Specified by:
setTimein interfaceAudioPlayer- Parameters:
time- time in ms- See Also:
AudioPlayer.reset(),AudioPlayer.getDuration()
-
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
-
-