Class MP3Player

java.lang.Object
java.lang.Thread
org.sm.smtools.util.MP3Player
All Implemented Interfaces:
Runnable

public final class MP3Player extends Thread
The MP3Player class is a helper class for the JLayer framework.

When playing a sound file or stream, the application's execution can be blocked, or it the playing can be delegated to a non-blocking thread.

Note that a valid I18NL10N database must be available!

Note that this class cannot be subclassed!

Version:
06/08/2019
Author:
Sven Maerivoet
  • Constructor Details

  • Method Details

    • close

      public void close()
      Closes the player.
    • run

      public void run()
      The Thread's run() method.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • play

      public void play(MP3Player.EPlaying playing) throws SoundPlayingException
      Starts playing a loaded sound file or stream.
      Parameters:
      playing - specifies whether or not the application's execution should be blocked when playing the sound
      Throws:
      SoundPlayingException - when an exception occurs during the sound playing
    • enableSystemSounds

      public static void enableSystemSounds()
      Enables the playing of system sounds.
    • disableSystemSounds

      public static void disableSystemSounds()
      Disables the playing of system sounds.
    • systemSoundsEnabled

      public static boolean systemSoundsEnabled()
      Returns whether or not system sounds are enabled.
      Returns:
      true if system sounds are enabled, false otherwise
    • playSystemSound

      public static void playSystemSound(String soundFilename)
      Plays a specified system sound.

      Note that the application is not blocked.

      Parameters:
      soundFilename - the filename of the system sound to play
    • playSystemSound

      public static void playSystemSound(String soundFilename, MP3Player.EPlaying playing)
      Plays a specified system sound.
      Parameters:
      soundFilename - the filename of the system sound to play
      playing - specifies whether or not the application's execution should be blocked when playing the sound