From: sr55 Date: Thu, 16 Mar 2017 21:00:37 +0000 (+0000) Subject: WinGui: Add a new option to play Sound when queue or single encode completes X-Git-Tag: 1.1.0~634 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c84a0f1019158708c0d3a1d33aef196eeac944ad;p=handbrake WinGui: Add a new option to play Sound when queue or single encode completes --- diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs index 35d2f6548..0fee65fc9 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs @@ -1482,6 +1482,15 @@ namespace HandBrakeWPF.Properties { } } + /// + /// Looks up a localized string similar to Play a sound when the queue or single encode completes:. + /// + public static string OptionsView_PlaySoundWhenDone { + get { + return ResourceManager.GetString("OptionsView_PlaySoundWhenDone", resourceCulture); + } + } + /// /// Looks up a localized string similar to Show the encode status in the application title bar.. /// diff --git a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx index 33f0658df..f6c92ea61 100644 --- a/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx +++ b/win/CS/HandBrakeWPF/Properties/ResourcesUI.resx @@ -896,4 +896,7 @@ This will not affect your current settings in the Subtitle tab. Show the encode status in the application title bar. + + Play a sound when the queue or single encode completes: + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/PrePostActionService.cs b/win/CS/HandBrakeWPF/Services/PrePostActionService.cs index 4e3f4f30f..033b90f96 100644 --- a/win/CS/HandBrakeWPF/Services/PrePostActionService.cs +++ b/win/CS/HandBrakeWPF/Services/PrePostActionService.cs @@ -11,7 +11,9 @@ namespace HandBrakeWPF.Services { using System; using System.Diagnostics; + using System.IO; using System.Windows.Forms; + using System.Windows.Media; using Caliburn.Micro; @@ -129,6 +131,18 @@ namespace HandBrakeWPF.Services return; } + if (this.userSettingService.GetUserSetting(UserSettingConstants.PlaySoundWhenDone)) + { + string filePath = this.userSettingService.GetUserSetting(UserSettingConstants.WhenDoneAudioFile); + if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath)) + { + var uri = new Uri(filePath, UriKind.RelativeOrAbsolute); + var player = new MediaPlayer(); + player.Open(uri); + player.Play(); + } + } + if (this.userSettingService.GetUserSetting(UserSettingConstants.WhenCompleteAction) == "Do nothing") { return; diff --git a/win/CS/HandBrakeWPF/UserSettingConstants.cs b/win/CS/HandBrakeWPF/UserSettingConstants.cs index a47c18583..09bc63d83 100644 --- a/win/CS/HandBrakeWPF/UserSettingConstants.cs +++ b/win/CS/HandBrakeWPF/UserSettingConstants.cs @@ -236,6 +236,16 @@ namespace HandBrakeWPF /// public const string ShowStatusInTitleBar = "ShowStatusInTitleBar"; + /// + /// Setting to turn on/off the ability to play a sound when an encode or queue is done. + /// + public static string PlaySoundWhenDone = "PlaySoundWhenDone"; + + /// + /// Setting to store the file to play when done. + /// + public static string WhenDoneAudioFile = "WhenDoneAudioFile"; + #endregion } } \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index da9a0e8b5..45cdcbd1a 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -28,6 +28,8 @@ namespace HandBrakeWPF.ViewModels using HandBrakeWPF.Utilities; using HandBrakeWPF.ViewModels.Interfaces; + using Microsoft.Win32; + using Ookii.Dialogs.Wpf; using Execute = Caliburn.Micro.Execute; @@ -73,7 +75,7 @@ namespace HandBrakeWPF.ViewModels private int selectedVerbosity; private bool sendFileAfterEncode; private string sendFileTo; - private string sendFileToPath; + private string sendFileToPath; private string vlcPath; private string whenDone; private BindingList whenDoneOptions = new BindingList(); @@ -93,9 +95,12 @@ namespace HandBrakeWPF.ViewModels private bool pauseOnLowDiskspace; private long pauseOnLowDiskspaceLevel; private bool useQsvDecodeForNonQsvEnc; - private bool showStatusInTitleBar; + private string whenDoneAudioFile; + + private bool playSoundWhenDone; + #endregion #region Constructors and Destructors @@ -350,7 +355,6 @@ namespace HandBrakeWPF.ViewModels } } - /// /// Gets or sets a value indicating whether to show encode status in the tile bar. /// @@ -367,7 +371,46 @@ namespace HandBrakeWPF.ViewModels this.NotifyOfPropertyChange(() => this.ShowStatusInTitleBar); } } - + + /// + /// When Done Audio File + /// + public string WhenDoneAudioFile + { + get + { + return this.whenDoneAudioFile; + } + set + { + if (value == this.whenDoneAudioFile) return; + this.whenDoneAudioFile = value; + this.NotifyOfPropertyChange(() => this.WhenDoneAudioFile); + } + } + + /// + /// When Done Audio File - File Path + /// + public string WhenDoneAudioFileFullPath { get; set; } + + /// + /// Play a sound when an encode or queue finishes. + /// + public bool PlaySoundWhenDone + { + get + { + return this.playSoundWhenDone; + } + set + { + if (value == this.playSoundWhenDone) return; + this.playSoundWhenDone = value; + this.NotifyOfPropertyChange(() => this.PlaySoundWhenDone); + } + } + #endregion #region Output Files @@ -1196,6 +1239,20 @@ namespace HandBrakeWPF.ViewModels this.updateService.CheckForUpdates(this.UpdateCheckComplete); } + /// + /// Browse - Send File To + /// + public void BrowseWhenDoneAudioFile() + { + OpenFileDialog dialog = new OpenFileDialog() { Filter = "All Files|*.wav;*.mp3", FileName = this.WhenDoneAudioFileFullPath }; + bool? dialogResult = dialog.ShowDialog(); + if (dialogResult.HasValue && dialogResult.Value) + { + this.WhenDoneAudioFile = Path.GetFileNameWithoutExtension(dialog.FileName); + this.WhenDoneAudioFileFullPath = dialog.FileName; + } + } + #endregion /// @@ -1242,6 +1299,9 @@ namespace HandBrakeWPF.ViewModels this.ResetWhenDoneAction = this.userSettingService.GetUserSetting(UserSettingConstants.ResetWhenDoneAction); this.ShowQueueInline = this.userSettingService.GetUserSetting(UserSettingConstants.ShowQueueInline); this.ShowStatusInTitleBar = this.userSettingService.GetUserSetting(UserSettingConstants.ShowStatusInTitleBar); + this.WhenDoneAudioFile = Path.GetFileNameWithoutExtension(this.userSettingService.GetUserSetting(UserSettingConstants.WhenDoneAudioFile)) ?? string.Empty; + this.WhenDoneAudioFileFullPath = this.userSettingService.GetUserSetting(UserSettingConstants.WhenDoneAudioFile); + this.PlaySoundWhenDone = this.userSettingService.GetUserSetting(UserSettingConstants.PlaySoundWhenDone); // ############################# // Output Settings @@ -1392,6 +1452,8 @@ namespace HandBrakeWPF.ViewModels this.userSettingService.SetUserSetting(UserSettingConstants.ResetWhenDoneAction, this.ResetWhenDoneAction); this.userSettingService.SetUserSetting(UserSettingConstants.ShowQueueInline, this.ShowQueueInline); this.userSettingService.SetUserSetting(UserSettingConstants.ShowStatusInTitleBar, this.ShowStatusInTitleBar); + this.userSettingService.SetUserSetting(UserSettingConstants.PlaySoundWhenDone, this.PlaySoundWhenDone); + this.userSettingService.SetUserSetting(UserSettingConstants.WhenDoneAudioFile, this.WhenDoneAudioFileFullPath); /* Output Files */ this.userSettingService.SetUserSetting(UserSettingConstants.AutoNaming, this.AutomaticallyNameFiles); diff --git a/win/CS/HandBrakeWPF/Views/OptionsView.xaml b/win/CS/HandBrakeWPF/Views/OptionsView.xaml index c9e522db0..f0e902585 100644 --- a/win/CS/HandBrakeWPF/Views/OptionsView.xaml +++ b/win/CS/HandBrakeWPF/Views/OptionsView.xaml @@ -131,6 +131,18 @@ + + + + + +