This commit is contained in:
dank074 2022-11-08 22:58:31 -06:00
parent 7ba1ecdcc1
commit 3086a8446f
2 changed files with 5 additions and 3 deletions

View File

@ -444,7 +444,7 @@ export class MusicController implements IMusicController
{ {
this.notifySongPlaying(songData); 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) if(priority > MusicPriorities.PRIORITY_ROOM_PLAYLIST)
{ {
Nitro.instance.soundManager.events.dispatchEvent(new NowPlayingEvent(NowPlayingEvent.NPE_USER_PLAY_SONG, priority, songData.id, -1)); Nitro.instance.soundManager.events.dispatchEvent(new NowPlayingEvent(NowPlayingEvent.NPE_USER_PLAY_SONG, priority, songData.id, -1));

View File

@ -6,6 +6,7 @@ import { TraxData } from '../trax/TraxData';
export class MusicPlayer export class MusicPlayer
{ {
private _currentSong: TraxData | undefined; private _currentSong: TraxData | undefined;
private _currentSongId: number;
private _startPos: number; private _startPos: number;
private _playLength: number; private _playLength: number;
private _isPlaying: boolean; private _isPlaying: boolean;
@ -27,7 +28,7 @@ export class MusicPlayer
this._cache = new Map<number, Howl>(); this._cache = new Map<number, Howl>();
} }
public async play(song: string, startPos: number = 0, playLength: number = -1): Promise<void> public async play(song: string, currentSongId: number, startPos: number = 0, playLength: number = -1): Promise<void>
{ {
this.reset(); this.reset();
@ -35,6 +36,7 @@ export class MusicPlayer
this._startPos = Math.trunc(startPos); this._startPos = Math.trunc(startPos);
this._playLength = playLength; this._playLength = playLength;
this._currentPos = this._startPos; this._currentPos = this._startPos;
this._currentSongId = currentSongId;
//this.emit('loading'); //this.emit('loading');
await this.preload(); await this.preload();
this._isPlaying = true; this._isPlaying = true;
@ -174,7 +176,7 @@ export class MusicPlayer
{ {
if(this._currentPos > this._playLength - 1) 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(); this.stop();
} }