]> granicus.if.org Git - handbrake/commitdiff
WinGui: Add a new option to play Sound when queue or single encode completes
authorsr55 <sr55.hb@outlook.com>
Thu, 16 Mar 2017 21:00:37 +0000 (21:00 +0000)
committersr55 <sr55.hb@outlook.com>
Thu, 16 Mar 2017 21:00:37 +0000 (21:00 +0000)
win/CS/HandBrakeWPF/Properties/ResourcesUI.Designer.cs
win/CS/HandBrakeWPF/Properties/ResourcesUI.resx
win/CS/HandBrakeWPF/Services/PrePostActionService.cs
win/CS/HandBrakeWPF/UserSettingConstants.cs
win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs
win/CS/HandBrakeWPF/Views/OptionsView.xaml
win/CS/HandBrakeWPF/defaultsettings.xml

index 35d2f654819f440b99e4714c0b1ac7bfbc285fcf..0fee65fc9be5c9aa5d96bf22673cf75c10b4a01f 100644 (file)
@@ -1482,6 +1482,15 @@ namespace HandBrakeWPF.Properties {
             }\r
         }\r
         \r
+        /// <summary>\r
+        ///   Looks up a localized string similar to Play a sound when the queue or single encode completes:.\r
+        /// </summary>\r
+        public static string OptionsView_PlaySoundWhenDone {\r
+            get {\r
+                return ResourceManager.GetString("OptionsView_PlaySoundWhenDone", resourceCulture);\r
+            }\r
+        }\r
+        \r
         /// <summary>\r
         ///   Looks up a localized string similar to Show the encode status in the application title bar..\r
         /// </summary>\r
index 33f0658df66ff7fdf3e61cc83242201d6d3b823f..f6c92ea61dcf4ca67e09e696e2a0199b091e76d8 100644 (file)
@@ -896,4 +896,7 @@ This will not affect your current settings in the Subtitle tab.</value>
   <data name="OptionsView_ShowStatusInTitleBar" xml:space="preserve">\r
     <value>Show the encode status in the application title bar.</value>\r
   </data>\r
+  <data name="OptionsView_PlaySoundWhenDone" xml:space="preserve">\r
+    <value>Play a sound when the queue or single encode completes:</value>\r
+  </data>\r
 </root>
\ No newline at end of file
index 4e3f4f30fa9639b8358c7cdf0898bdd1c8934708..033b90f96208391de73ecf35dbfb513a67d88814 100644 (file)
@@ -11,7 +11,9 @@ namespace HandBrakeWPF.Services
 {\r
     using System;\r
     using System.Diagnostics;\r
+    using System.IO;\r
     using System.Windows.Forms;\r
+    using System.Windows.Media;\r
 \r
     using Caliburn.Micro;\r
 \r
@@ -129,6 +131,18 @@ namespace HandBrakeWPF.Services
                 return;\r
             }\r
 \r
+            if (this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PlaySoundWhenDone))\r
+            {\r
+                string filePath = this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenDoneAudioFile);\r
+                if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath))\r
+                {\r
+                    var uri = new Uri(filePath, UriKind.RelativeOrAbsolute);\r
+                    var player = new MediaPlayer();\r
+                    player.Open(uri);\r
+                    player.Play();\r
+                }\r
+            }\r
+\r
             if (this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenCompleteAction) == "Do nothing")\r
             {\r
                 return;\r
index a47c185836699cc10caff1acc8f08debeb1f6986..09bc63d8391f14398219b272387e450d900996fd 100644 (file)
@@ -236,6 +236,16 @@ namespace HandBrakeWPF
         /// </summary>\r
         public const string ShowStatusInTitleBar = "ShowStatusInTitleBar";\r
 \r
+        /// <summary>\r
+        /// Setting to turn on/off the ability to play a sound when an encode or queue is done.\r
+        /// </summary>\r
+        public static string PlaySoundWhenDone = "PlaySoundWhenDone";\r
+\r
+        /// <summary>\r
+        /// Setting to store the file to play when done.\r
+        /// </summary>\r
+        public static string WhenDoneAudioFile = "WhenDoneAudioFile";\r
+\r
         #endregion\r
     }\r
 }
