Fix queue and player bugs

This commit is contained in:
Max Isom 2020-03-23 19:40:54 -05:00
parent 95ea8e9ad3
commit 334a2bf0a0
2 changed files with 28 additions and 20 deletions

View file

@ -43,7 +43,7 @@ export default class {
if (isPlaying) { if (isPlaying) {
oldPosition = player.getPosition(); oldPosition = player.getPosition();
await player.forward(); player.manualForward();
} }
await player.seek(8); await player.seek(8);
@ -51,6 +51,7 @@ export default class {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {
setTimeout(async () => { setTimeout(async () => {
if (player.getCurrent()?.title === 'GO PACKERS!') {
player.removeCurrent(); player.removeCurrent();
if (isPlaying) { if (isPlaying) {
@ -59,6 +60,7 @@ export default class {
} else { } else {
player.disconnect(); player.disconnect();
} }
}
resolve(true); resolve(true);
}, 10000); }, 10000);

View file

@ -120,8 +120,10 @@ export default class {
} }
// Was disconnected, need to recreate stream // Was disconnected, need to recreate stream
if (!currentSong.isLive) {
return this.seek(this.getPosition()); return this.seek(this.getPosition());
} }
}
try { try {
const stream = await this.getStream(currentSong.url); const stream = await this.getStream(currentSong.url);
@ -160,8 +162,7 @@ export default class {
} }
async forward(): Promise<void> { async forward(): Promise<void> {
if (this.queuePosition < this.queueSize() + 1) { this.manualForward();
this.queuePosition++;
try { try {
if (this.getCurrent() && this.status !== STATUS.PAUSED) { if (this.getCurrent() && this.status !== STATUS.PAUSED) {
@ -174,6 +175,11 @@ export default class {
this.queuePosition--; this.queuePosition--;
throw error; throw error;
} }
}
manualForward(): void {
if (this.queuePosition < this.queue.length) {
this.queuePosition++;
} else { } else {
throw new Error('No songs in queue to forward to.'); throw new Error('No songs in queue to forward to.');
} }