-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMusicPlayer.java
More file actions
59 lines (48 loc) · 1.6 KB
/
MusicPlayer.java
File metadata and controls
59 lines (48 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/** Context class */
public class MusicPlayer{
private SongLibrary musiclibr;
private MyDisplay displayState;
private boolean isFocus;
public MusicPlayer(SongLibrary musiclib){
this.musiclibr = musiclib;
isFocus = false;
displayState = new FullPlaylistMode(musiclib);
}
/** SwitchMode allows the Client to switch the status, by changing the
* instance of the `private MyDisplay displayState` attribute.
* The attribute `private boolean isFocus` currently holds the value of the
* status that is contained in MusicPlayer. The default can be set
* in the MusicPlayer constructor. At time of writing it's false -
* thus, FullPlaylistMode is the "default" instance.
*
*/
public void switchMode(){
if(this.isFocus){
displayState = new FullPlaylistMode(this.musiclibr);
isFocus = false;
}else{
displayState = new SongFocusMode(this.musiclibr);
isFocus = true;
}
System.out.println("Switching to... " + displayState.getModeTitle());
}
public void playMusic(){
if(musiclibr.getCurrentSong().isPresent()){
displayState.visualize(musiclibr.getCurrentSong().get());
}else{
System.out.println("........");
}
}
public void nextSong(){
if(musiclibr.next().isPresent()){
}else{
System.out.println("........");
}
}
public void prevSong(){
if(musiclibr.previous().isPresent()){
}else{
System.out.println("........");
}
}
}