diff --git a/FModel/Properties/Settings.Designer.cs b/FModel/Properties/Settings.Designer.cs
index 68eae981..4dab1138 100644
--- a/FModel/Properties/Settings.Designer.cs
+++ b/FModel/Properties/Settings.Designer.cs
@@ -95,6 +95,18 @@ namespace FModel.Properties {
}
}
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string AudioPlayerDevice {
+ get {
+ return ((string)(this["AudioPlayerDevice"]));
+ }
+ set {
+ this["AudioPlayerDevice"] = value;
+ }
+ }
+
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
diff --git a/FModel/Properties/Settings.settings b/FModel/Properties/Settings.settings
index 6b790654..b4b4864a 100644
--- a/FModel/Properties/Settings.settings
+++ b/FModel/Properties/Settings.settings
@@ -17,9 +17,12 @@
True
-
- True
-
+
+ True
+
+
+
+
diff --git a/FModel/Utils/Keys.cs b/FModel/Utils/Keys.cs
index 69872aec..2910a99d 100644
--- a/FModel/Utils/Keys.cs
+++ b/FModel/Utils/Keys.cs
@@ -52,7 +52,7 @@ namespace FModel.Utils
{
// i can use TestAesKey here but that means it's gonna test here then right after to set the key
// so a try catch when setting the key seems better
- menuItem.PakFile.AesKey = sKey.ToBytesKey();
+ menuItem.PakFile.AesKey = sKey.Trim().ToBytesKey();
}
catch (System.Exception e)
{
@@ -72,7 +72,7 @@ namespace FModel.Utils
{
// i can use TestAesKey here but that means it's gonna test here then right after to set the key
// so a try catch when setting the key seems better
- menuItem.PakFile.AesKey = dKey.ToBytesKey();
+ menuItem.PakFile.AesKey = dKey.Trim().ToBytesKey();
}
catch (System.Exception e)
{
diff --git a/FModel/ViewModels/SoundPlayer/InputFileViewModel.cs b/FModel/ViewModels/SoundPlayer/InputFileViewModel.cs
index ea7ffa41..2213e7ac 100644
--- a/FModel/ViewModels/SoundPlayer/InputFileViewModel.cs
+++ b/FModel/ViewModels/SoundPlayer/InputFileViewModel.cs
@@ -1,4 +1,5 @@
using FModel.Windows.SoundPlayer.Visualization;
+using System.Collections.ObjectModel;
using System.Windows;
namespace FModel.ViewModels.SoundPlayer
@@ -32,18 +33,18 @@ namespace FModel.ViewModels.SoundPlayer
public class InputFileViewModel : PropertyChangedBase
{
- private Device _device = Device.GetDefaultDevice();
+ private ObservableCollection _devices = new ObservableCollection(Device.GetOutputDevices());
private bool _isEnabled = true;
private string _content;
private string _bytes;
private string _duration;
private float _volume = 0.5f;
- public Device Device
+ public ObservableCollection Devices
{
- get { return _device; }
+ get { return _devices; }
- set { this.SetProperty(ref this._device, value); }
+ set { this.SetProperty(ref this._devices, value); }
}
public bool IsEnabled
{
diff --git a/FModel/Windows/SoundPlayer/AudioPlayer.xaml b/FModel/Windows/SoundPlayer/AudioPlayer.xaml
index 4b05994c..0f8f8148 100644
--- a/FModel/Windows/SoundPlayer/AudioPlayer.xaml
+++ b/FModel/Windows/SoundPlayer/AudioPlayer.xaml
@@ -81,8 +81,8 @@
-
+
x.DeviceId == Properties.Settings.Default.AudioPlayerDevice).FirstOrDefault();
+ if (AudioDevices_CmbBox.SelectedIndex < 0) AudioDevices_CmbBox.SelectedIndex = 0;
+
if (spectrumAnalyzer == null)
spectrumAnalyzer = new UserControls.SpectrumAnalyzer(output);
if (timeline == null)
@@ -107,5 +112,19 @@ namespace FModel.Windows.SoundPlayer
PlayPauseImg.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/play.png"));
}
}
+
+ private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (sender is ComboBox c && c.SelectedItem is Device d)
+ {
+ Properties.Settings.Default.AudioPlayerDevice = d.DeviceId;
+ Properties.Settings.Default.Save();
+
+ if (output == null)
+ output = new OutputSource(d);
+ else
+ output.SwapDevice(d);
+ }
+ }
}
}
diff --git a/FModel/Windows/SoundPlayer/Visualization/OutputSource.cs b/FModel/Windows/SoundPlayer/Visualization/OutputSource.cs
index f29096d9..dff4a3e5 100644
--- a/FModel/Windows/SoundPlayer/Visualization/OutputSource.cs
+++ b/FModel/Windows/SoundPlayer/Visualization/OutputSource.cs
@@ -482,6 +482,35 @@ namespace FModel.Windows.SoundPlayer.Visualization
return false;
}
+ public bool SwapDevice(Device d)
+ {
+ if (_soundOut != null)
+ {
+ bool wasPlaying = IsPlaying;
+ bool wasPaused = Paused;
+ TimeSpan pos = Position;
+ outputDevice = d;
+
+ if (wasPlaying || wasPaused)
+ {
+ _soundOut.Stop();
+ }
+
+ LoadSoundOut();
+ _waveSource.SetPosition(pos);
+
+ if (wasPlaying)
+ _soundOut.Play();
+ else if (wasPaused)
+ {
+ _soundOut.Play();
+ _soundOut.Pause();
+ }
+ }
+
+ return true;
+ }
+
#endregion
#region Events