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

public static interface Device.Player extends PcmWriter
PCM writer with optional methods to control real-time playing where applicanle.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Player factory interface.
  • Method Summary

    Modifier and Type
    Method
    Description
    default int
    Gets an estimate of how many frames are currently buffered, waiting to be played.
    default boolean
    Checks if pause() is supported.
    default void
    Waits for player to send on any data it has buffered up and closes it.
    Gets the audio expected by the player.
    Gets the bit layout expected by the player.
    default void
    Pauses, if this optional operation is supported, audio playback at the destination.
    default void
    Resumes paused audio playback at the destination.
    boolean
    Writes a block of audio data in the bit layout expected by the player.

    Methods inherited from interface net.avadeaux.klipspringer.codec.PcmWriter

    close
  • Method Details

    • format

      PcmFormat format()
      Gets the audio expected by the player.
    • layout

      default Device.BitLayout layout()
      Gets the bit layout expected by the player. If the player is produced by a Factory, the layout should match the value returned by Device.Player.Factory.layout(PcmFormat), and if the player is associated with a device, this should match what is returned by Device.layout(PcmFormat). Default returns Device.BitLayout.LSB. Default returns Device.BitLayout.LSB.
    • write

      boolean write(ByteBuffer data) throws IOException
      Writes a block of audio data in the bit layout expected by 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:
      write in interface PcmWriter
      Throws:
      IOException
    • bufferedFrames

      default int bufferedFrames() throws IOException
      Gets an estimate of how many frames are currently buffered, waiting to be played. Default returns zero.
      Throws:
      IOException
    • canPause

      default boolean canPause()
      Checks if pause() is supported. Default returns false.
    • pause

      default void pause() throws IOException
      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 throws UnsupportedOperationException.
      Throws:
      IOException
    • unpause

      default void unpause() throws IOException
      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

      default void drain() throws IOException
      Waits for player to send on any data it has buffered up and closes it. Default implementation calls PcmWriter.close() immediately.
      Throws:
      IOException