feat: Save previous audio information

This commit is contained in:
2024-08-18 15:48:12 +07:00
parent 3fbaf7a7b4
commit 738a9b710b

View File

@@ -16,6 +16,7 @@ export class Player {
private paused: boolean = false;
private currentAudioInformation: AudioInformation | null = null;
private loopMode: LoopMode = LoopMode.None;
private previousAudioInformation: AudioInformation | null = null;
public _stream: SeekableStream | null = null;
private _skipFlag: boolean = false;
@@ -67,6 +68,8 @@ export class Player {
this._stream.destroy();
}
this.previousAudioInformation = this.currentAudioInformation;
if (this.loopMode === LoopMode.Current) {
this._createStream(
this.currentAudioInformation as AudioInformation,
@@ -116,6 +119,10 @@ export class Player {
return await this.currentProvider.getInformation(url);
}
public getPreviousAudioInformation() {
return this.previousAudioInformation;
}
public async play(url: string, seekTime: number = 0) {
const information = await this.getInformation(url);