aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/soundchan/TrackScheduler.java
diff options
context:
space:
mode:
authorBrandon <bwaggone@umich.edu>2018-04-21 15:38:57 -0400
committerBrandon <bwaggone@umich.edu>2018-04-21 15:38:57 -0400
commit0fe63e59569f161628574159a8f8d318abbe3e0e (patch)
tree94474465a4c727aa92dd9b5fca26b3184b5d05b4 /src/main/java/soundchan/TrackScheduler.java
parent70f6beee0fb9569e8549752e627929ae506c5e0c (diff)
downloadSoundChan-0fe63e59569f161628574159a8f8d318abbe3e0e.tar.gz
SoundChan-0fe63e59569f161628574159a8f8d318abbe3e0e.tar.bz2
SoundChan-0fe63e59569f161628574159a8f8d318abbe3e0e.zip
Fix bug
Diffstat (limited to 'src/main/java/soundchan/TrackScheduler.java')
-rw-r--r--src/main/java/soundchan/TrackScheduler.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/main/java/soundchan/TrackScheduler.java b/src/main/java/soundchan/TrackScheduler.java
index cc68335..cf7b1f8 100644
--- a/src/main/java/soundchan/TrackScheduler.java
+++ b/src/main/java/soundchan/TrackScheduler.java
@@ -46,14 +46,16 @@ public class TrackScheduler extends AudioEventAdapter {
public void playNow(AudioTrack track) {
AudioTrack currenlyPlaying = player.getPlayingTrack();
- AudioTrack cloned = currenlyPlaying.makeClone();
- cloned.setPosition(currenlyPlaying.getPosition());
-
- // Don't re-enqueue if its just a soundclip
- if(!(currenlyPlaying.getInfo().uri.contains(".mp3") || currenlyPlaying.getInfo().uri.contains(".wav")))
- // Re-enqueue the track
- queue.addFirst(cloned);
+ // If something is currently playing, pause it and put it back in the queue
+ if(currenlyPlaying != null) {
+ AudioTrack cloned = currenlyPlaying.makeClone();
+ cloned.setPosition(currenlyPlaying.getPosition());
+ // Don't re-enqueue if its just a soundclip
+ if (!(currenlyPlaying.getInfo().uri.contains(".mp3") || currenlyPlaying.getInfo().uri.contains(".wav")))
+ // Re-enqueue the track
+ queue.addFirst(cloned);
+ }
player.startTrack(track, false);
}