Prevent next song playing before fade done

This commit is contained in:
JappaWakka 2024-05-15 17:08:45 +02:00
parent 873411d40e
commit b48debe4e2
1 changed files with 37 additions and 35 deletions

View File

@ -45,43 +45,45 @@ Public Class LoopStream
_sourceStream.Position = 0 _sourceStream.Position = 0
Else Else
If Not _sourceStream.Position = 0 Then If Not _sourceStream.Position = 0 Then
If MusicManager.Playlist.Count > 1 And MusicManager._isCurrentlyFading = False Then If MusicManager._isCurrentlyFading = False Then
MusicManager.Playlist.RemoveAt(0) If MusicManager.Playlist.Count > 1 Then
ElseIf MusicManager.EnableLooping = False AndAlso MusicManager.Playlist.Count > 0 Then MusicManager.Playlist.RemoveAt(0)
MusicManager.Playlist.RemoveAt(0) ElseIf MusicManager.EnableLooping = False AndAlso MusicManager.Playlist.Count > 0 Then
End If MusicManager.Playlist.RemoveAt(0)
Dim NextSong As SongContainer = Nothing End If
If MusicManager.Playlist.Count > 0 Then Dim NextSong As SongContainer = Nothing
NextSong = MusicManager.Playlist(0) If MusicManager.Playlist.Count > 0 Then
End If NextSong = MusicManager.Playlist(0)
If NextSong IsNot Nothing Then End If
Logger.Debug($"Play song [{NextSong.Name}]") If NextSong IsNot Nothing Then
_sourceStream.Dispose() Logger.Debug($"Play song [{NextSong.Name}]")
_sourceStream.Dispose()
If NextSong.AudioType = ".ogg" Then If NextSong.AudioType = ".ogg" Then
_sourceStream = New VorbisWaveReader(NextSong.Song) _sourceStream = New VorbisWaveReader(NextSong.Song)
ElseIf NextSong.AudioType = ".mp3" Then ElseIf NextSong.AudioType = ".mp3" Then
_sourceStream = New Mp3FileReader(NextSong.Song) _sourceStream = New Mp3FileReader(NextSong.Song)
ElseIf NextSong.AudioType = ".wma" Then ElseIf NextSong.AudioType = ".wma" Then
_sourceStream = New MediaFoundationReader(NextSong.Song) _sourceStream = New MediaFoundationReader(NextSong.Song)
End If
_sourceStream.Position = 0
MusicManager._currentSongName = NextSong.Name
MusicManager._currentSong = NextSong
_enableLooping = NextSong.IsLoop
Else
If MusicManager.GetSong("silence").AudioType = ".ogg" Then
_sourceStream = New VorbisWaveReader(MusicManager.GetSong("silence").Song)
ElseIf MusicManager.GetSong("silence").AudioType = ".mp3" Then
_sourceStream = New Mp3FileReader(MusicManager.GetSong("silence").Song)
ElseIf MusicManager.GetSong("silence").AudioType = ".wma" Then
_sourceStream = New MediaFoundationReader(MusicManager.GetSong("silence").Song)
End If
_enableLooping = True
_sourceStream.Position = 0
MusicManager._currentSong = Nothing
MusicManager._currentSongName = "silence"
Logger.Debug($"Play song [silence]")
End If End If
_sourceStream.Position = 0
MusicManager._currentSongName = NextSong.Name
MusicManager._currentSong = NextSong
_enableLooping = NextSong.IsLoop
Else
If MusicManager.GetSong("silence").AudioType = ".ogg" Then
_sourceStream = New VorbisWaveReader(MusicManager.GetSong("silence").Song)
ElseIf MusicManager.GetSong("silence").AudioType = ".mp3" Then
_sourceStream = New Mp3FileReader(MusicManager.GetSong("silence").Song)
ElseIf MusicManager.GetSong("silence").AudioType = ".wma" Then
_sourceStream = New MediaFoundationReader(MusicManager.GetSong("silence").Song)
End If
_enableLooping = True
_sourceStream.Position = 0
MusicManager._currentSong = Nothing
MusicManager._currentSongName = "silence"
Logger.Debug($"Play song [silence]")
End If End If
Else Else
Exit While Exit While