Interface SoundPlayer

  • All Known Implementing Classes:
    JavaSoundPlayer

    public interface SoundPlayer
    Sound player interface. Implementations can be backed up by Java Sound API or Java FX Media API.
    Since:
    12328
    • Method Detail

      • play

        void play​(AudioPlayer.Execute command,
                  AudioPlayer.State stateChange,
                  java.net.URL playingUrl)
           throws AudioException,
                  java.io.IOException
        Ask player to play a new media.
        Parameters:
        command - Command containing media information
        stateChange - the previous state
        playingUrl - the currently playing URL, if any
        Throws:
        AudioException - if an audio error occurs
        java.io.IOException - if an I/O error occurs
      • pause

        void pause​(AudioPlayer.Execute command,
                   AudioPlayer.State stateChange,
                   java.net.URL playingUrl)
            throws AudioException,
                   java.io.IOException
        Ask player to pause the current playing media.
        Parameters:
        command - Command containing media information
        stateChange - the previous state
        playingUrl - the currently playing URL, if any
        Throws:
        AudioException - if an audio error occurs
        java.io.IOException - if an I/O error occurs
      • playing

        boolean playing​(AudioPlayer.Execute command)
                 throws AudioException,
                        java.io.IOException,
                        java.lang.InterruptedException
        Method called when a media is being played.
        Parameters:
        command - Command containing media information
        Returns:
        true if the playing call was blocking, and the playback is finished when this method returns
        Throws:
        AudioException - if an audio error occurs
        java.io.IOException - if an I/O error occurs
        java.lang.InterruptedException - if the play is interrupted
      • position

        double position()
        Returns the media playback position, in seconds.
        Returns:
        the media playback position, in seconds
      • speed

        double speed()
        Returns the media playback speed ratio.
        Returns:
        the media playback speed ratio
      • addAudioListener

        void addAudioListener​(AudioListener listener)
        Adds a listener that will be notified of audio playback events.
        Parameters:
        listener - audio listener