diff --git a/src/main/java/musicplayer/Player.java b/src/main/java/musicplayer/Player.java index e4b44b0..5cbd9b8 100644 --- a/src/main/java/musicplayer/Player.java +++ b/src/main/java/musicplayer/Player.java @@ -17,6 +17,10 @@ public class Player { private Song currentSong; private PlayerCallbackInterface callbackInterface; + /** + * Manages GStreamer based playback operations. + * @param callbackInterface Interface on which UI updates can be called. + */ public Player(PlayerCallbackInterface callbackInterface) { this.callbackInterface = callbackInterface; Gst.init(); @@ -36,6 +40,10 @@ public class Player { }); } + /** + * Set a source Song file and start playing it via GStreamer. + * @param song Song to play. + */ public void playSong(Song song) { callbackInterface.setSongHighlighting(song); currentSong = song; @@ -54,6 +62,9 @@ public class Player { callbackInterface.setSeekBarDuration((int) playBin.queryDuration().toSeconds()); } + /** + * Stop any music currently playing. + */ public void stop() { if (this.thread != null) { playBin.stop(); @@ -62,18 +73,30 @@ public class Player { } } + /** + * Resume playing a paused song. + */ public void resume() { playBin.play(); } + /** + * Pause the currently playing song. + */ public void pause() { playBin.pause(); } + /** + * @return The Song currently being played or ready to be played. + */ public Song getCurrentSong(){ return currentSong; } + /** + * @return Current playback position in seconds. + */ public int currentSongPosition(){ return playBin.isPlaying() ? (int) (playBin.getClock().getTime().toSeconds() - playBin.getBaseTime().toSeconds()) : 0; } diff --git a/src/main/java/musicplayer/PlayerGUI.form b/src/main/java/musicplayer/PlayerGUI.form index 3240931..71bbcf9 100644 --- a/src/main/java/musicplayer/PlayerGUI.form +++ b/src/main/java/musicplayer/PlayerGUI.form @@ -1,6 +1,6 @@
diff --git a/src/main/java/musicplayer/PlayerGUI.java b/src/main/java/musicplayer/PlayerGUI.java index 4700468..1f733dd 100644 --- a/src/main/java/musicplayer/PlayerGUI.java +++ b/src/main/java/musicplayer/PlayerGUI.java @@ -66,10 +66,17 @@ public class PlayerGUI implements PlayerCallbackInterface{ seekBarUpdater.start(); } + /** + * Set the value of seekBar. + * @param position New seekBar value. + */ public void setSeekBarPosition(int position){ SwingUtilities.invokeLater(() -> seekBar.setValue(position)); } + /** + * Reset the libraryView to contain nothing. + */ private void resetTree() { libraryView.removeAll(); DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode(); @@ -77,6 +84,10 @@ public class PlayerGUI implements PlayerCallbackInterface{ libraryView.setModel(treeModel); } + /** + * Populate the library with songs grouped by album. + * @param libraryData Map of albums with a lists of associated songs. + */ private void populateLibrary(Map