diff --git a/pom.xml b/pom.xml
index e45147d..5fdf03f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,6 +14,11 @@
5.10.2
+
+ org.openjfx
+ javafx-media
+ 21
+
org.openjfx
javafx-controls
diff --git a/src/main/java/sbu/javafx/MusicController.java b/src/main/java/sbu/javafx/MusicController.java
index d21cb5a..98596b8 100644
--- a/src/main/java/sbu/javafx/MusicController.java
+++ b/src/main/java/sbu/javafx/MusicController.java
@@ -6,6 +6,10 @@ import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.VBox;
+import javafx.fxml.FXML;
+import javafx.scene.media.Media;
+import javafx.scene.media.MediaPlayer;
+
public class MusicController {
@@ -13,20 +17,90 @@ public class MusicController {
//TODO: Implement the logic to play a song. This method should update the UI to show which song is currently playing.
- public Button button ;
- public void OnAction()
+ private Button PlayButton ;
+ private MediaPlayer mediaPlayer;
+ private boolean IsPlay = false ;
+ @FXML
+ public void Play( Button btn)
{
- System.out.println("click on submit");
+ if (!IsPlay)
+ {
+ btn.setText("stop");
+ IsPlay = true ;
+
+ }
+ else if (IsPlay)
+ {
+ btn.setText("play");
+ IsPlay = false ;
+ }
}
@FXML
- public void handlePlayAction() {
+ public void handlePlayAction(ActionEvent event) {
+ String songPath = "";
+ Button button =
+ (Button) event.getSource();
//Update labels, change button icons, etc.
- }
+ if(button.getId().equals("1")) {
+ if (!IsPlay) {
+ songPath = "/1.mp3";
+ Play( button);
+
+ }
+ else
+ {
+ mediaPlayer.stop();
+ Play( button);
+
+
+
+ }
+ }
+
+ else if(button.getId().equals("2")) {
+
+ if (!IsPlay) {
+ songPath = "/2.mp3";
+ Play( button);
+
+ }
+ else
+ {
+ mediaPlayer.stop();
+ Play( button);
+
+ }
+ }
+
+ else if(button.getId().equals("3")) {
+
+ if (!IsPlay) {
+ songPath = "/3.mp3";
+ Play( button);
+
+ }
+ else
+ {
+ mediaPlayer.stop();
+ Play(button);
+
+ }
+ }
+
+ Media media = new Media(
+ getClass().getResource(songPath)
+ .toExternalForm()
+ );
+
+ mediaPlayer = new MediaPlayer(media);
+ mediaPlayer.play();
+ }
//TODO: Logic to add a specific song to the user's playlist.
public void addToPlaylist(String songName) {
//Add the song to a list or update a ListView.
+
}
// TODO:This method should open a new window or change the current scene to display the "Playlist" page.
diff --git a/src/main/resources/1.mp3 b/src/main/resources/1.mp3
new file mode 100644
index 0000000..27df216
Binary files /dev/null and b/src/main/resources/1.mp3 differ
diff --git a/src/main/resources/2.mp3 b/src/main/resources/2.mp3
new file mode 100644
index 0000000..735f818
Binary files /dev/null and b/src/main/resources/2.mp3 differ
diff --git a/src/main/resources/3.mp3 b/src/main/resources/3.mp3
new file mode 100644
index 0000000..9f416e3
Binary files /dev/null and b/src/main/resources/3.mp3 differ
diff --git a/src/main/resources/AlbumArtSmall.jpg b/src/main/resources/AlbumArtSmall.jpg
new file mode 100644
index 0000000..f88f72b
Binary files /dev/null and b/src/main/resources/AlbumArtSmall.jpg differ
diff --git a/src/main/resources/Folder.jpg b/src/main/resources/Folder.jpg
new file mode 100644
index 0000000..117b86b
Binary files /dev/null and b/src/main/resources/Folder.jpg differ
diff --git a/src/main/resources/sbu/javafx/App-view.fxml b/src/main/resources/sbu/javafx/App-view.fxml
index acd892b..7fbf0bc 100644
--- a/src/main/resources/sbu/javafx/App-view.fxml
+++ b/src/main/resources/sbu/javafx/App-view.fxml
@@ -1,12 +1,15 @@
+
+
-
+
+
-
-
-
-
-
+
+
+
+
+
+
+
@@ -61,12 +84,21 @@
-
-
-
-
-
+
+
+
+
+
+
@@ -83,5 +115,5 @@
-
+