Package com.tagtraum.audiokern
Interface AudioPlayer
-
- All Known Subinterfaces:
PlayListPlayer
- All Known Implementing Classes:
AVPlayer
,CompositePlayer
,InternalPlayer
,ITunesPlayerComponent
,JavaPlayer
,Player
public interface AudioPlayer
Audio player.- Author:
- Hendrik Schreiber
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addAudioPlayerListener(AudioPlayerListener listener)
void
addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
void
addPropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
void
close()
Closes the audio file and associated player resources.void
fastForward()
Plays the file forward at accelerated speed.AudioDevice
getAudioDevice()
Current audio device.long
getDuration()
Duration of the song in ms.ReplayGain.Type
getReplayGainType()
Currently configured type of replay gain.AudioSong
getSong()
Returns the currently opened song.long
getTime()
Returns the current time in ms.float
getVolume()
Returns the volume.boolean
isDone()
True, if the song was played to the end.boolean
isMuted()
Indicates whether the player is muted.boolean
isPaused()
Indicates whether the song is currently playing.void
open(AudioSong song)
Opens a song.void
pause()
Stops playback.void
play()
Starts playback.void
playPause()
Starts playback, if song is paused, otherwise pauses playback.void
removeAudioPlayerListener(AudioPlayerListener listener)
void
removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
void
removePropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
void
reset()
Positions the player at the beginning of the file.void
setAudioDevice(AudioDevice audioDevice)
Sets the desired audio device.void
setMuted(boolean muted)
Un/mutes this player.void
setReplayGainType(ReplayGain.Type type)
Asks the player to respect the given kind of replay gain.void
setTime(long time)
Sets the current time in ms.void
setVolume(float volume)
Changes the volume.
-
-
-
Method Detail
-
setAudioDevice
void setAudioDevice(AudioDevice audioDevice) throws IllegalArgumentException
Sets the desired audio device.- Parameters:
audioDevice
- audio device- Throws:
IllegalArgumentException
- if the device is not supported
-
getAudioDevice
AudioDevice getAudioDevice()
Current audio device.- Returns:
- currently used audio device
-
getSong
AudioSong getSong()
Returns the currently opened song.- Returns:
- currently opened song
-
open
void open(AudioSong song) throws IOException
- Parameters:
song
- song- Throws:
IOException
- if the song cannot be opened
-
play
void play()
Starts playback.
-
pause
void pause()
Stops playback.
-
playPause
void playPause()
Starts playback, if song is paused, otherwise pauses playback.
-
fastForward
void fastForward()
Plays the file forward at accelerated speed.
-
close
void close()
Closes the audio file and associated player resources.
-
reset
void reset()
Positions the player at the beginning of the file. Equivalent to callingsetTime(long)
with 0 as argument.- See Also:
setTime(long)
-
getTime
long getTime()
Returns the current time in ms.- Returns:
- current time in ms
-
setTime
void setTime(long time) throws IllegalArgumentException
Sets the current time in ms.- 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:
reset()
,getDuration()
-
getDuration
long getDuration()
Duration of the song in ms.- Returns:
- the overall duration of the song in ms.
-
isDone
boolean isDone()
True, if the song was played to the end.- Returns:
- true if the song was played to the end.
-
isPaused
boolean isPaused()
Indicates whether the song is currently playing.- Returns:
- false if the song is playing
-
getVolume
float getVolume()
Returns the volume.- Returns:
- value between -1 and 1, negative values equating to silence
-
setVolume
void setVolume(float volume) throws IllegalArgumentException
Changes the volume.- 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
void setMuted(boolean muted)
Un/mutes this player.- Parameters:
muted
- muted
-
isMuted
boolean isMuted()
Indicates whether the player is muted.- Returns:
- true to false
-
setReplayGainType
void setReplayGainType(ReplayGain.Type type)
Asks the player to respect the given kind of replay gain. Some players may ignore this property.- Parameters:
type
- type
-
getReplayGainType
ReplayGain.Type getReplayGainType()
Currently configured type of replay gain.- Returns:
- replay gain type
-
addPropertyChangeListener
void addPropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
-
removePropertyChangeListener
void removePropertyChangeListener(PropertyChangeListener propertyChangeListener)
-
addPropertyChangeListener
void addPropertyChangeListener(PropertyChangeListener propertyChangeListener)
-
removePropertyChangeListener
void removePropertyChangeListener(String propertyName, PropertyChangeListener propertyChangeListener)
-
addAudioPlayerListener
void addAudioPlayerListener(AudioPlayerListener listener)
-
removeAudioPlayerListener
void removeAudioPlayerListener(AudioPlayerListener listener)
-
-