Adds full support for YouTube playback.
While a few optimizations could be made, YouTube playback is almost as seamless as local playback.
This commit is contained in:
@@ -4,17 +4,16 @@
|
||||
|
||||
package edu.regis.universeplayer;
|
||||
|
||||
import edu.regis.universeplayer.data.Song;
|
||||
import edu.regis.universeplayer.data.PlaybackEvent;
|
||||
|
||||
import java.util.EventListener;
|
||||
import java.util.EventObject;
|
||||
|
||||
/**
|
||||
* A playback listener allows a class to listen for events regarding player
|
||||
* updates.
|
||||
*
|
||||
* @author William Hubbard
|
||||
* @verison 0.1
|
||||
* @version 0.1
|
||||
*/
|
||||
public interface PlaybackListener extends EventListener
|
||||
{
|
||||
@@ -23,64 +22,6 @@ public interface PlaybackListener extends EventListener
|
||||
*
|
||||
* @param status - The playback status.
|
||||
*/
|
||||
void onPlaybackChanged(PlaybackInfo status);
|
||||
void onPlaybackChanged(PlaybackEvent status);
|
||||
|
||||
class PlaybackInfo extends EventObject
|
||||
{
|
||||
private final Song currentSong;
|
||||
/**
|
||||
* The time we are currently at in the song, in seconds.
|
||||
*/
|
||||
private final float playTime;
|
||||
|
||||
/**
|
||||
* The current status of the player.
|
||||
*/
|
||||
private final PlaybackStatus status;
|
||||
|
||||
public PlaybackInfo(Player<? extends Song> player, Song song, float playTime, PlaybackStatus status)
|
||||
{
|
||||
super(player);
|
||||
this.currentSong = song;
|
||||
this.playTime = playTime;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player<? extends Song> getSource()
|
||||
{
|
||||
return (Player<? extends Song>) super.getSource();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the song currently playing.
|
||||
*
|
||||
* @return The current song, or null if none is loaded.
|
||||
*/
|
||||
public Song getSong()
|
||||
{
|
||||
return this.currentSong;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the current play time.
|
||||
*
|
||||
* @return The play time of the player. This will be zero if the song is
|
||||
* stopped or not loaded.
|
||||
*/
|
||||
public float getPlayTime()
|
||||
{
|
||||
return this.playTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the current status of the player.
|
||||
*
|
||||
* @return - The player's playback status.
|
||||
*/
|
||||
public PlaybackStatus getStatus()
|
||||
{
|
||||
return this.status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,20 +4,20 @@
|
||||
|
||||
package edu.regis.universeplayer.browser;
|
||||
|
||||
import edu.regis.universeplayer.PlaybackInfo;
|
||||
import edu.regis.universeplayer.PlaybackListener;
|
||||
import edu.regis.universeplayer.PlaybackStatus;
|
||||
import edu.regis.universeplayer.Player;
|
||||
import edu.regis.universeplayer.browserCommands.*;
|
||||
import edu.regis.universeplayer.data.InternetSong;
|
||||
import edu.regis.universeplayer.data.PlaybackEvent;
|
||||
import edu.regis.universeplayer.data.Song;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.ConnectException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.*;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Scanner;
|
||||
import java.util.concurrent.*;
|
||||
@@ -227,7 +227,7 @@ public class Browser extends MessageRunner implements Player<InternetSong>
|
||||
@Override
|
||||
public void addPlaybackListener(PlaybackListener listener)
|
||||
{
|
||||
|
||||
this.listeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,7 +239,7 @@ public class Browser extends MessageRunner implements Player<InternetSong>
|
||||
@Override
|
||||
public boolean hasPlaybackListener(PlaybackListener listener)
|
||||
{
|
||||
return false;
|
||||
return this.listeners.contains(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,9 +250,21 @@ public class Browser extends MessageRunner implements Player<InternetSong>
|
||||
@Override
|
||||
public void removePlaybackListener(PlaybackListener listener)
|
||||
{
|
||||
|
||||
this.listeners.remove(listener);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void triggerUpdateListeners(Object ob)
|
||||
{
|
||||
PlaybackEvent status;
|
||||
super.triggerUpdateListeners(ob);
|
||||
if (ob instanceof PlaybackInfo)
|
||||
{
|
||||
status = new PlaybackEvent(this, (PlaybackInfo) ob);
|
||||
this.listeners.forEach(l -> l.onPlaybackChanged(status));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryFuture<Void> play()
|
||||
{
|
||||
@@ -301,7 +313,15 @@ public class Browser extends MessageRunner implements Player<InternetSong>
|
||||
@Override
|
||||
public QueryFuture<Void> stopSong()
|
||||
{
|
||||
return null;
|
||||
try
|
||||
{
|
||||
return new ForwardedFuture(this.sendObject(new CommandLoadSong((URL) null)));
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
logger.error("Could not send message", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -331,14 +351,14 @@ public class Browser extends MessageRunner implements Player<InternetSong>
|
||||
Future future = this.sendObject(new QueryStatus());
|
||||
return new QueryFuture<>() {
|
||||
|
||||
private CommandReturn<Double> getVal() throws ExecutionException, InterruptedException
|
||||
private CommandReturn<String> getVal() throws ExecutionException, InterruptedException
|
||||
{
|
||||
return ((CommandReturn<Double>) future.get());
|
||||
return ((CommandReturn<String>) future.get());
|
||||
}
|
||||
|
||||
private CommandReturn<Double> getVal(long timeout, TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException
|
||||
private CommandReturn<String> getVal(long timeout, TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException
|
||||
{
|
||||
return ((CommandReturn<Double>) future.get(timeout, unit));
|
||||
return ((CommandReturn<String>) future.get(timeout, unit));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -374,15 +394,15 @@ public class Browser extends MessageRunner implements Player<InternetSong>
|
||||
@Override
|
||||
public PlaybackStatus get() throws InterruptedException, ExecutionException
|
||||
{
|
||||
Double value = getVal().getReturnValue();
|
||||
return PlaybackStatus.values()[value.intValue()];
|
||||
String value = getVal().getReturnValue();
|
||||
return PlaybackStatus.valueOf(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlaybackStatus get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
|
||||
{
|
||||
Double value = getVal(timeout, unit).getReturnValue();
|
||||
return PlaybackStatus.values()[value.intValue()];
|
||||
String value = getVal(timeout, unit).getReturnValue();
|
||||
return PlaybackStatus.valueOf(value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 William Hubbard. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package edu.regis.universeplayer.browser;
|
||||
|
||||
import edu.regis.universeplayer.data.Song;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
public class InternetSong extends Song
|
||||
{
|
||||
public URL location;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 William Hubbard. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package edu.regis.universeplayer.data;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
public class Album implements Comparable<Album>
|
||||
{
|
||||
public int id;
|
||||
public String name;
|
||||
public String[] artists;
|
||||
public ImageIcon art;
|
||||
public int year;
|
||||
public String[] genres;
|
||||
public int totalTracks;
|
||||
public int totalDiscs;
|
||||
|
||||
@Override
|
||||
public int compareTo(Album o)
|
||||
{
|
||||
if (o != null)
|
||||
{
|
||||
return this.name.compareTo(o.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
package edu.regis.universeplayer.data;
|
||||
|
||||
import edu.regis.universeplayer.browser.InternetSong;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 William Hubbard. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package edu.regis.universeplayer.data;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* This song represents a song found on the local file system.
|
||||
*/
|
||||
public class LocalSong extends Song
|
||||
{
|
||||
public File file;
|
||||
public String type;
|
||||
public String codec;
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 William Hubbard. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package edu.regis.universeplayer.data;
|
||||
|
||||
import com.mpatric.mp3agic.ID3v1;
|
||||
import com.mpatric.mp3agic.ID3v2;
|
||||
import com.mpatric.mp3agic.InvalidDataException;
|
||||
import com.mpatric.mp3agic.Mp3File;
|
||||
import com.mpatric.mp3agic.UnsupportedTagException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* This will specifically import an MP3 file.
|
||||
*
|
||||
* @author William Hubbard
|
||||
* @version 0.1
|
||||
*/
|
||||
public class MP3Song extends LocalSong
|
||||
{
|
||||
public MP3Song(File file)
|
||||
{
|
||||
Mp3File metadata;
|
||||
ID3v1 tag1;
|
||||
ID3v2 tag2;
|
||||
this.file = file;
|
||||
try
|
||||
{
|
||||
metadata = new Mp3File(file);
|
||||
this.album = new Album();
|
||||
if (metadata.hasId3v1Tag())
|
||||
{
|
||||
tag1 = metadata.getId3v1Tag();
|
||||
this.title = tag1.getTitle();
|
||||
this.artists = tag1.getArtist().split(";");
|
||||
/**
|
||||
* Trim the artists as needed.
|
||||
*/
|
||||
for (int i = 0, l = this.artists.length; i < l; i++)
|
||||
{
|
||||
this.artists[i] = this.artists[i].trim();
|
||||
}
|
||||
this.trackNum = Integer.parseInt(tag1.getTrack().split("/")[0]);
|
||||
|
||||
this.album.name = tag1.getAlbum();
|
||||
this.album.genres = tag1.getGenreDescription().split(";");
|
||||
for (int i = 0, l = this.album.genres.length; i < l; i++)
|
||||
{
|
||||
this.album.genres[i] = this.album.genres[i].trim();
|
||||
}
|
||||
this.album.year = Integer.parseInt(tag1.getYear());
|
||||
}
|
||||
/**
|
||||
* Make sure that the v2 tag doesn't contain any contradictory information.
|
||||
*/
|
||||
if (metadata.hasId3v2Tag())
|
||||
{
|
||||
tag2 = metadata.getId3v2Tag();
|
||||
if (!tag2.getTitle().isEmpty())
|
||||
{
|
||||
this.title = tag2.getTitle();
|
||||
}
|
||||
if (!tag2.getTitle().isEmpty())
|
||||
{
|
||||
this.artists = tag2.getArtist().split(";");
|
||||
/**
|
||||
* Trim the artists as needed.
|
||||
*/
|
||||
for (int i = 0, l = this.artists.length; i < l; i++)
|
||||
{
|
||||
this.artists[i] = this.artists[i].trim();
|
||||
}
|
||||
}
|
||||
if (!tag2.getTitle().isEmpty())
|
||||
{
|
||||
this.trackNum = Integer.parseInt(tag2.getTrack().split("/")[0]);
|
||||
}
|
||||
|
||||
if (!tag2.getAlbum().isEmpty())
|
||||
{
|
||||
this.album.name = tag2.getAlbum();
|
||||
}
|
||||
if (!tag2.getAlbumArtist().isEmpty())
|
||||
{
|
||||
this.album.artists = tag2.getAlbumArtist().split(";");
|
||||
/**
|
||||
* Trim the artists as needed.
|
||||
*/
|
||||
for (int i = 0, l = this.album.artists.length; i < l; i++)
|
||||
{
|
||||
this.album.artists[i] = this.album.artists[i].trim();
|
||||
}
|
||||
}
|
||||
if (!tag2.getGenreDescription().isEmpty())
|
||||
{
|
||||
this.album.genres = tag2.getGenreDescription().split(";");
|
||||
for (int i = 0, l = this.album.genres.length; i < l; i++)
|
||||
{
|
||||
this.album.genres[i] = this.album.genres[i].trim();
|
||||
}
|
||||
}
|
||||
if (!tag2.getYear().isEmpty())
|
||||
{
|
||||
this.album.year = Integer.parseInt(tag2.getYear());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new IllegalArgumentException("Invalid MP3 File", e);
|
||||
}
|
||||
catch (UnsupportedTagException | InvalidDataException e)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2021 William Hubbard. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package edu.regis.universeplayer.data;
|
||||
|
||||
import edu.regis.universeplayer.PlaybackInfo;
|
||||
import edu.regis.universeplayer.Player;
|
||||
import edu.regis.universeplayer.localPlayer.LocalPlayer;
|
||||
|
||||
import java.util.EventObject;
|
||||
|
||||
public class PlaybackEvent extends EventObject
|
||||
{
|
||||
private final PlaybackInfo info;
|
||||
|
||||
public PlaybackEvent(Player<? extends Song> player, PlaybackInfo playbackInfo)
|
||||
{
|
||||
super(player);
|
||||
this.info = playbackInfo;
|
||||
}
|
||||
|
||||
public PlaybackInfo getInfo()
|
||||
{
|
||||
return info;
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 William Hubbard. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package edu.regis.universeplayer.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Contains data for a song.
|
||||
*/
|
||||
public abstract class Song implements Comparable<Song>, Serializable
|
||||
{
|
||||
public String title;
|
||||
public String[] artists;
|
||||
public int trackNum;
|
||||
public int disc;
|
||||
public long duration;
|
||||
|
||||
/**
|
||||
* A reference to the album this song is part of.
|
||||
*/
|
||||
public Album album;
|
||||
|
||||
@Override
|
||||
public int compareTo(Song o)
|
||||
{
|
||||
if (o != null)
|
||||
{
|
||||
int comp = this.album != null ? this.album.compareTo(o.album) : o.album != null ? 1 : 0;
|
||||
if (comp == 0)
|
||||
{
|
||||
comp = Integer.compare(this.disc, o.disc);
|
||||
if (comp == 0)
|
||||
{
|
||||
comp = Integer.compare(this.trackNum, o.trackNum);
|
||||
if (comp == 0)
|
||||
{
|
||||
comp = this.title != null ? this.title.compareTo(o.title) : o.title != null ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return comp;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,14 @@
|
||||
package edu.regis.universeplayer.localPlayer;
|
||||
|
||||
import com.intervigil.wave.WaveReader;
|
||||
import edu.regis.universeplayer.PlaybackInfo;
|
||||
import edu.regis.universeplayer.PlaybackListener;
|
||||
import edu.regis.universeplayer.PlaybackStatus;
|
||||
import edu.regis.universeplayer.Player;
|
||||
import edu.regis.universeplayer.browserCommands.CommandConfirmation;
|
||||
import edu.regis.universeplayer.browserCommands.QueryFuture;
|
||||
import edu.regis.universeplayer.data.LocalSong;
|
||||
import edu.regis.universeplayer.data.PlaybackEvent;
|
||||
import edu.regis.universeplayer.data.Song;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -310,7 +312,7 @@ public class LocalPlayer implements Player<LocalSong>, MediaPlayerEventListener
|
||||
public void playing(MediaPlayer mediaPlayer)
|
||||
{
|
||||
logger.debug("Local player playing.");
|
||||
SwingUtilities.invokeLater(() -> this.listeners.forEach(playbackListener -> playbackListener.onPlaybackChanged(new PlaybackListener.PlaybackInfo(this, this.currentSong, mediaPlayer.status().time(), PlaybackStatus.PLAYING))));
|
||||
SwingUtilities.invokeLater(() -> this.listeners.forEach(playbackListener -> playbackListener.onPlaybackChanged(new PlaybackEvent(this, new PlaybackInfo(this.currentSong, mediaPlayer.status().time(), PlaybackStatus.PLAYING)))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -322,7 +324,7 @@ public class LocalPlayer implements Player<LocalSong>, MediaPlayerEventListener
|
||||
public void paused(MediaPlayer mediaPlayer)
|
||||
{
|
||||
logger.debug("Local player paused.");
|
||||
SwingUtilities.invokeLater(() -> this.listeners.forEach(playbackListener -> playbackListener.onPlaybackChanged(new PlaybackListener.PlaybackInfo(this, this.currentSong, mediaPlayer.status().time(), PlaybackStatus.PAUSED))));
|
||||
SwingUtilities.invokeLater(() -> this.listeners.forEach(playbackListener -> playbackListener.onPlaybackChanged(new PlaybackEvent(this, new PlaybackInfo(this.currentSong, mediaPlayer.status().time(), PlaybackStatus.PAUSED)))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -338,7 +340,7 @@ public class LocalPlayer implements Player<LocalSong>, MediaPlayerEventListener
|
||||
public void stopped(MediaPlayer mediaPlayer)
|
||||
{
|
||||
logger.debug("Local player stopped prematurely.");
|
||||
SwingUtilities.invokeLater(() -> this.listeners.forEach(playbackListener -> playbackListener.onPlaybackChanged(new PlaybackListener.PlaybackInfo(this, this.currentSong, mediaPlayer.status().time(), PlaybackStatus.STOPPED))));
|
||||
SwingUtilities.invokeLater(() -> this.listeners.forEach(playbackListener -> playbackListener.onPlaybackChanged(new PlaybackEvent(this, new PlaybackInfo(this.currentSong, mediaPlayer.status().time(), PlaybackStatus.STOPPED)))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -372,7 +374,7 @@ public class LocalPlayer implements Player<LocalSong>, MediaPlayerEventListener
|
||||
public void finished(MediaPlayer mediaPlayer)
|
||||
{
|
||||
logger.debug("Local player finished.");
|
||||
SwingUtilities.invokeLater(() -> this.listeners.forEach(playbackListener -> playbackListener.onPlaybackChanged(new PlaybackListener.PlaybackInfo(this, this.currentSong, mediaPlayer.status().time(), PlaybackStatus.FINISHED))));
|
||||
SwingUtilities.invokeLater(() -> this.listeners.forEach(playbackListener -> playbackListener.onPlaybackChanged(new PlaybackEvent(this, new PlaybackInfo(this.currentSong, mediaPlayer.status().time(), PlaybackStatus.FINISHED)))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -384,7 +386,7 @@ public class LocalPlayer implements Player<LocalSong>, MediaPlayerEventListener
|
||||
@Override
|
||||
public void timeChanged(MediaPlayer mediaPlayer, long newTime)
|
||||
{
|
||||
SwingUtilities.invokeLater(() -> this.listeners.forEach(playbackListener -> playbackListener.onPlaybackChanged(new PlaybackListener.PlaybackInfo(this, this.currentSong, newTime / 1000F, PlaybackStatus.PLAYING))));
|
||||
SwingUtilities.invokeLater(() -> this.listeners.forEach(playbackListener -> playbackListener.onPlaybackChanged(new PlaybackEvent(this, new PlaybackInfo(this.currentSong, newTime / 1000F, PlaybackStatus.PLAYING)))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@ package edu.regis.universeplayer.player;
|
||||
|
||||
import edu.regis.universeplayer.Player;
|
||||
import edu.regis.universeplayer.browser.Browser;
|
||||
import edu.regis.universeplayer.browser.InternetSong;
|
||||
import edu.regis.universeplayer.data.InternetSong;
|
||||
import edu.regis.universeplayer.data.Queue;
|
||||
import edu.regis.universeplayer.data.*;
|
||||
import edu.regis.universeplayer.localPlayer.LocalPlayer;
|
||||
@@ -22,9 +22,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* The Interface class serves as the primary GUI that the player interacts with.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
package edu.regis.universeplayer.player;
|
||||
|
||||
import edu.regis.universeplayer.browser.InternetSong;
|
||||
import edu.regis.universeplayer.data.InternetSong;
|
||||
import edu.regis.universeplayer.data.InternetSongProvider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
|
||||
package edu.regis.universeplayer.player;
|
||||
|
||||
import edu.regis.universeplayer.PlaybackInfo;
|
||||
import edu.regis.universeplayer.PlaybackListener;
|
||||
import edu.regis.universeplayer.PlaybackStatus;
|
||||
import edu.regis.universeplayer.Player;
|
||||
import edu.regis.universeplayer.data.PlaybackEvent;
|
||||
import edu.regis.universeplayer.data.Queue;
|
||||
import edu.regis.universeplayer.data.Song;
|
||||
import org.slf4j.Logger;
|
||||
@@ -323,17 +325,18 @@ public class PlayerControls extends JPanel implements Queue.SongChangeListener,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaybackChanged(PlaybackInfo status)
|
||||
public void onPlaybackChanged(PlaybackEvent status)
|
||||
{
|
||||
if (status.getSource() != null && status.getSource() == this.currentPlayer)
|
||||
{
|
||||
switch (status.getStatus())
|
||||
switch (status.getInfo().getStatus())
|
||||
{
|
||||
case PLAYING -> this.playButton.setIcon(PAUSE_ICON);
|
||||
case FINISHED -> Queue.getInstance().skipNext();
|
||||
case PAUSED, STOPPED, EMPTY -> this.playButton.setIcon(PLAY_ICON);
|
||||
}
|
||||
this.progress.setValue((int) status.getPlayTime());
|
||||
this.progress.setValue((int) status.getInfo().getPlayTime());
|
||||
this.progress.setMaximum((int) (status.getInfo().getSong().duration / 1000));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user