回答編集履歴
1
コードを追加した。
test
CHANGED
@@ -7,3 +7,113 @@
|
|
7
7
|
JDK 8u45
|
8
8
|
|
9
9
|
ですが、vhzfsqckさんの環境はどの様なバージョンでしょうか?
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
###動作確認に使ったソースコード
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
```lang-java
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
public class App extends Application {
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
@Override
|
26
|
+
|
27
|
+
public void start(Stage primaryStage) {
|
28
|
+
|
29
|
+
Group root = new Group();
|
30
|
+
|
31
|
+
Scene scene = new Scene(root, 500, 200);
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
Media pick = new Media(this.getClass().getResource("sample.mp3").toString());
|
36
|
+
|
37
|
+
MediaPlayer player = new MediaPlayer(pick);
|
38
|
+
|
39
|
+
MediaView mediaView = new MediaView(player);
|
40
|
+
|
41
|
+
((Group) scene.getRoot()).getChildren().add(mediaView);
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
HBox hbox = new HBox();
|
46
|
+
|
47
|
+
hbox.setAlignment(Pos.CENTER);
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
Button seekButton = new Button("Seek");
|
52
|
+
|
53
|
+
seekButton.setOnAction(event -> {
|
54
|
+
|
55
|
+
player.seek(Duration.millis(5000.0));
|
56
|
+
|
57
|
+
});
|
58
|
+
|
59
|
+
hbox.getChildren().add(seekButton);
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
Button playButton = new Button("Play");
|
64
|
+
|
65
|
+
playButton.setOnAction(event -> {
|
66
|
+
|
67
|
+
player.play();
|
68
|
+
|
69
|
+
});
|
70
|
+
|
71
|
+
hbox.getChildren().add(playButton);
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
Button pauseButton = new Button("Pause");
|
76
|
+
|
77
|
+
pauseButton.setOnAction(event -> {
|
78
|
+
|
79
|
+
player.pause();
|
80
|
+
|
81
|
+
});
|
82
|
+
|
83
|
+
hbox.getChildren().add(pauseButton);
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
Button stopButton = new Button("Stop");
|
88
|
+
|
89
|
+
stopButton.setOnAction(event -> {
|
90
|
+
|
91
|
+
player.stop();
|
92
|
+
|
93
|
+
});
|
94
|
+
|
95
|
+
hbox.getChildren().add(stopButton);
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
((Group) scene.getRoot()).getChildren().add(hbox);
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
primaryStage.setTitle("Media Player");
|
104
|
+
|
105
|
+
primaryStage.setScene(scene);
|
106
|
+
|
107
|
+
primaryStage.show();
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
public static void main(String[] args) {
|
112
|
+
|
113
|
+
launch(args);
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
```
|