67 lines
1.9 KiB
Java
67 lines
1.9 KiB
Java
package sbu.javafx;
|
|
|
|
import javafx.fxml.FXML;
|
|
import javafx.scene.control.*;
|
|
|
|
import javax.print.attribute.standard.Media;
|
|
import java.nio.MappedByteBuffer;
|
|
|
|
public class TrackController {
|
|
|
|
// TODO: Define your UI components using the @FXML annotation.
|
|
|
|
@FXML private Label displayTrackName;
|
|
@FXML private Label displayArtistName;
|
|
@FXML private Label displayDuration;
|
|
@FXML private Button playButton;
|
|
@FXML private Button addButton;
|
|
|
|
private Track currentTrack;
|
|
|
|
private static Track playingTrack = new Track("___", "___", "00:00", "");
|
|
|
|
public void setTrack(Track track) {
|
|
this.currentTrack = track;
|
|
|
|
this.displayTrackName.textProperty().bind(track.getTrackNameProperty());
|
|
this.displayArtistName.textProperty().bind(track.getArtistNameProperty());
|
|
this.displayDuration.textProperty().bind(track.getDurationProperty());
|
|
|
|
this.playButton.textProperty().bind(track.getPlayButton());
|
|
this.addButton.textProperty().bind(track.getAddButton());
|
|
}
|
|
|
|
@FXML
|
|
public void initialize() {
|
|
//
|
|
}
|
|
|
|
//TODO: Implement the logic to play a song. This method should update the UI to show which song is currently playing.
|
|
|
|
@FXML
|
|
public void handlePlayAction() {
|
|
//Update labels, change button icons, etc.
|
|
|
|
//changing playingTrack
|
|
if (playingTrack.getTrackName().equals(currentTrack.getTrackName()) &&
|
|
playingTrack.getArtistName().equals(currentTrack.getArtistName())) {
|
|
playingTrack = new Track("___", "___", "00:00", "");
|
|
}
|
|
else {
|
|
playingTrack = currentTrack;
|
|
}
|
|
|
|
//parsing playingTrack to AppController
|
|
AppController.setPlayingTrack(playingTrack);
|
|
}
|
|
|
|
//TODO: Logic to add a specific song to the user's playlist.
|
|
|
|
@FXML
|
|
public void addToPlaylist() {
|
|
//Add the song to a list or update a ListView.
|
|
|
|
AppController.addOrRemove(currentTrack);
|
|
}
|
|
}
|