\ No newline at end of file
index da9a0e8b5d8df891f5555b0aa987517cca08e2ea..45cdcbd1a4456b3f5f3e06a1ec46e4f75b3a63ab 100644 (file)
@@ -28,6 +28,8 @@ namespace HandBrakeWPF.ViewModels
     using HandBrakeWPF.Utilities;\r
     using HandBrakeWPF.ViewModels.Interfaces;\r
 \r
+    using Microsoft.Win32;\r
+\r
     using Ookii.Dialogs.Wpf;\r
 \r
     using Execute = Caliburn.Micro.Execute;\r
@@ -73,7 +75,7 @@ namespace HandBrakeWPF.ViewModels
         private int selectedVerbosity;\r
         private bool sendFileAfterEncode;\r
         private string sendFileTo;\r
-        private string sendFileToPath;\r
+        private string sendFileToPath;       \r
         private string vlcPath;\r
         private string whenDone;\r
         private BindingList<string> whenDoneOptions = new BindingList<string>();\r
@@ -93,9 +95,12 @@ namespace HandBrakeWPF.ViewModels
         private bool pauseOnLowDiskspace;\r
         private long pauseOnLowDiskspaceLevel;\r
         private bool useQsvDecodeForNonQsvEnc;\r
-\r
         private bool showStatusInTitleBar;\r
 \r
+        private string whenDoneAudioFile;\r
+\r
+        private bool playSoundWhenDone;\r
+\r
         #endregion\r
 \r
         #region Constructors and Destructors\r
@@ -350,7 +355,6 @@ namespace HandBrakeWPF.ViewModels
             }\r
         }\r
 \r
-\r
         /// <summary>\r
         /// Gets or sets a value indicating whether to show encode status in the tile bar.\r
         /// </summary>\r
@@ -367,7 +371,46 @@ namespace HandBrakeWPF.ViewModels
                 this.NotifyOfPropertyChange(() => this.ShowStatusInTitleBar);\r
             }\r
         }\r
-        \r
+\r
+        /// <summary>\r
+        /// When Done Audio File\r
+        /// </summary>\r
+        public string WhenDoneAudioFile\r
+        {\r
+            get\r
+            {\r
+                return this.whenDoneAudioFile;\r
+            }\r
+            set\r
+            {\r
+                if (value == this.whenDoneAudioFile) return;\r
+                this.whenDoneAudioFile = value;\r
+                this.NotifyOfPropertyChange(() => this.WhenDoneAudioFile);\r
+            }\r
+        }\r
+\r
+        /// <summary>\r
+        /// When Done Audio File - File Path\r
+        /// </summary>\r
+        public string WhenDoneAudioFileFullPath { get; set; }\r
+\r
+        /// <summary>\r
+        /// Play a sound when an encode or queue finishes.\r
+        /// </summary>\r
+        public bool PlaySoundWhenDone\r
+        {\r
+            get\r
+            {\r
+                return this.playSoundWhenDone;\r
+            }\r
+            set\r
+            {\r
+                if (value == this.playSoundWhenDone) return;\r
+                this.playSoundWhenDone = value;\r
+                this.NotifyOfPropertyChange(() => this.PlaySoundWhenDone);\r
+            }\r
+        }\r
+\r
         #endregion\r
 \r
         #region Output Files\r
@@ -1196,6 +1239,20 @@ namespace HandBrakeWPF.ViewModels
             this.updateService.CheckForUpdates(this.UpdateCheckComplete);\r
         }\r
 \r
+        /// <summary>\r
+        /// Browse - Send File To\r
+        /// </summary>\r
+        public void BrowseWhenDoneAudioFile()\r
+        {\r
+            OpenFileDialog dialog = new  OpenFileDialog() { Filter = "All Files|*.wav;*.mp3", FileName = this.WhenDoneAudioFileFullPath };\r
+            bool? dialogResult = dialog.ShowDialog();\r
+            if (dialogResult.HasValue && dialogResult.Value)\r
+            {\r
+                this.WhenDoneAudioFile = Path.GetFileNameWithoutExtension(dialog.FileName);\r
+                this.WhenDoneAudioFileFullPath = dialog.FileName;\r
+            }\r
+        }\r
+\r
         #endregion\r
 \r
         /// <summary>\r
