fixing playlist track removal

This commit is contained in:
2024-11-24 18:13:01 +00:00
parent 16ba22d90b
commit 9601597cf6
3 changed files with 14 additions and 2 deletions

View File

@@ -9,6 +9,8 @@ COPY tsconfig.json tsconfig.app.json tsconfig.node.json vite.config.ts /srv/
COPY src /srv/src
COPY public /srv/public
COPY map /srv/map
COPY summon /srv/summon
COPY chromecast /srv/chromecast
COPY ./index.html /srv/
RUN npm run build

View File

@@ -1,6 +1,6 @@
import { VirtualFile } from "../FileSystem/types";
import { SoundGroupNode, SoundGroupNodeOptions } from "./SoundGroupNode";
import { MediaElementSoundNode } from "./SoundNode";
import { MediaElementSoundNode, SoundNode } from "./SoundNode";
export interface PlaylistGroupNodeOptions extends SoundGroupNodeOptions {
currentTrack: number;
@@ -13,7 +13,7 @@ export class PlaylistGroupNode extends SoundGroupNode<PlaylistGroupNodeOptions>
private intervalId?: number;
changeTrack(track: number) {
this.currentTrack.stop();
this.currentTrack?.stop();
(this.currentTrack as MediaElementSoundNode)?.seek(0);
this.soundNodes[this.options.currentTrack]?.stop();
this.options.currentTrack = track;
@@ -46,6 +46,15 @@ export class PlaylistGroupNode extends SoundGroupNode<PlaylistGroupNodeOptions>
}, 1000);
}
removeSoundNode(node: SoundNode) {
const index = this.soundNodes.indexOf(node);
if (index === this.options.currentTrack) {
this.options.currentTrack = 0;
this.options.currentTrackTime = 0;
}
super.removeSoundNode(node);
}
stop() {
this.currentTrack?.stop();
clearInterval(this.intervalId);

View File

@@ -66,6 +66,7 @@ export abstract class SoundGroupNode<T extends SoundGroupNodeOptions> {
}
removeSoundNode(node: SoundNode) {
node?.stop();
const index = this.soundNodes.indexOf(node);
if (index > -1) {
this.soundNodes.splice(index, 1);