Class JavaSoundPlayer

  • All Implemented Interfaces:
    SoundPlayer

    class JavaSoundPlayer
    extends java.lang.Object
    implements SoundPlayer
    Legacy sound player based on the Java Sound API. Used on platforms where Java FX is not yet available. It supports only WAV files.
    Since:
    12328
    • Constructor Detail

    • Method Detail

      • play

        public void play​(AudioPlayer.Execute command,
                         AudioPlayer.State stateChange,
                         java.net.URL playingUrl)
                  throws AudioException,
                         java.io.IOException
        Description copied from interface: SoundPlayer
        Ask player to play a new media.
        Specified by:
        play in interface SoundPlayer
        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

        public void pause​(AudioPlayer.Execute command,
                          AudioPlayer.State stateChange,
                          java.net.URL playingUrl)
                   throws AudioException,
                          java.io.IOException
        Description copied from interface: SoundPlayer
        Ask player to pause the current playing media.
        Specified by:
        pause in interface SoundPlayer
        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

        public boolean playing​(AudioPlayer.Execute command)
                        throws AudioException,
                               java.io.IOException,
                               java.lang.InterruptedException
        Description copied from interface: SoundPlayer
        Method called when a media is being played.
        Specified by:
        playing in interface SoundPlayer
        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

        public double position()
        Description copied from interface: SoundPlayer
        Returns the media playback position, in seconds.
        Specified by:
        position in interface SoundPlayer
        Returns:
        the media playback position, in seconds
      • speed

        public double speed()
        Description copied from interface: SoundPlayer
        Returns the media playback speed ratio.
        Specified by:
        speed in interface SoundPlayer
        Returns:
        the media playback speed ratio