Prevent Music from deleting playlistsong if fading

This commit is contained in:
JappaWakka 2024-05-15 17:03:42 +02:00
parent 7c2ff10f33
commit 873411d40e
1 changed files with 6 additions and 2 deletions

View File

@ -45,7 +45,7 @@ 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 Then If MusicManager.Playlist.Count > 1 And MusicManager._isCurrentlyFading = False Then
MusicManager.Playlist.RemoveAt(0) MusicManager.Playlist.RemoveAt(0)
ElseIf MusicManager.EnableLooping = False AndAlso MusicManager.Playlist.Count > 0 Then ElseIf MusicManager.EnableLooping = False AndAlso MusicManager.Playlist.Count > 0 Then
MusicManager.Playlist.RemoveAt(0) MusicManager.Playlist.RemoveAt(0)
@ -137,6 +137,7 @@ Public Class MusicManager
' if the song that gets played after fading completed is an intro to another song ' if the song that gets played after fading completed is an intro to another song
Public Shared _isFadingIn As Boolean = False Public Shared _isFadingIn As Boolean = False
Private Shared _isFadingOut As Boolean = False Private Shared _isFadingOut As Boolean = False
Public Shared _isCurrentlyFading As Boolean = False
' NAudio properties ' NAudio properties
Public Shared outputDevice As WaveOutEvent Public Shared outputDevice As WaveOutEvent
Public Shared audioFileOGG As VorbisWaveReader Public Shared audioFileOGG As VorbisWaveReader
@ -253,6 +254,7 @@ Public Class MusicManager
' fading ' fading
If _isFadingOut Then If _isFadingOut Then
_isCurrentlyFading = True
Volume -= _fadeSpeed Volume -= _fadeSpeed
If Volume <= 0F Then If Volume <= 0F Then
@ -276,10 +278,12 @@ Public Class MusicManager
Else Else
Volume = 1.0F Volume = 1.0F
End If End If
_isCurrentlyFading = False
Else Else
' no song found, do not fade into anything ' no song found, do not fade into anything
_isFadingIn = False _isFadingIn = False
_isCurrentlyFading = False
ClearCurrentlyPlaying() ClearCurrentlyPlaying()
If Muted = True Then If Muted = True Then
Volume = 0.0F Volume = 0.0F
@ -350,7 +354,7 @@ Public Class MusicManager
Private Shared Sub Play(song As SongContainer) Private Shared Sub Play(song As SongContainer)
If Not song Is Nothing Then If Not song Is Nothing Then
Logger.Debug($"Play song [{song.Name}]") Logger.Debug($"Play song [{song.song}]")
If outputDevice IsNot Nothing Then If outputDevice IsNot Nothing Then
outputDevice.Dispose() outputDevice.Dispose()
End If End If