Package fr.formiko.usuel.media.audio
Class MusicPlayer
java.lang.Object
fr.formiko.usuel.media.audio.MusicPlayer
- All Implemented Interfaces:
AudioInterface
to listen music.
It use audioPlayer & make sur than only 1 is running at the same time.
It use audioPlayer & make sur than only 1 is running at the same time.
- Author:
- Hydrolien
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AudioPlayer
private GString
private String
private boolean
private GString
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addNextMusic(String music, boolean first)
Add next music to list of music to play.private String
return a music.getPath()
private String
return a random music.void
Initialize availables musics list.void
next()
Play next music.void
pause()
Pause curent music.void
play()
Play next music.void
resume()
Resume curent music.void
stop()
Stop curent music.
-
Field Details
-
audioPlayer
-
musicPaused
private boolean musicPaused -
nextMusics
-
availableMusics
-
curentMusic
-
-
Constructor Details
-
MusicPlayer
public MusicPlayer()
-
-
Method Details
-
getPath
-
play
public void play()Play next music.- Specified by:
play
in interfaceAudioInterface
-
pause
public void pause()Pause curent music.- Specified by:
pause
in interfaceAudioInterface
- See Also:
resume()
-
resume
public void resume()Resume curent music.- Specified by:
resume
in interfaceAudioInterface
- See Also:
pause()
-
stop
public void stop()Stop curent music.
We need play() to start music again.- Specified by:
stop
in interfaceAudioInterface
-
addNextMusic
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
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
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).
-