Class AudioApi

java.lang.Object
uk.co.caprica.vlcj.player.base.AudioApi
All Implemented Interfaces:
EqualizerListener

public final class AudioApi extends Object implements EqualizerListener
Behaviour pertaining to media player audio.
  • Method Details

    • setOutput

      public boolean setOutput(String output)
      Set the desired audio output.

      The change will not be applied until the media player has been stopped and then played again.

      The output name comes from AudioApi.audioOutputs().

      Parameters:
      output - name of the desired audio output
      Returns:
      true if the output was successfully set, otherwise false
    • outputDevice

      public String outputDevice()
      Get the identifier of the current audio output device, if available.

      To return a useful value, an audio output must be active (i.e. the media must be playing).

      Returns:
      identifier of the current audio output device, or null if not available
    • setOutputDevice

      public void setOutputDevice(String output, String outputDeviceId)
      Set the desired audio output device.

      The change will not be applied until the media player has been stopped and then played again.

      The output name comes from AudioApi.audioOutputs().

      The device id comes from the AudioDevice.getDeviceId() returned by AudioApi.audioOutputs().

      Parameters:
      output - name of the desired audio output
      outputDeviceId - id of the desired audio output device
    • outputDevices

      public List<AudioDevice> outputDevices()
      Get the available audio devices for the media player audio output.
      Returns:
      list of audio devices, may be empty but not null
    • mute

      public boolean mute()
      Toggle volume mute.
      Returns:
      mute true if the volume is muted, false if the volume is not muted
    • setMute

      public void setMute(boolean mute)
      Mute or un-mute the volume.
      Parameters:
      mute - true to mute the volume, false to un-mute it
    • isMute

      public boolean isMute()
      Test whether or not the volume is currently muted.
      Returns:
      mute true if the volume is muted, false if the volume is not muted
    • volume

      public int volume()
      Get the current volume.
      Returns:
      volume, a percentage of full volume in the range 0 to 200
    • setVolume

      public boolean setVolume(int volume)
      Set the volume.

      The volume is actually a percentage of full volume, setting a volume over 100 may cause audible distortion.

      Parameters:
      volume - volume, a percentage of full volume in the range 0 to 200
      Returns:
      true if successful; false on error
    • channel

      public AudioChannel channel()
      Get the current audio channel. For channel values see AudioChannel.
      Returns:
      audio channel
    • setChannel

      public boolean setChannel(AudioChannel channel)
      Set the audio channel. For channel values see AudioChannel.
      Parameters:
      channel - channel
      Returns:
      true if successful; false on error
    • delay

      public long delay()
      Get the audio delay.
      Returns:
      audio delay, in microseconds
    • setDelay

      public void setDelay(long delay)
      Set the audio delay.

      The audio delay is set for the current item only and will be reset to zero each time the media changes.

      Parameters:
      delay - desired audio delay, in microseconds
    • equalizer

      public Equalizer equalizer()
      Get the current audio equalizer.
      Returns:
      equalizer, or null if there is no active equalizer
    • setEqualizer

      public void setEqualizer(Equalizer equalizer)
      Set the audio equalizer.
      Parameters:
      equalizer - equalizer, or null to disable the audio equalizer
    • equalizerChanged

      public final void equalizerChanged(Equalizer equalizer)
      Description copied from interface: EqualizerListener
      The state of the equalizer changed.
      Specified by:
      equalizerChanged in interface EqualizerListener
      Parameters:
      equalizer - the equalizer that changed
    • trackCount

      public int trackCount()
      Get the number of available audio tracks.
      Returns:
      track count
    • track

      public int track()
      Get the current audio track.
      Returns:
      track identifier, see trackDescriptions()
    • setTrack

      public int setTrack(int track)
      Set a new audio track to play.

      The track identifier must be one of those returned by trackDescriptions().

      Audio can be disabled by passing here the identifier of the track with a description of "Disable".

      There is no guarantee that the available track identifiers go in sequence from zero up to trackCount()-1. The trackDescriptions() method should always be used to ascertain the available track identifiers.

      Parameters:
      track - track identifier
      Returns:
      current audio track identifier
    • trackDescriptions

      public List<TrackDescription> trackDescriptions()
      Get the audio track descriptions.

      The media must be playing before this information is available.

      Returns:
      list of descriptions, may be empty but will never be null
    • callback

      public void callback(String format, int rate, int channels, AudioCallback audioCallback)
      Enable audio callbacks and set the component used to process the audio samples.

      The callback will not manage audio volume.

      Parameters:
      format - audio buffer format
      rate - audio buffer bit-rate
      channels - number of audio channels
      audioCallback - component that will process the audio samples
      See Also:
    • callback

      public void callback(String format, int rate, int channels, AudioCallback audioCallback, boolean manageVolume)
      Enable audio callbacks and set the component used to process the audio samples.
      Parameters:
      format - audio buffer format
      rate - audio buffer bit-rate
      channels - number of audio channels
      audioCallback - component that will process the audio samples
      manageVolume - true if the callback will manage audio volume; false if not