summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2019-06-06 19:55:02 +0100
committersr55 <[email protected]>2019-06-06 19:55:02 +0100
commitb0fce31fb6da40a98ef9af26845f67d81819f5b4 (patch)
tree9c7092ba897f205121fe41ff45cf9908e4344b0e /win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
parent0835cd60e3ecba9cad213109c80d64c42448367d (diff)
WinGui: Add a "Test" button to the When Done Audio options. Also log the "MediaFailed" event to the log otherwise we get silent failures. #2130
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs26
1 files changed, 26 insertions, 0 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
index 06500c309..06629ece2 100644
--- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
@@ -16,6 +16,7 @@ namespace HandBrakeWPF.ViewModels
using System.IO;
using System.Linq;
using System.Windows;
+ using System.Windows.Media;
using Caliburn.Micro;
@@ -1410,6 +1411,31 @@ namespace HandBrakeWPF.ViewModels
this.WhenDoneAudioFile = Path.GetFileNameWithoutExtension(dialog.FileName);
this.WhenDoneAudioFileFullPath = dialog.FileName;
}
+ else
+ {
+ this.WhenDoneAudioFile = null;
+ this.WhenDoneAudioFileFullPath = null;
+ }
+ }
+
+ public void PlayWhenDoneFile()
+ {
+ if (!string.IsNullOrEmpty(this.WhenDoneAudioFileFullPath) && File.Exists(this.WhenDoneAudioFileFullPath))
+ {
+ var uri = new Uri(this.WhenDoneAudioFileFullPath, UriKind.RelativeOrAbsolute);
+ var player = new MediaPlayer();
+ player.Open(uri);
+ player.Play();
+ player.MediaFailed += (object sender, ExceptionEventArgs e) => { Debug.WriteLine(e); };
+ }
+ else
+ {
+ this.errorService.ShowMessageBox(
+ Resources.OptionsView_MediaFileNotSet,
+ Resources.Error,
+ MessageBoxButton.OK,
+ MessageBoxImage.Error);
+ }
}
#endregion