-
Notifications
You must be signed in to change notification settings - Fork 12
/
MyStage.java
43 lines (34 loc) · 892 Bytes
/
MyStage.java
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
package p4_group_8_repo;
import java.io.File;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.util.Duration;
public class MyStage extends World{
MediaPlayer mediaPlayer;
@Override
public void act(long now) {
}
public MyStage() {
// mediaPlayer.play();
// mediaPlayer.setOnEndOfMedia(new Runnable() {
//
// @Override
// public void run() {
// mediaPlayer.seek(Duration.ZERO);
//
// }
//
// });
// mediaPlayer.play();
}
public void playMusic() {
String musicFile = "src/p4_group_8_repo/Frogger Main Song Theme (loop).mp3";
Media sound = new Media(new File(musicFile).toURI().toString());
mediaPlayer = new MediaPlayer(sound);
mediaPlayer.setCycleCount(MediaPlayer.INDEFINITE);
mediaPlayer.play();
}
public void stopMusic() {
mediaPlayer.stop();
}
}