Class BGMManager

java.lang.Object
util.BGMManager

public class BGMManager extends Object
A simple manager for playing background music (BGM) in a JavaFX application.

Supports playing, looping, and stopping a single BGM track at a time.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static javafx.scene.media.MediaPlayer
     
    private static final double
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    play(String resourcePath)
    Plays a BGM track from the given resource path.
    static void
    Stops the currently playing BGM, if any.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • currentPlayer

      private static javafx.scene.media.MediaPlayer currentPlayer
    • VOLUME

      private static final double VOLUME
      See Also:
  • Constructor Details

    • BGMManager

      public BGMManager()
  • Method Details

    • play

      public static void play(String resourcePath)
      Plays a BGM track from the given resource path. If another track is already playing, it stops it first.
      Parameters:
      resourcePath - the path to the music file relative to the classpath
    • stop

      public static void stop()
      Stops the currently playing BGM, if any.