Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joshua Hartwell
authored and
Joshua Hartwell
committed
May 1, 2017
0 parents
commit 2864f95
Showing
11 changed files
with
364 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> | ||
<accessrules> | ||
<accessrule kind="accessible" pattern="javafx/**"/> | ||
</accessrules> | ||
</classpathentry> | ||
<classpathentry kind="lib" path="/d/programming/workspace/MusicPlayer/lib/jaudiotagger-2.2.6-SNAPSHOT.jar"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>MusicPlayer</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.8 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.8 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import javafx.beans.property.SimpleIntegerProperty; | ||
import javafx.beans.property.SimpleStringProperty; | ||
|
||
public class Album { | ||
private final SimpleStringProperty artist; | ||
private final SimpleIntegerProperty year; | ||
private final SimpleStringProperty album; | ||
|
||
Album ( String artist, int year, String album ) { | ||
this.artist = new SimpleStringProperty ( artist ); | ||
this.year = new SimpleIntegerProperty ( year ); | ||
this.album = new SimpleStringProperty ( album ); | ||
} | ||
|
||
public String getArtist () { | ||
return artist.get(); | ||
} | ||
|
||
public int getYear () { | ||
return year.get(); | ||
} | ||
|
||
public String getAlbum () { | ||
return album.get(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,253 @@ | ||
import java.io.File; | ||
|
||
import org.jaudiotagger.audio.AudioFile; | ||
import org.jaudiotagger.audio.AudioFileIO; | ||
import org.jaudiotagger.tag.FieldKey; | ||
import org.jaudiotagger.tag.Tag; | ||
|
||
import javafx.application.Application; | ||
import javafx.collections.FXCollections; | ||
import javafx.collections.ObservableList; | ||
import javafx.geometry.Insets; | ||
import javafx.geometry.Orientation; | ||
import javafx.geometry.Pos; | ||
import javafx.scene.Group; | ||
import javafx.scene.Scene; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.Slider; | ||
import javafx.scene.control.SplitPane; | ||
import javafx.scene.control.TableColumn; | ||
import javafx.scene.control.TableView; | ||
import javafx.scene.control.TextField; | ||
import javafx.scene.control.cell.PropertyValueFactory; | ||
import javafx.scene.image.Image; | ||
import javafx.scene.image.ImageView; | ||
import javafx.scene.layout.BorderPane; | ||
import javafx.scene.layout.HBox; | ||
import javafx.scene.layout.StackPane; | ||
import javafx.scene.layout.VBox; | ||
import javafx.stage.Stage; | ||
|
||
|
||
@SuppressWarnings({ "rawtypes", "unchecked" }) //TODO: Maybe get rid of this when I understand things better | ||
public class MusicPlayer extends Application { | ||
|
||
public static final String PROGRAM_NAME = "Music Player"; | ||
|
||
final static ObservableList <Album> albumListData = FXCollections.observableArrayList( | ||
new Album ("Air", 2009, "Pocket WhateveR" ), | ||
new Album ("Air", 2008, "Pocket WhateveR" ), | ||
new Album ("Air", 2007, "Pocket WhateveR" ), | ||
new Album ("Air", 2006, "Pocket WhateveR" ), | ||
new Album ("Air", 2005, "Pocket WhateveR" ), | ||
new Album ("Air", 2004, "Pocket WhateveR" ), | ||
new Album ("Josh", 2008, "wefwef" ), | ||
new Album ("EWFEW", 2005, "EEFEFE" ), | ||
new Album ("Maria", 1949, "AAA" ), | ||
new Album ("Thomas", 2000, "DDDDD" ), | ||
new Album ("234234", 1999, "wefwef" ), | ||
new Album ("wefawfasdfs", 2008, "AAAAA" ), | ||
new Album ("qqqqqq", 2008, "VBBBBB" ) | ||
); | ||
|
||
final static ObservableList <Track> playlistData = FXCollections.observableArrayList ( | ||
new Track ( "Air", 2009, "Pocket Whatever", "Johs's Song", 5, 344 ), | ||
new Track ( "Air", 2009, "Pocket Whatever", "Song ABC", 1, 1344 ), | ||
new Track ( "Air", 2009, "Pocket Whatever", "GGG", 2, 443 ), | ||
new Track ( "Air", 2009, "Pocket Whatever", "HLIFJWE", 3, 992 ), | ||
new Track ( "Air", 2009, "Pocket Whatever", "Living Free", 4, 116 ), | ||
new Track ( "Air", 2009, "Pocket Whatever", "Absbolute", 6, 644 ) | ||
); | ||
|
||
static TableView albumTable; | ||
static TableView playlistTable; | ||
|
||
static BorderPane albumImage; | ||
static BorderPane artistImage; | ||
static TextField albumSearchPane; | ||
|
||
static VBox transport; | ||
|
||
|
||
|
||
public static void main ( String[] args ) throws Exception { | ||
|
||
/*AudioFile audioFile = AudioFileIO.read( new File ( "song.flac" ) ); | ||
Tag tag = audioFile.getTag(); | ||
System.out.println ( tag.getFirst ( FieldKey.ARTIST ) ); | ||
System.out.println ( tag.getFirst ( FieldKey.ALBUM ) ); | ||
System.out.println ( tag.getFirst ( FieldKey.TITLE ) ); | ||
System.out.println ( tag.getFirst ( FieldKey.TRACK ) ); | ||
*/ | ||
|
||
|
||
Application.launch ( args ); | ||
|
||
} | ||
|
||
@Override | ||
public void start ( Stage stage ) { | ||
Scene scene = new Scene ( new Group() ); | ||
|
||
setupAlbumTable(); | ||
setupAlbumSearchPane(); | ||
setupPlaylistTable(); | ||
setupAlbumImage(); | ||
setupArtistImage(); | ||
setupTransport(); | ||
|
||
SplitPane artSplitPane = new SplitPane(); | ||
artSplitPane.getItems().addAll ( albumImage, artistImage ); | ||
|
||
SplitPane playlistSplitPane = new SplitPane(); | ||
playlistSplitPane.setOrientation ( Orientation.VERTICAL ); | ||
playlistSplitPane.getItems().addAll ( playlistTable, artSplitPane ); | ||
|
||
BorderPane albumListPane = new BorderPane(); | ||
albumSearchPane.prefWidthProperty().bind ( albumListPane.widthProperty() ); | ||
albumListPane.setTop( albumSearchPane ); | ||
albumListPane.setCenter( albumTable ); | ||
|
||
SplitPane primarySplitPane = new SplitPane(); | ||
primarySplitPane.getItems().addAll ( albumListPane, playlistSplitPane ); | ||
|
||
|
||
final BorderPane primaryContainer = new BorderPane(); | ||
|
||
primaryContainer.prefWidthProperty().bind( scene.widthProperty() ); | ||
primaryContainer.prefHeightProperty().bind( scene.heightProperty() ); | ||
primaryContainer.setPadding( new Insets(0) ); //TODO: | ||
primaryContainer.setCenter( primarySplitPane ); | ||
primaryContainer.setTop( transport ); | ||
|
||
|
||
stage.setTitle ( PROGRAM_NAME ); | ||
stage.setWidth ( 1024 ); | ||
stage.setHeight ( 768 ); | ||
((Group) scene.getRoot()).getChildren().addAll( primaryContainer ); | ||
|
||
stage.setScene ( scene ); | ||
stage.show(); | ||
} | ||
|
||
public void setupTransport() { | ||
|
||
Button playButton = new Button ( "▶" ); | ||
Button pauseButton = new Button ( "▋▋" ); | ||
Button stopButton = new Button ( "◼" ); | ||
Button nextButton = new Button ( "⏩" ); | ||
Button previousButton = new Button ( "⏪" ); | ||
|
||
Label timeElapsed = new Label ( "2:02" ); | ||
Label timeRemaining = new Label ( "-1:12" ); | ||
//Label transportTitle = | ||
|
||
Slider trackPosition = new Slider(); | ||
trackPosition.setMin( 0 ); | ||
trackPosition.setMax( 100 ); | ||
trackPosition.setValue ( 40 ); //TODO: Delete | ||
trackPosition.setMaxWidth ( 600 ); | ||
trackPosition.setMinWidth( 200 ); | ||
trackPosition.setPrefWidth( 400 ); | ||
|
||
HBox sliderPane = new HBox(); | ||
sliderPane.getChildren().add ( timeElapsed ); | ||
sliderPane.getChildren().add ( trackPosition ); | ||
sliderPane.getChildren().add ( timeRemaining ); | ||
sliderPane.setAlignment( Pos.CENTER ); | ||
|
||
HBox buttons = new HBox(); | ||
buttons.getChildren().add ( stopButton ); | ||
buttons.getChildren().add ( playButton ); | ||
buttons.getChildren().add ( pauseButton ); | ||
buttons.getChildren().add ( previousButton ); | ||
buttons.getChildren().add ( nextButton ); | ||
buttons.setPadding ( new Insets ( 5 ) ); | ||
buttons.setSpacing ( 5 ); | ||
|
||
HBox controls = new HBox (); | ||
controls.getChildren().add ( buttons ); | ||
controls.getChildren().add ( sliderPane ); | ||
controls.setSpacing( 10 ); | ||
controls.setAlignment( Pos.CENTER ); | ||
|
||
HBox playingTrackInfo = new HBox(); | ||
Label trackInfo = new Label ( "Air - 1998 - Moon Safari - 01 - La Femme D'Argent" ); | ||
playingTrackInfo.getChildren().add ( trackInfo ); | ||
playingTrackInfo.setAlignment( Pos.CENTER ); | ||
|
||
transport = new VBox(); | ||
transport.getChildren().add ( playingTrackInfo ); | ||
transport.getChildren().add ( controls ); | ||
transport.setPadding( new Insets ( 10, 0, 10, 0 ) ); | ||
transport.setSpacing ( 5 ); | ||
|
||
} | ||
|
||
public void setupAlbumImage() { | ||
albumImage = new BorderPane(); | ||
ImageView view = new ImageView( new Image ( "file:front.jpg" ) ); | ||
view.fitWidthProperty().set( 250 ); | ||
view.fitHeightProperty().set( 250 ); | ||
albumImage.setCenter( view ); | ||
} | ||
|
||
public void setupArtistImage() { | ||
artistImage = new BorderPane(); | ||
ImageView view = new ImageView( new Image ( "file:artist.jpg" ) ); | ||
view.fitWidthProperty().set( 250 ); | ||
view.fitHeightProperty().set( 250 ); | ||
artistImage.setCenter( view ); | ||
} | ||
|
||
public void setupAlbumSearchPane () { | ||
albumSearchPane = new TextField(); | ||
} | ||
|
||
public void setupAlbumTable () { | ||
TableColumn artistColumn = new TableColumn ( "Artist" ); | ||
TableColumn yearColumn = new TableColumn ( "Year" ); | ||
TableColumn albumColumn = new TableColumn ( "Album" ); | ||
|
||
artistColumn.setCellValueFactory ( new PropertyValueFactory <Album, String> ( "Artist" ) ); | ||
yearColumn.setCellValueFactory ( new PropertyValueFactory <Album, Integer> ( "Year" ) ); | ||
albumColumn.setCellValueFactory ( new PropertyValueFactory <Album, String> ( "Album" ) ); | ||
|
||
artistColumn.setSortType (TableColumn.SortType.ASCENDING ); | ||
|
||
albumTable = new TableView(); | ||
albumTable.getColumns().addAll ( artistColumn, yearColumn, albumColumn ); | ||
albumTable.setEditable ( false ); | ||
albumTable.setItems( albumListData ); | ||
albumTable.getSortOrder().add ( artistColumn ); | ||
albumTable.setColumnResizePolicy ( TableView.CONSTRAINED_RESIZE_POLICY ); | ||
|
||
} | ||
|
||
public void setupPlaylistTable () { | ||
TableColumn artistColumn = new TableColumn("Artist"); | ||
TableColumn yearColumn = new TableColumn("Year"); | ||
TableColumn albumColumn = new TableColumn("Album"); | ||
TableColumn titleColumn = new TableColumn("Title"); | ||
TableColumn trackColumn = new TableColumn("#"); | ||
TableColumn lengthColumn = new TableColumn("Length"); | ||
|
||
artistColumn.setCellValueFactory( new PropertyValueFactory <Track, String> ("Artist") ); | ||
yearColumn.setCellValueFactory( new PropertyValueFactory <Track, Integer> ("Year") ); | ||
albumColumn.setCellValueFactory( new PropertyValueFactory <Track, String> ("Album") ); | ||
titleColumn.setCellValueFactory( new PropertyValueFactory <Track, String> ("Title") ); | ||
trackColumn.setCellValueFactory( new PropertyValueFactory <Track, Integer> ("trackNumber") ); | ||
lengthColumn.setCellValueFactory( new PropertyValueFactory <Track, String> ("Length") ); | ||
|
||
playlistTable = new TableView(); | ||
playlistTable.getColumns().addAll ( trackColumn, artistColumn, yearColumn, albumColumn, titleColumn, lengthColumn ); | ||
playlistTable.setEditable ( false ); | ||
playlistTable.setItems( playlistData ); | ||
playlistTable.setColumnResizePolicy ( TableView.CONSTRAINED_RESIZE_POLICY ); | ||
|
||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import javafx.beans.property.SimpleIntegerProperty; | ||
import javafx.beans.property.SimpleStringProperty; | ||
|
||
public class Track { | ||
private final SimpleStringProperty artist; | ||
private final SimpleIntegerProperty year; | ||
private final SimpleStringProperty album; | ||
private final SimpleStringProperty title; | ||
private final SimpleIntegerProperty trackNumber; | ||
private final SimpleIntegerProperty length; | ||
|
||
|
||
Track ( String artist, int year, String album, String title, int trackNumber, int length ) { | ||
this.artist = new SimpleStringProperty ( artist ); | ||
this.year = new SimpleIntegerProperty ( year ); | ||
this.album = new SimpleStringProperty ( album ); | ||
this.title = new SimpleStringProperty ( title ); | ||
this.trackNumber = new SimpleIntegerProperty ( trackNumber ); | ||
this.length = new SimpleIntegerProperty ( length ); | ||
} | ||
|
||
public String getArtist () { | ||
return artist.get(); | ||
} | ||
|
||
public int getYear () { | ||
return year.get(); | ||
} | ||
|
||
public String getAlbum () { | ||
return album.get(); | ||
} | ||
|
||
public String getTitle () { | ||
return title.get(); | ||
} | ||
|
||
public int getTrackNumber () { | ||
return trackNumber.get(); | ||
} | ||
|
||
public int getLength () { | ||
return length.get(); | ||
} | ||
} |