Interface Device.Player
- All Superinterfaces:
AutoCloseable,Closeable,PcmWriter
- All Known Subinterfaces:
AudioStream
- All Known Implementing Classes:
Alsa.Player,ExternalEncodedStream,FlacStream,LameStream,LinePlayer,VorbisStream
- Enclosing interface:
Device
PCM writer with optional methods to control real-time playing where applicanle.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfacePlayer factory interface. -
Method Summary
Modifier and TypeMethodDescriptiondefault intGets an estimate of how many frames are currently buffered, waiting to be played.default booleancanPause()Checks ifpause()is supported.default voiddrain()Waits for player to send on any data it has buffered up and closes it.format()Gets the audio expected by the player.default Device.BitLayoutlayout()Gets the bit layout expected by the player.default voidpause()Pauses, if this optional operation is supported, audio playback at the destination.default voidunpause()Resumes paused audio playback at the destination.booleanwrite(ByteBuffer data) Writes a block of audio data inthe bit layout expectedby the player.
-
Method Details
-
format
PcmFormat format()Gets the audio expected by the player. -
layout
Gets 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. -
write
Writes 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 interfacePcmWriter- Throws:
IOException
-
bufferedFrames
Gets an estimate of how many frames are currently buffered, waiting to be played. Default returns zero.- Throws:
IOException
-
canPause
default boolean canPause()Checks ifpause()is supported. Default returns false. -
pause
Pauses, 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.- Throws:
IOException
-
unpause
Resumes paused audio playback at the destination. If already in playback state, or if pausing is not supported, this method does nothing (the default).- Throws:
IOException
-
drain
Waits for player to send on any data it has buffered up and closes it. Default implementation callsPcmWriter.close()immediately.- Throws:
IOException
-