Class MusicPlayer

java.lang.Object
fr.formiko.usuel.media.audio.MusicPlayer
All Implemented Interfaces:
AudioInterface

public class MusicPlayer extends Object implements AudioInterface
to listen music.
It use audioPlayer & make sur than only 1 is running at the same time.
Author:
Hydrolien
  • Field Details

    • audioPlayer

      private AudioPlayer audioPlayer
    • musicPaused

      private boolean musicPaused
    • nextMusics

      private GString nextMusics
    • availableMusics

      private GString availableMusics
    • curentMusic

      private String curentMusic
  • Constructor Details

    • MusicPlayer

      public MusicPlayer()
  • Method Details

    • getPath

      public String getPath()
    • play

      public void play()
      Play next music.
      Specified by:
      play in interface AudioInterface
    • pause

      public void pause()
      Pause curent music.
      Specified by:
      pause in interface AudioInterface
      See Also:
      resume()
    • resume

      public void resume()
      Resume curent music.
      Specified by:
      resume in interface AudioInterface
      See Also:
      pause()
    • stop

      public void stop()
      Stop curent music.
      We need play() to start music again.
      Specified by:
      stop in interface AudioInterface
    • addNextMusic

      public void addNextMusic(String music, boolean first)
      Add next music to list of music to play.
      Parameters:
      music - name of the music.
      first - If true add music at the head of the list. Else add at the end.
    • next

      public void next()
      Play next music.
    • iniAvailableMusics

      public void iniAvailableMusics()
      Initialize availables musics list.
    • getNextMusic

      private String getNextMusic()
      return a music.
      If there is a next music, it return next Music. If next music list is empty, it return a random music.
    • getRandomMusic

      private String getRandomMusic()
      return a random music.
      If the list of availableMusics is null, it create it.
      It should avoid to play same music than curent one by gettin a new random 1 (10 try).