Failsafe for no usable audio devices
This commit is contained in:
parent
96f6bc2a42
commit
3414d31b62
|
@ -346,7 +346,7 @@ Public Class MusicManager
|
||||||
If Not song Is Nothing Then
|
If Not song Is Nothing Then
|
||||||
|
|
||||||
Logger.Debug($"Play song [{song.Name}]")
|
Logger.Debug($"Play song [{song.Name}]")
|
||||||
If Not outputDevice Is Nothing Then
|
If outputDevice IsNot Nothing Then
|
||||||
outputDevice.Dispose()
|
outputDevice.Dispose()
|
||||||
End If
|
End If
|
||||||
outputDevice = New WaveOutEvent()
|
outputDevice = New WaveOutEvent()
|
||||||
|
@ -363,9 +363,16 @@ Public Class MusicManager
|
||||||
audioFileWMA = New MediaFoundationReader(song.Song)
|
audioFileWMA = New MediaFoundationReader(song.Song)
|
||||||
_stream = New NAudio.Wave.WaveChannel32(New LoopStream(audioFileWMA, song.IsLoop))
|
_stream = New NAudio.Wave.WaveChannel32(New LoopStream(audioFileWMA, song.IsLoop))
|
||||||
End If
|
End If
|
||||||
outputDevice.Init(_stream)
|
Try
|
||||||
If Paused = False Then
|
outputDevice.Init(_stream)
|
||||||
outputDevice.Play()
|
Catch ex As Exception
|
||||||
|
Logger.Log(Logger.LogTypes.ErrorMessage, "No usable audio device")
|
||||||
|
outputDevice = Nothing
|
||||||
|
End Try
|
||||||
|
If outputDevice IsNot Nothing Then
|
||||||
|
If Paused = False Then
|
||||||
|
outputDevice.Play()
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
_stream.Volume = Volume * MasterVolume
|
_stream.Volume = Volume * MasterVolume
|
||||||
_currentSongName = song.Name
|
_currentSongName = song.Name
|
||||||
|
|
Loading…
Reference in New Issue