Class LinePlayer
java.lang.Object
net.avadeaux.klipspringer.codec.LinePlayer
- All Implemented Interfaces:
Closeable,AutoCloseable,Device.Player,PcmWriter
Audio output adapter for writing to a
SourceDataLine.-
Nested Class Summary
Nested classes/interfaces inherited from interface net.avadeaux.klipspringer.codec.Device.Player
Device.Player.Factory -
Constructor Summary
ConstructorsConstructorDescriptionLinePlayer(SourceDataLine line, boolean paused) Constructs a player for the given line. -
Method Summary
Modifier and TypeMethodDescriptionintGets an estimate of how many frames are currently buffered, waiting to be played.booleancanPause()Returns true.voidclose()SeeCloseable.close().voiddrain()Waits for player to send on any data it has buffered up and closes it.format()Gets the audio expected by the player.layout()Gets the bit layout expected by the player.voidpause()Pauses, if this optional operation is supported, audio playback at the destination.voidunpause()Resumes paused audio playback at the destination.booleanwrite(ByteBuffer data) Writes a block of audio data inthe bit layout expectedby the player.
-
Constructor Details
-
LinePlayer
Constructs a player for the given line. Opens the line if not already open, and starts it unless the paused parameter is true.- Throws:
IOException
-
-
Method Details
-
format
Description copied from interface:Device.PlayerGets the audio expected by the player.- Specified by:
formatin interfaceDevice.Player
-
layout
Description copied from interface:Device.PlayerGets the bit layout expected by the player. If the player is produced by aFactory, the layout should match the value returned byDevice.Player.Factory.layout(PcmFormat), and if the player is associated with a device, this should match what is returned byDevice.layout(PcmFormat). Default returnsDevice.BitLayout.LSB. Default returnsDevice.BitLayout.LSB.- Specified by:
layoutin interfaceDevice.Player
-
write
Description copied from interface:Device.PlayerWrites a block of audio data inthe bit layout expectedby the player. For most players, it makes sense to always return true, since players do not usually have a limit on the stream.- Specified by:
writein interfaceDevice.Player- Specified by:
writein interfacePcmWriter- Throws:
IOException
-
bufferedFrames
public int bufferedFrames()Description copied from interface:Device.PlayerGets an estimate of how many frames are currently buffered, waiting to be played. Default returns zero.- Specified by:
bufferedFramesin interfaceDevice.Player
-
canPause
-
pause
public void pause()Description copied from interface:Device.PlayerPauses, if this optional operation is supported, audio playback at the destination. Pausing during write may have the effect that write returns false, with the buffer position set to where writing stopped. If already in paused state, this method does nothing. Default implementation throwsUnsupportedOperationException.- Specified by:
pausein interfaceDevice.Player
-
unpause
public void unpause()Description copied from interface:Device.PlayerResumes paused audio playback at the destination. If already in playback state, or if pausing is not supported, this method does nothing (the default).- Specified by:
unpausein interfaceDevice.Player
-
drain
public void drain()Description copied from interface:Device.PlayerWaits for player to send on any data it has buffered up and closes it. Default implementation callsPcmWriter.close()immediately.- Specified by:
drainin interfaceDevice.Player
-
close
-