aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Isom <[email protected]>2020-03-23 19:40:54 -0500
committerMax Isom <[email protected]>2020-03-23 19:40:54 -0500
commit334a2bf0a050199089ac41ebacd4fa897fefc05f (patch)
treef69395af3efa31cb1f7fbc3c66b5b99d4a912d8c
parent95ea8e9ad3c81d29cc38977867179b4a61c5eee5 (diff)
downloadmuse-334a2bf0a050199089ac41ebacd4fa897fefc05f.tar.xz
muse-334a2bf0a050199089ac41ebacd4fa897fefc05f.zip
Fix queue and player bugs
-rw-r--r--src/services/natural-language-commands.ts18
-rw-r--r--src/services/player.ts32
2 files changed, 29 insertions, 21 deletions
diff --git a/src/services/natural-language-commands.ts b/src/services/natural-language-commands.ts
index 7171a87..ce89ce0 100644
--- a/src/services/natural-language-commands.ts
+++ b/src/services/natural-language-commands.ts
@@ -43,7 +43,7 @@ export default class {
if (isPlaying) {
oldPosition = player.getPosition();
- await player.forward();
+ player.manualForward();
}
await player.seek(8);
@@ -51,13 +51,15 @@ export default class {
return new Promise((resolve, reject) => {
try {
setTimeout(async () => {
- player.removeCurrent();
-
- if (isPlaying) {
- await player.back();
- await player.seek(oldPosition);
- } else {
- player.disconnect();
+ if (player.getCurrent()?.title === 'GO PACKERS!') {
+ player.removeCurrent();
+
+ if (isPlaying) {
+ await player.back();
+ await player.seek(oldPosition);
+ } else {
+ player.disconnect();
+ }
}
resolve(true);
diff --git a/src/services/player.ts b/src/services/player.ts
index 1f24d93..d592aac 100644
--- a/src/services/player.ts
+++ b/src/services/player.ts
@@ -120,7 +120,9 @@ export default class {
}
// Was disconnected, need to recreate stream
- return this.seek(this.getPosition());
+ if (!currentSong.isLive) {
+ return this.seek(this.getPosition());
+ }
}
try {
@@ -160,20 +162,24 @@ export default class {
}
async forward(): Promise<void> {
- if (this.queuePosition < this.queueSize() + 1) {
- this.queuePosition++;
+ this.manualForward();
- try {
- if (this.getCurrent() && this.status !== STATUS.PAUSED) {
- await this.play();
- } else {
- this.status = STATUS.PAUSED;
- this.disconnect();
- }
- } catch (error) {
- this.queuePosition--;
- throw error;
+ try {
+ if (this.getCurrent() && this.status !== STATUS.PAUSED) {
+ await this.play();
+ } else {
+ this.status = STATUS.PAUSED;
+ this.disconnect();
}
+ } catch (error) {
+ this.queuePosition--;
+ throw error;
+ }
+ }
+
+ manualForward(): void {
+ if (this.queuePosition < this.queue.length) {
+ this.queuePosition++;
} else {
throw new Error('No songs in queue to forward to.');
}