@@ -1242,6 +1299,9 @@ namespace HandBrakeWPF.ViewModels
             this.ResetWhenDoneAction = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ResetWhenDoneAction);\r
             this.ShowQueueInline = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowQueueInline);\r
             this.ShowStatusInTitleBar = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.ShowStatusInTitleBar);\r
+            this.WhenDoneAudioFile = Path.GetFileNameWithoutExtension(this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenDoneAudioFile)) ?? string.Empty;\r
+            this.WhenDoneAudioFileFullPath = this.userSettingService.GetUserSetting<string>(UserSettingConstants.WhenDoneAudioFile);\r
+            this.PlaySoundWhenDone = this.userSettingService.GetUserSetting<bool>(UserSettingConstants.PlaySoundWhenDone);\r
 \r
             // #############################\r
             // Output Settings\r
@@ -1392,6 +1452,8 @@ namespace HandBrakeWPF.ViewModels
             this.userSettingService.SetUserSetting(UserSettingConstants.ResetWhenDoneAction, this.ResetWhenDoneAction);\r
             this.userSettingService.SetUserSetting(UserSettingConstants.ShowQueueInline, this.ShowQueueInline);\r
             this.userSettingService.SetUserSetting(UserSettingConstants.ShowStatusInTitleBar, this.ShowStatusInTitleBar);\r
+            this.userSettingService.SetUserSetting(UserSettingConstants.PlaySoundWhenDone, this.PlaySoundWhenDone);\r
+            this.userSettingService.SetUserSetting(UserSettingConstants.WhenDoneAudioFile, this.WhenDoneAudioFileFullPath);\r
 \r
             /* Output Files */\r
             this.userSettingService.SetUserSetting(UserSettingConstants.AutoNaming, this.AutomaticallyNameFiles);\r
index c9e522db01d33309c65ebe5828f288d7aed89152..f0e902585486b3464e6605c4f1dc9c0a61fa66ca 100644 (file)
                                 <TextBox Name="SendToArguments" Text="{Binding Arguments}" Width="250" />\r
                             </StackPanel>\r
 \r
+                            <StackPanel Orientation="Vertical" Margin="0,7,0,0">\r
+                                <CheckBox Content="{x:Static Properties:ResourcesUI.OptionsView_PlaySoundWhenDone}"  \r
+                                          VerticalAlignment="Center" VerticalContentAlignment="Center" IsChecked="{Binding PlaySoundWhenDone}" Margin="0,1,0,0" />\r
+                                \r
+                                <StackPanel Orientation="Horizontal" Margin="25,2,0,0">\r
+                                    <TextBlock Text="{Binding WhenDoneAudioFile}" VerticalAlignment="Center" Margin="5,0,5,0"  />\r
+                                    <Button Content="Browse" cal:Message.Attach="[Event Click] = [Action BrowseWhenDoneAudioFile]" />\r
+                                </StackPanel>\r
+                \r
+                            </StackPanel>\r
+\r
+\r
                         </StackPanel>\r
                     </StackPanel>\r
 \r
index 4bec7eca1efe1f123a8183f49debdb2c7ecea3cd..220adf3f99bb8d50e1a5d9c326cf21cf7d59889c 100644 (file)
       <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>\r
     </value>\r
   </item>\r
+  <item>\r
+    <key>\r
+      <string>PlaySoundWhenDone</string>\r
+    </key>\r
+    <value>\r
+      <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:boolean" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">false</anyType>\r
+    </value>\r
+  </item>\r
+  <item>\r
+    <key>\r
+      <string>WhenDoneAudioFile</string>\r
+    </key>\r
+    <value>\r
+      <anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" d4p1:type="q1:string" xmlns:d4p1="http://www.w3.org/2001/XMLSchema-instance">Choose a File:</anyType>\r
+    </value>\r
+  </item>\r
 </dictionary>
\ No newline at end of file