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

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(
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("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"),
+28 -6
View File
@@ -11,6 +11,8 @@ import javafx.scene.image.ImageView;
import javafx.scene.layout.*;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.util.Duration;
@@ -38,12 +40,17 @@ public class MusicController {
private boolean isPlaying=false;
private boolean isMute=false;
private boolean isOpen=false;
private boolean isRepeat=false;
private Song currentSong = null;
ImageView playIcon;
ImageView pauseIcon;
ImageView audioIcon;
ImageView muteIcon;
String path;
Media media;
MediaPlayer player ;
// TODO: Define your UI components using the @FXML annotation.
@FXML
@@ -161,11 +168,21 @@ public class MusicController {
}
public void play(ActionEvent event, Song song){
currentSong=song;
nowPlayingLabel.setText(song.getName());
if (!isPlaying)
playPause(event);
//کد پخش
// کد پخش موسیقی
path = getClass()
.getResource(song.getPath())
.toExternalForm();
media = new Media(path);
player = new MediaPlayer(media);
player.play();
}
@FXML
@@ -173,7 +190,10 @@ public class MusicController {
if(isPlaying){
playPauseBtn.setGraphic(playIcon);
isPlaying=false;
//کد توقف اینجاست چون برای هر توقفی دکمه ی پاز رو میزنیم ولی برای پلی ممکنه از بین آهنگ ها بزنیم
//کد توقف
player.pause();
}
else{
playPauseBtn.setGraphic(pauseIcon);
@@ -183,11 +203,14 @@ public class MusicController {
@FXML
public void mute(ActionEvent e){
isMute=!isMute;
if(!isMute){
audioBtn.setGraphic(audioIcon);
}else{
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(playlistListView.getItems().isEmpty()){
Alert alert = new Alert(Alert.AlertType.WARNING);
+16 -26
View File
@@ -11,11 +11,20 @@
<Insets bottom="10" left="10" right="10" top="10" />
</padding>
<!-- دکمه تغییر تم -->
<!-- دکمه تغییر تم و open playlist -->
<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;" />
<Region HBox.hgrow="ALWAYS" /> <!-- این فضا رو پر میکنه تا دکمه سمت چپ بمونه -->
<Button fx:id="themeToggleBtn"
text="Dark"
onAction="#toggleTheme"/>
<Region HBox.hgrow="ALWAYS"/>
<Button fx:id="openPlaylistBtn"
onAction="#openPlaylistWindow"
text="Open Playlist"
style="-fx-background-radius: 15px;" />
</HBox>
<Label fx:id="messageLabel"
@@ -34,19 +43,11 @@
<!-- باکس آهنگ در حال پخش -->
<VBox alignment="CENTER" spacing="5">
<!-- اسم آهنگ در حال پخش -->
<Label fx:id="nowPlayingLabel" style="-fx-font-weight: bold; -fx-font-size: 14px;" text="No song playing" />
<Label fx:id="nowPlayingLabel"
text="No song playing"/>
<!-- دکمه‌های جلو عقب -->
<BorderPane>
<center>
<HBox alignment="CENTER" spacing="20">
<padding>
<Insets top="0" right="0" bottom="0" left="65"/>
</padding>
<!-- دکمه‌های اصلی -->
<!-- دکمه‌های جلو عقب -->
<Button fx:id="audioBtn"
onAction="#mute"
styleClass="circle-button">
@@ -101,16 +102,5 @@
</graphic>
</Button>
</HBox>
</center>
<right>
<Button fx:id="openPlaylistBtn"
onAction="#openPlaylistWindow"
text="Open Playlist"
style="-fx-background-radius: 15px;" />
</right>
</BorderPane>
</VBox>
</VBox>