diff --git a/src/nitro/sound/music/MusicController.ts b/src/nitro/sound/music/MusicController.ts index 2edce7f9..8fde79eb 100644 --- a/src/nitro/sound/music/MusicController.ts +++ b/src/nitro/sound/music/MusicController.ts @@ -444,7 +444,7 @@ export class MusicController implements IMusicController { this.notifySongPlaying(songData); } - this._musicPlayer.play(songData.songData, startPos, playLength); + this._musicPlayer.play(songData.songData, songData.id, startPos, playLength); if(priority > MusicPriorities.PRIORITY_ROOM_PLAYLIST) { Nitro.instance.soundManager.events.dispatchEvent(new NowPlayingEvent(NowPlayingEvent.NPE_USER_PLAY_SONG, priority, songData.id, -1)); diff --git a/src/nitro/sound/music/MusicPlayer.ts b/src/nitro/sound/music/MusicPlayer.ts index 0e829249..64053bf9 100644 --- a/src/nitro/sound/music/MusicPlayer.ts +++ b/src/nitro/sound/music/MusicPlayer.ts @@ -6,6 +6,7 @@ import { TraxData } from '../trax/TraxData'; export class MusicPlayer { private _currentSong: TraxData | undefined; + private _currentSongId: number; private _startPos: number; private _playLength: number; private _isPlaying: boolean; @@ -27,7 +28,7 @@ export class MusicPlayer this._cache = new Map(); } - public async play(song: string, startPos: number = 0, playLength: number = -1): Promise + public async play(song: string, currentSongId: number, startPos: number = 0, playLength: number = -1): Promise { this.reset(); @@ -35,6 +36,7 @@ export class MusicPlayer this._startPos = Math.trunc(startPos); this._playLength = playLength; this._currentPos = this._startPos; + this._currentSongId = currentSongId; //this.emit('loading'); await this.preload(); this._isPlaying = true; @@ -174,7 +176,7 @@ export class MusicPlayer { if(this._currentPos > this._playLength - 1) { - Nitro.instance.soundManager.events.dispatchEvent(new SoundManagerEvent(SoundManagerEvent.TRAX_SONG_COMPLETE, Nitro.instance.soundManager.musicController.getRoomItemPlaylist().nowPlayingSongId)); + Nitro.instance.soundManager.events.dispatchEvent(new SoundManagerEvent(SoundManagerEvent.TRAX_SONG_COMPLETE, this._currentSongId)); this.stop(); }