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