mirror of
https://github.com/P3D-Legacy/P3D-Legacy.git
synced 2025-07-26 23:34:58 +02:00
[MusicManager Fixes]
Fix for the game taking longer to resume after pausing on a map without music Fix for audible gaps between intros and regular songs
This commit is contained in:
parent
9244a18653
commit
621a6bc364
@ -45,10 +45,24 @@ 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._isIntroStarted = True Then
|
||||||
|
Dim IntroContinueSong As SongContainer = MusicManager.GetSong(MusicManager._introContinueSong)
|
||||||
|
If IntroContinueSong IsNot Nothing Then
|
||||||
|
_sourceStream = New VorbisWaveReader(IntroContinueSong.Song)
|
||||||
|
_enableLooping = True
|
||||||
|
_sourceStream.Position = 0
|
||||||
|
Else
|
||||||
|
_sourceStream = New VorbisWaveReader(MusicManager.GetSong("silence").Song)
|
||||||
|
_enableLooping = True
|
||||||
|
_sourceStream.Position = 0
|
||||||
|
End If
|
||||||
|
MusicManager._isIntroStarted = False
|
||||||
|
Else
|
||||||
Exit While
|
Exit While
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
End If
|
||||||
totalBytesRead += bytesRead
|
totalBytesRead += bytesRead
|
||||||
End While
|
End While
|
||||||
|
|
||||||
@ -57,8 +71,8 @@ Public Class LoopStream
|
|||||||
End Class
|
End Class
|
||||||
Public Class MusicManager
|
Public Class MusicManager
|
||||||
|
|
||||||
Private Const NO_MUSIC As String = "*nomusic*" ' contains * as character, which cannot be in a filename
|
|
||||||
Private Const DEFAULT_FADE_SPEED As Single = 0.02F
|
Private Const DEFAULT_FADE_SPEED As Single = 0.02F
|
||||||
|
Private Const NO_MUSIC As String = "silence"
|
||||||
|
|
||||||
Private Shared _songs As Dictionary(Of String, SongContainer) = New Dictionary(Of String, SongContainer)()
|
Private Shared _songs As Dictionary(Of String, SongContainer) = New Dictionary(Of String, SongContainer)()
|
||||||
Public Shared Property Volume As Single = 1.0F
|
Public Shared Property Volume As Single = 1.0F
|
||||||
@ -80,9 +94,9 @@ Public Class MusicManager
|
|||||||
' time until the intro of a song plays
|
' time until the intro of a song plays
|
||||||
Private Shared _introMuteTime As Date
|
Private Shared _introMuteTime As Date
|
||||||
Public Shared _introEndTime As Date
|
Public Shared _introEndTime As Date
|
||||||
Private Shared _isIntroStarted As Boolean = False
|
Public Shared _isIntroStarted As Boolean = False
|
||||||
' song that gets played after the intro finished
|
' song that gets played after the intro finished
|
||||||
Private Shared _introContinueSong As String
|
Public Shared _introContinueSong As String
|
||||||
|
|
||||||
' song that plays after fading is finished
|
' song that plays after fading is finished
|
||||||
Private Shared _nextSong As String
|
Private Shared _nextSong As String
|
||||||
@ -230,8 +244,7 @@ Public Class MusicManager
|
|||||||
Volume = 1.0F
|
Volume = 1.0F
|
||||||
End If
|
End If
|
||||||
If _nextSong = NO_MUSIC Then
|
If _nextSong = NO_MUSIC Then
|
||||||
_nextSong = ""
|
_nextSong = "Silence"
|
||||||
MusicManager.Stop()
|
|
||||||
End If
|
End If
|
||||||
|
|
||||||
End If
|
End If
|
||||||
@ -252,16 +265,16 @@ Public Class MusicManager
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
' intro
|
' intro
|
||||||
If _isIntroStarted Then
|
' If _isIntroStarted Then
|
||||||
If Paused = False Then
|
' If Paused = False Then
|
||||||
If Date.Now >= _introEndTime Then
|
'If Date.Now >= _introEndTime Then
|
||||||
Dim song = GetSong(_introContinueSong)
|
'Dim song = GetSong(_introContinueSong)
|
||||||
_isLooping = True
|
'_isLooping = True
|
||||||
_isIntroStarted = False
|
'_isIntroStarted = False
|
||||||
Play(song)
|
'Play(song)
|
||||||
End If
|
'End If
|
||||||
End If
|
'End If
|
||||||
End If
|
'End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If Core.GameInstance.IsActive AndAlso _lastVolume <> (Volume * MasterVolume) Then
|
If Core.GameInstance.IsActive AndAlso _lastVolume <> (Volume * MasterVolume) Then
|
||||||
@ -448,7 +461,7 @@ Public Class MusicManager
|
|||||||
End If
|
End If
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Private Shared Function GetSong(songName As String) As SongContainer
|
Public Shared Function GetSong(songName As String) As SongContainer
|
||||||
Dim key = GetSongName(songName)
|
Dim key = GetSongName(songName)
|
||||||
|
|
||||||
If _songs.ContainsKey(key) = True Then
|
If _songs.ContainsKey(key) = True Then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user