Fixed the fast forward/slower music bug

This commit is contained in:
JappaWakka 2022-06-26 20:21:10 +02:00
parent 322ca3e5c4
commit 76484c89b1
1 changed files with 30 additions and 16 deletions

View File

@ -49,19 +49,24 @@ Public Class LoopStream
Dim IntroSongName As String = "intro\" & MusicManager._afterBattleIntroSong.Name Dim IntroSongName As String = "intro\" & MusicManager._afterBattleIntroSong.Name
Dim IntroSong As SongContainer = MusicManager.GetSong(IntroSongName) Dim IntroSong As SongContainer = MusicManager.GetSong(IntroSongName)
If IntroSong IsNot Nothing Then If IntroSong IsNot Nothing Then
If IntroSong.AudioType = ".ogg" Then If IntroSong.Origin = MusicManager.GetSong(MusicManager._afterBattleIntroSong.Name).Origin Then
_sourceStream = New VorbisWaveReader(IntroSong.Song) If IntroSong.AudioType = ".ogg" Then
ElseIf IntroSong.AudioType = ".mp3" Then _sourceStream = New VorbisWaveReader(IntroSong.Song)
_sourceStream = New Mp3FileReader(IntroSong.Song) ElseIf IntroSong.AudioType = ".mp3" Then
ElseIf IntroSong.AudioType = ".wma" Then _sourceStream = New Mp3FileReader(IntroSong.Song)
_sourceStream = New MediaFoundationReader(IntroSong.Song) ElseIf IntroSong.AudioType = ".wma" Then
_sourceStream = New MediaFoundationReader(IntroSong.Song)
End If
_enableLooping = False
_sourceStream.Position = 0
MusicManager._introContinueSong = MusicManager._afterBattleIntroSong.Name
MusicManager._isIntroStarted = True
MusicManager._afterBattleIntroSong = Nothing
MusicManager._currentSongExists = True
MusicManager._currentSongName = IntroSong.Name
MusicManager._currentSong = IntroSong
Logger.Debug($"Play song [{IntroSong.Name}]")
End If End If
_enableLooping = False
_sourceStream.Position = 0
MusicManager._introContinueSong = MusicManager._afterBattleIntroSong.Name
MusicManager._isIntroStarted = True
MusicManager._afterBattleIntroSong = Nothing
Logger.Debug($"Play song [{IntroSong.Name}]")
Else Else
Dim ContinueSong As SongContainer = MusicManager.GetSong(MusicManager._afterBattleIntroSong.Name) Dim ContinueSong As SongContainer = MusicManager.GetSong(MusicManager._afterBattleIntroSong.Name)
If ContinueSong.AudioType = ".ogg" Then If ContinueSong.AudioType = ".ogg" Then
@ -75,7 +80,11 @@ Public Class LoopStream
_sourceStream.Position = 0 _sourceStream.Position = 0
MusicManager._isIntroStarted = False MusicManager._isIntroStarted = False
MusicManager._afterBattleIntroSong = Nothing MusicManager._afterBattleIntroSong = Nothing
MusicManager._currentSongExists = True
MusicManager._currentSongName = ContinueSong.Name
MusicManager._currentSong = ContinueSong
Logger.Debug($"Play song [{ContinueSong.Name}]") Logger.Debug($"Play song [{ContinueSong.Name}]")
End If End If
Else Else
If MusicManager._isIntroStarted = True Then If MusicManager._isIntroStarted = True Then
@ -91,6 +100,9 @@ Public Class LoopStream
End If End If
_enableLooping = True _enableLooping = True
_sourceStream.Position = 0 _sourceStream.Position = 0
MusicManager._currentSongExists = True
MusicManager._currentSongName = IntroContinueSong.Name
MusicManager._currentSong = IntroContinueSong
Else Else
If MusicManager.GetSong("silence").AudioType = ".ogg" Then If MusicManager.GetSong("silence").AudioType = ".ogg" Then
_sourceStream = New VorbisWaveReader(MusicManager.GetSong("silence").Song) _sourceStream = New VorbisWaveReader(MusicManager.GetSong("silence").Song)
@ -101,6 +113,9 @@ Public Class LoopStream
End If End If
_enableLooping = True _enableLooping = True
_sourceStream.Position = 0 _sourceStream.Position = 0
MusicManager._currentSongExists = False
MusicManager._currentSong = Nothing
MusicManager._currentSongName = "silence"
End If End If
MusicManager._fadeIntoIntro = False MusicManager._fadeIntoIntro = False
Else Else
@ -129,10 +144,10 @@ Public Class MusicManager
Public Shared _isLooping As Boolean = False Public Shared _isLooping As Boolean = False
' currently playing song ' currently playing song
Private Shared _currentSongName As String = NO_MUSIC Public Shared _currentSongName As String = NO_MUSIC
' if the song in _currentSong is an actual existing song ' if the song in _currentSong is an actual existing song
Private Shared _currentSongExists As Boolean = False Public Shared _currentSongExists As Boolean = False
Private Shared _currentSong As SongContainer = Nothing Public Shared _currentSong As SongContainer = Nothing
Public Shared _afterBattleIntroSong As SongContainer = Nothing Public Shared _afterBattleIntroSong As SongContainer = Nothing
' time until music playback is paused for sound effect ' time until music playback is paused for sound effect
@ -552,7 +567,6 @@ Public Class MusicManager
End Function End Function
Private Shared Function GetSongName(song As String) As String Private Shared Function GetSongName(song As String) As String
Dim key = song.ToLowerInvariant() Dim key = song.ToLowerInvariant()
Dim aliasMap = SongAliasMap Dim aliasMap = SongAliasMap