اضافه کردن دکمه ی قبل و بعد مونده

This commit is contained in:
2026-05-28 21:17:26 +03:30
parent 06fc183025
commit 574ef215ee
3 changed files with 46 additions and 34 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ public class Main extends Application {
controller.musicsListView.getItems().addAll( controller.musicsListView.getItems().addAll(
new Song("Blinding Lights", "The Weeknd","/musics/The-Weeknd-Blinding-Lights-128.mp3"), new Song("Blinding Lights", "The Weeknd","/musics/The-Weeknd-Blinding-Lights-128.mp3"),
new Song("Comme des enfants", "Coert De Pirate","/musics/Coeur-De-Pirate-Comme-des-enfants-128.pm3"), new Song("Comme des enfants", "Coert De Pirate","/musics/Coeur-De-Pirate-Comme-des-enfants-128.mp3"),
new Song("Slow Down", "GRAE", "/musics/GRAE-Slow-Down-128.mp3"), new Song("Slow Down", "GRAE", "/musics/GRAE-Slow-Down-128.mp3"),
new Song("Cigarettes out the Window", "TV Girl", "/music/TV-Girl-Cigarettes-out-the-Window-128.mp3"), new Song("Cigarettes out the Window", "TV Girl", "/music/TV-Girl-Cigarettes-out-the-Window-128.mp3"),
new Song("deja vu", "Olivia Rodirgo", "/musics/Olivia-Rodrigo-deja-vu-320.mp3"), new Song("deja vu", "Olivia Rodirgo", "/musics/Olivia-Rodrigo-deja-vu-320.mp3"),
+28 -6
View File
@@ -11,6 +11,8 @@ import javafx.scene.image.ImageView;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.util.Duration; import javafx.util.Duration;
@@ -38,12 +40,17 @@ public class MusicController {
private boolean isPlaying=false; private boolean isPlaying=false;
private boolean isMute=false; private boolean isMute=false;
private boolean isOpen=false; private boolean isOpen=false;
private boolean isRepeat=false;
private Song currentSong = null; private Song currentSong = null;
ImageView playIcon; ImageView playIcon;
ImageView pauseIcon; ImageView pauseIcon;
ImageView audioIcon; ImageView audioIcon;
ImageView muteIcon; ImageView muteIcon;
String path;
Media media;
MediaPlayer player ;
// TODO: Define your UI components using the @FXML annotation. // TODO: Define your UI components using the @FXML annotation.
@FXML @FXML
@@ -161,11 +168,21 @@ public class MusicController {
} }
public void play(ActionEvent event, Song song){ public void play(ActionEvent event, Song song){
currentSong=song; currentSong=song;
nowPlayingLabel.setText(song.getName()); nowPlayingLabel.setText(song.getName());
if (!isPlaying) if (!isPlaying)
playPause(event); playPause(event);
//کد پخش
// کد پخش موسیقی
path = getClass()
.getResource(song.getPath())
.toExternalForm();
media = new Media(path);
player = new MediaPlayer(media);
player.play();
} }
@FXML @FXML
@@ -173,7 +190,10 @@ public class MusicController {
if(isPlaying){ if(isPlaying){
playPauseBtn.setGraphic(playIcon); playPauseBtn.setGraphic(playIcon);
isPlaying=false; isPlaying=false;
//کد توقف اینجاست چون برای هر توقفی دکمه ی پاز رو میزنیم ولی برای پلی ممکنه از بین آهنگ ها بزنیم
//کد توقف
player.pause();
} }
else{ else{
playPauseBtn.setGraphic(pauseIcon); playPauseBtn.setGraphic(pauseIcon);
@@ -183,11 +203,14 @@ public class MusicController {
@FXML @FXML
public void mute(ActionEvent e){ public void mute(ActionEvent e){
isMute=!isMute;
if(!isMute){ if(!isMute){
audioBtn.setGraphic(audioIcon);
}else{
audioBtn.setGraphic(muteIcon); audioBtn.setGraphic(muteIcon);
player.setVolume(0);
isMute=true;
}else{
audioBtn.setGraphic(audioIcon);
player.setVolume(100);
isMute=false;
} }
} }
@@ -219,7 +242,6 @@ public class MusicController {
if(!isOpen){ if(!isOpen){
// باز کردن پلی‌لیست // باز کردن پلی‌لیست
if(playlistListView.getItems().isEmpty()){ if(playlistListView.getItems().isEmpty()){
Alert alert = new Alert(Alert.AlertType.WARNING); Alert alert = new Alert(Alert.AlertType.WARNING);
+16 -26
View File
@@ -11,11 +11,20 @@
<Insets bottom="10" left="10" right="10" top="10" /> <Insets bottom="10" left="10" right="10" top="10" />
</padding> </padding>
<!-- دکمه تغییر تم --> <!-- دکمه تغییر تم و open playlist -->
<HBox alignment="CENTER_LEFT" spacing="10"> <HBox alignment="CENTER_LEFT" spacing="10">
<Button fx:id="themeToggleBtn" text=" Dark" onAction="#toggleTheme"
style="-fx-background-color: #555; -fx-text-fill: white; -fx-background-radius: 10px; -fx-padding: 5 10;" /> <Button fx:id="themeToggleBtn"
<Region HBox.hgrow="ALWAYS" /> <!-- این فضا رو پر میکنه تا دکمه سمت چپ بمونه --> text="Dark"
onAction="#toggleTheme"/>
<Region HBox.hgrow="ALWAYS"/>
<Button fx:id="openPlaylistBtn"
onAction="#openPlaylistWindow"
text="Open Playlist"
style="-fx-background-radius: 15px;" />
</HBox> </HBox>
<Label fx:id="messageLabel" <Label fx:id="messageLabel"
@@ -34,19 +43,11 @@
<!-- باکس آهنگ در حال پخش --> <!-- باکس آهنگ در حال پخش -->
<VBox alignment="CENTER" spacing="5"> <VBox alignment="CENTER" spacing="5">
<!-- اسم آهنگ در حال پخش --> <Label fx:id="nowPlayingLabel"
<Label fx:id="nowPlayingLabel" style="-fx-font-weight: bold; -fx-font-size: 14px;" text="No song playing" /> text="No song playing"/>
<!-- دکمه‌های جلو عقب -->
<BorderPane>
<center>
<HBox alignment="CENTER" spacing="20"> <HBox alignment="CENTER" spacing="20">
<padding> <!-- دکمه‌های جلو عقب -->
<Insets top="0" right="0" bottom="0" left="65"/>
</padding>
<!-- دکمه‌های اصلی -->
<Button fx:id="audioBtn" <Button fx:id="audioBtn"
onAction="#mute" onAction="#mute"
styleClass="circle-button"> styleClass="circle-button">
@@ -101,16 +102,5 @@
</graphic> </graphic>
</Button> </Button>
</HBox> </HBox>
</center>
<right>
<Button fx:id="openPlaylistBtn"
onAction="#openPlaylistWindow"
text="Open Playlist"
style="-fx-background-radius: 15px;" />
</right>
</BorderPane>
</VBox> </VBox>
</VBox> </VBox>