Updated JavaDoc.
This commit is contained in:
parent
ccee051cb4
commit
62fbb9e9fc
@ -84,6 +84,9 @@ public class JTreeLibrary extends JPanel implements ILibrary, LibraryCallbackInt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a message in the Library area to tell the user that the library is empty.
|
||||||
|
*/
|
||||||
private void showEmpty(){
|
private void showEmpty(){
|
||||||
DefaultTreeModel failedModel = new DefaultTreeModel(new DefaultMutableTreeNode());
|
DefaultTreeModel failedModel = new DefaultTreeModel(new DefaultMutableTreeNode());
|
||||||
DefaultMutableTreeNode failedParentNode = (DefaultMutableTreeNode) failedModel.getRoot();
|
DefaultMutableTreeNode failedParentNode = (DefaultMutableTreeNode) failedModel.getRoot();
|
||||||
@ -92,6 +95,9 @@ public class JTreeLibrary extends JPanel implements ILibrary, LibraryCallbackInt
|
|||||||
libraryTree.setModel(failedModel);
|
libraryTree.setModel(failedModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a list of all songs in the library area.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void showSongs() {
|
public void showSongs() {
|
||||||
Optional<List<Song>> dbQuery = database.listAllT(Song.class);
|
Optional<List<Song>> dbQuery = database.listAllT(Song.class);
|
||||||
@ -106,6 +112,11 @@ public class JTreeLibrary extends JPanel implements ILibrary, LibraryCallbackInt
|
|||||||
showEmpty();
|
showEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a list of all songs in the library area, grouped by a certain related type.
|
||||||
|
* @param grouping Type by which songs will be grouped.
|
||||||
|
* @param <T> Type by which songs will be grouped.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public <T extends HasSongs & Comparable<T>> void showGroupedSongs(Class<T> grouping) {
|
public <T extends HasSongs & Comparable<T>> void showGroupedSongs(Class<T> grouping) {
|
||||||
Optional<List<T>> dbQuery = database.listAllT(grouping);
|
Optional<List<T>> dbQuery = database.listAllT(grouping);
|
||||||
@ -125,6 +136,9 @@ public class JTreeLibrary extends JPanel implements ILibrary, LibraryCallbackInt
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the library to updating mode and start processing songs in library folders.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void updateLibrary() {
|
public void updateLibrary() {
|
||||||
if(!libraryUpdating.get()) {
|
if(!libraryUpdating.get()) {
|
||||||
@ -141,6 +155,9 @@ public class JTreeLibrary extends JPanel implements ILibrary, LibraryCallbackInt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh the content currently displayed in the library view.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void refreshLibrary() {
|
public void refreshLibrary() {
|
||||||
if(!libraryUpdating.get()) { // Don't try to refresh while updating!!
|
if(!libraryUpdating.get()) { // Don't try to refresh while updating!!
|
||||||
@ -160,23 +177,37 @@ public class JTreeLibrary extends JPanel implements ILibrary, LibraryCallbackInt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The library was updated but there was an error (partial update may have occurred).
|
||||||
|
* @param message Error message.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void libraryUpdated(String message) {
|
public void libraryUpdated(String message) {
|
||||||
JOptionPane.showMessageDialog(this, message, "Update Error", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(this, message, "Update Error", JOptionPane.ERROR_MESSAGE);
|
||||||
libraryUpdated();
|
libraryUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Library updated successfully.
|
||||||
|
*/
|
||||||
public void libraryUpdated() {
|
public void libraryUpdated() {
|
||||||
libraryUpdating.set(false);
|
libraryUpdating.set(false);
|
||||||
refreshLibrary();
|
refreshLibrary();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show data on the current update item being indexed.
|
||||||
|
* @param name Data about the file/folder to be shown to the user.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void currentlyUpdating(String name) {
|
public void currentlyUpdating(String name) {
|
||||||
updatingNode.setUserObject(name);
|
updatingNode.setUserObject(name);
|
||||||
((DefaultTreeModel)libraryTree.getModel()).nodeChanged(updatingNode);
|
((DefaultTreeModel)libraryTree.getModel()).nodeChanged(updatingNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Double click a library item to add it to the playlist.
|
||||||
|
*/
|
||||||
private class LibraryMouseAdapter extends MouseAdapter {
|
private class LibraryMouseAdapter extends MouseAdapter {
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed(MouseEvent e) {
|
public void mousePressed(MouseEvent e) {
|
||||||
@ -197,6 +228,9 @@ public class JTreeLibrary extends JPanel implements ILibrary, LibraryCallbackInt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renderer for showing album art next to library album items.
|
||||||
|
*/
|
||||||
private class LibraryTreeCellRenderer implements TreeCellRenderer {
|
private class LibraryTreeCellRenderer implements TreeCellRenderer {
|
||||||
|
|
||||||
private final JLabel label;
|
private final JLabel label;
|
||||||
|
@ -77,15 +77,27 @@ public class GStreamerPlayer implements IPlayer{
|
|||||||
setVolume(ConfigManager.getLastVolume());
|
setVolume(ConfigManager.getLastVolume());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the position of the seekbar.
|
||||||
|
*/
|
||||||
private void resetSeek(){
|
private void resetSeek(){
|
||||||
if(callbackInterface != null)
|
if(callbackInterface != null)
|
||||||
callbackInterface.setSeekBarPosition(0);
|
callbackInterface.setSeekBarPosition(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Play the currently active song in the playlist.
|
||||||
|
* @throws StartPlayingException
|
||||||
|
*/
|
||||||
public void play() throws StartPlayingException {
|
public void play() throws StartPlayingException {
|
||||||
playSong(playlist.getActive());
|
playSong(playlist.getActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Play a song
|
||||||
|
* @param inputSong Song to play.
|
||||||
|
* @throws StartPlayingException
|
||||||
|
*/
|
||||||
private void playSong(Song inputSong) throws StartPlayingException {
|
private void playSong(Song inputSong) throws StartPlayingException {
|
||||||
if (playBin.getState() == State.PLAYING)
|
if (playBin.getState() == State.PLAYING)
|
||||||
stop();
|
stop();
|
||||||
@ -186,9 +198,11 @@ public class GStreamerPlayer implements IPlayer{
|
|||||||
* @param volume New volume in percent.
|
* @param volume New volume in percent.
|
||||||
*/
|
*/
|
||||||
public void setVolume(int volume){
|
public void setVolume(int volume){
|
||||||
|
if(volume >= 0 && volume <= 100) {
|
||||||
currentVolume = volume;
|
currentVolume = volume;
|
||||||
playBin.setVolumePercent(volume);
|
playBin.setVolumePercent(volume);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Current Player volume in percent.
|
* @return Current Player volume in percent.
|
||||||
|
@ -66,11 +66,20 @@ public class VLCPlayer implements IPlayer {
|
|||||||
libvlcArgs.add("--aout=dummy");
|
libvlcArgs.add("--aout=dummy");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Play the currently active song in the playlist.
|
||||||
|
* @throws StartPlayingException
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void play() throws StartPlayingException {
|
public void play() throws StartPlayingException {
|
||||||
playSong(playlist.getActive());
|
playSong(playlist.getActive());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Play a song
|
||||||
|
* @param inputSong Song to play.
|
||||||
|
* @throws StartPlayingException
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void playSong(Optional<Song> inputSong) throws StartPlayingException {
|
public void playSong(Optional<Song> inputSong) throws StartPlayingException {
|
||||||
if(inputSong.isPresent()) {
|
if(inputSong.isPresent()) {
|
||||||
@ -78,6 +87,11 @@ public class VLCPlayer implements IPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Play a song
|
||||||
|
* @param inputSong Song to play.
|
||||||
|
* @throws StartPlayingException
|
||||||
|
*/
|
||||||
private void playSong(Song inputSong) throws StartPlayingException {
|
private void playSong(Song inputSong) throws StartPlayingException {
|
||||||
resetSeek();
|
resetSeek();
|
||||||
if(inputSong == currentSong && mediaPlayer.getTime() > 0 && mediaPlayer.getTime() <= mediaPlayer.getLength()) { // Song ~should~ already be loaded, unpause instead?
|
if(inputSong == currentSong && mediaPlayer.getTime() > 0 && mediaPlayer.getTime() <= mediaPlayer.getLength()) { // Song ~should~ already be loaded, unpause instead?
|
||||||
@ -97,22 +111,34 @@ public class VLCPlayer implements IPlayer {
|
|||||||
throw new StartPlayingException(inputSong);
|
throw new StartPlayingException(inputSong);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the position of the seekbar.
|
||||||
|
*/
|
||||||
private void resetSeek(){
|
private void resetSeek(){
|
||||||
if(callbackInterface != null)
|
if(callbackInterface != null)
|
||||||
callbackInterface.setSeekBarPosition(0);
|
callbackInterface.setSeekBarPosition(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop playback.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
resetSeek();
|
resetSeek();
|
||||||
mediaPlayer.stop();
|
mediaPlayer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resume playback.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void resume() {
|
public void resume() {
|
||||||
mediaPlayer.setPause(false);
|
mediaPlayer.setPause(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pause playback.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void pause() {
|
public void pause() {
|
||||||
mediaPlayer.setPause(true);
|
mediaPlayer.setPause(true);
|
||||||
@ -123,52 +149,89 @@ public class VLCPlayer implements IPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Play the next song in the playlist.
|
||||||
|
* @throws StartPlayingException
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void next() throws StartPlayingException {
|
public void next() throws StartPlayingException {
|
||||||
playSong(playlist.getNext(currentSong));
|
playSong(playlist.getNext(currentSong));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Play the previous song in the playlist.
|
||||||
|
* @throws StartPlayingException
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void previous() throws StartPlayingException {
|
public void previous() throws StartPlayingException {
|
||||||
playSong(playlist.getPrevious(currentSong));
|
playSong(playlist.getPrevious(currentSong));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The song currently playing (or set as ready to play)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Song getCurrentSong() {
|
public Song getCurrentSong() {
|
||||||
return currentSong;
|
return currentSong;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Current playback position in seconds.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int currentSongPosition() {
|
public int currentSongPosition() {
|
||||||
return (int)(mediaPlayer.getTime() / 1000);
|
return (int)(mediaPlayer.getTime() / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set playback volume.
|
||||||
|
* @param volume Volume value between 0 & 100.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setVolume(int volume) {
|
public void setVolume(int volume) {
|
||||||
|
if(volume >= 0 && volume <= 100) {
|
||||||
currentVolume = volume;
|
currentVolume = volume;
|
||||||
mediaPlayer.setVolume(volume);
|
mediaPlayer.setVolume(volume);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Current playback volume.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getVolume() {
|
public int getVolume() {
|
||||||
return (mediaPlayer.getVolume() >= 0) ? mediaPlayer.getVolume() : currentVolume;
|
return (mediaPlayer.getVolume() >= 0) ? mediaPlayer.getVolume() : currentVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Move to desired position in playback.
|
||||||
|
* @param position Time to move to in seconds.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void seek(int position) {
|
public void seek(int position) {
|
||||||
mediaPlayer.setTime(position * 1000);
|
mediaPlayer.setTime(position * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Is the player currently playing.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isPlaying() {
|
public boolean isPlaying() {
|
||||||
return mediaPlayer.isPlaying();
|
return mediaPlayer.isPlaying();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the player to single song repeat mode.
|
||||||
|
* @param repeatMode Repeat one song?
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setRepeat(boolean repeatMode) {
|
public void setRepeat(boolean repeatMode) {
|
||||||
this.repeatMode = repeatMode;
|
this.repeatMode = repeatMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Is the player set to repeat one song.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isRepeating() {
|
public boolean isRepeating() {
|
||||||
return repeatMode;
|
return repeatMode;
|
||||||
|
Loading…
Reference in New Issue
Block a user