mirror of
https://github.com/aaru-dps/RedBookPlayer.git
synced 2025-12-16 11:14:39 +00:00
Disconnect volume from Init
This commit is contained in:
@@ -398,6 +398,8 @@ namespace RedBookPlayer.GUI.ViewModels
|
||||
|
||||
// Initialize Player
|
||||
_player = new Player(App.Settings.NumberOfDiscs, App.Settings.Volume);
|
||||
_player.PropertyChanged += PlayerStateChanged;
|
||||
PlayerStateChanged(this, null);
|
||||
PlayerState = PlayerState.NoDisc;
|
||||
}
|
||||
|
||||
@@ -417,10 +419,7 @@ namespace RedBookPlayer.GUI.ViewModels
|
||||
// Attempt to initialize Player
|
||||
_player.Init(path, playerOptions, opticalDiscOptions, autoPlay);
|
||||
if(_player.Initialized)
|
||||
{
|
||||
_player.PropertyChanged += PlayerStateChanged;
|
||||
PlayerStateChanged(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
#region Playback (UI)
|
||||
|
||||
@@ -66,22 +66,23 @@ namespace RedBookPlayer.Models.Audio
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
/// <param name="read">ReadFunction to use during decoding</param>
|
||||
/// <param name="defaultVolume">Default volume between 0 and 100 to use when starting playback</param>
|
||||
public SoundOutput(int defaultVolume = 100) => Volume = defaultVolume;
|
||||
public SoundOutput(PlayerSource.ReadFunction read, int defaultVolume = 100)
|
||||
{
|
||||
Volume = defaultVolume;
|
||||
SetupAudio(read);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the output with a given image
|
||||
/// </summary>
|
||||
/// <param name="read">ReadFunction to use during decoding</param>
|
||||
/// <param name="autoPlay">True if playback should begin immediately, false otherwise</param>
|
||||
public void Init(PlayerSource.ReadFunction read, bool autoPlay)
|
||||
public void Init(bool autoPlay)
|
||||
{
|
||||
// Reset initialization
|
||||
Initialized = false;
|
||||
|
||||
// Setup the audio output
|
||||
SetupAudio(read);
|
||||
|
||||
// Initialize playback, if necessary
|
||||
if(autoPlay)
|
||||
_soundOut.Play();
|
||||
@@ -164,18 +165,11 @@ namespace RedBookPlayer.Models.Audio
|
||||
/// <param name="read">ReadFunction to use during decoding</param>
|
||||
private void SetupAudio(PlayerSource.ReadFunction read)
|
||||
{
|
||||
if(_source == null)
|
||||
{
|
||||
_source = new PlayerSource(read);
|
||||
if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
_soundOut = new Linux.AudioBackend(_source);
|
||||
else if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
_soundOut = new Windows.AudioBackend(_source);
|
||||
}
|
||||
else
|
||||
{
|
||||
_soundOut.Stop();
|
||||
}
|
||||
_source = new PlayerSource(read);
|
||||
if(RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
_soundOut = new Linux.AudioBackend(_source);
|
||||
else if(RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
_soundOut = new Windows.AudioBackend(_source);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -352,7 +352,8 @@ namespace RedBookPlayer.Models.Hardware
|
||||
_currentDisc = 0;
|
||||
|
||||
_filterStage = new FilterStage();
|
||||
_soundOutput = new SoundOutput(defaultVolume);
|
||||
_soundOutput = new SoundOutput(ProviderRead, defaultVolume);
|
||||
_soundOutput.PropertyChanged += SoundOutputStateChanged;
|
||||
|
||||
_availableTrackList = new Dictionary<int, List<int>>();
|
||||
for(int i = 0; i < _numberOfDiscs; i++)
|
||||
@@ -400,13 +401,10 @@ namespace RedBookPlayer.Models.Hardware
|
||||
_filterStage.SetupFilters();
|
||||
|
||||
// Initialize the sound output
|
||||
_soundOutput.Init(ProviderRead, autoPlay);
|
||||
_soundOutput.Init(autoPlay);
|
||||
if(_soundOutput == null || !_soundOutput.Initialized)
|
||||
return;
|
||||
|
||||
// Add event handling for the sound output
|
||||
_soundOutput.PropertyChanged += SoundOutputStateChanged;
|
||||
|
||||
// Load in the track list for the current disc
|
||||
LoadTrackList();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user