/// <summary> /// Set the bounds of the Constant Quality Slider /// </summary> private void SetQualitySliderBounds() { // Note Updating bounds to the same values won't trigger an update. // The properties are smart enough to not take in equal values. switch (this.SelectedVideoEncoder) { case VideoEncoder.FFMpeg: case VideoEncoder.FFMpeg2: this.QualityMin = 1; this.QualityMax = 31; break; case VideoEncoder.QuickSync: case VideoEncoder.QuickSyncH265: this.QualityMin = 0; this.QualityMax = 51; break; case VideoEncoder.X264: case VideoEncoder.X264_10: case VideoEncoder.X265: case VideoEncoder.X265_10: case VideoEncoder.X265_12: this.QualityMin = 0; this.QualityMax = (int)(51 / userSettingService.GetUserSetting <double>(UserSettingConstants.X264Step)); break; case VideoEncoder.Theora: case VideoEncoder.VP8: case VideoEncoder.VP9: this.QualityMin = 0; this.QualityMax = 63; break; } }
public StaticPreviewViewModel(IScan scanService, IUserSettingService userSettingService, IErrorService errorService, ILog logService, ILogInstanceManager logInstanceManager, IPortService portService) { this.scanService = scanService; this.selectedPreviewImage = 1; this.Title = Resources.Preview; this.PreviewNotAvailable = true; // Live Preview this.userSettingService = userSettingService; this.errorService = errorService; this.logService = logService; this.logInstanceManager = logInstanceManager; this.portService = portService; this.Title = "Preview"; this.Percentage = "0.00%"; this.PercentageValue = 0; this.Duration = 30; this.CanPlay = true; this.useSystemDefaultPlayer = userSettingService.GetUserSetting<bool>(UserSettingConstants.DefaultPlayer); this.Duration = userSettingService.GetUserSetting<int>(UserSettingConstants.LastPreviewDuration); this.previewRotateFlip = userSettingService.GetUserSetting<bool>(UserSettingConstants.PreviewRotationFlip); this.NotifyOfPropertyChange(() => this.previewRotateFlip); // Don't want to trigger an Update, so setting the backing variable. }
public static IEncodeInstance GetEncodeInstance(int verbosity, HBConfiguration configuration, ILog logService, IUserSettingService userSettingService, IPortService portService) { lock (ProcessingLock) { if (!HandBrakeUtils.IsInitialised()) { throw new Exception("Please call Init before Using!"); } IEncodeInstance newInstance; if (userSettingService.GetUserSetting <bool>(UserSettingConstants.ProcessIsolationEnabled) && Portable.IsProcessIsolationEnabled()) { newInstance = new RemoteInstance(logService, userSettingService, portService); } else { if (encodeInstance != null && !encodeInstance.IsRemoteInstance) { encodeInstance.Dispose(); encodeInstance = null; } newInstance = new HandBrakeInstance(); HandBrakeUtils.SetDvdNav( !userSettingService.GetUserSetting <bool>(UserSettingConstants.DisableLibDvdNav)); encodeInstance = newInstance; } newInstance.Initialize(verbosity, noHardware); return(newInstance); } }
/// <summary> /// The queue processor_ queue completed. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The EventArgs. /// </param> private void QueueProcessorQueueCompleted(object sender, System.EventArgs e) { if (userSettingService.GetUserSetting <bool>(UserSettingConstants.GrowlQueue)) { // GrowlCommunicator.Notify("Queue Completed", "Put down that cocktail...\nyour Handbrake queue is done."); } }
/// <summary> /// Play the Encoded file /// </summary> private void PlayFile() { // Launch VLC and Play video. if (this.CurrentlyPlaying != string.Empty) { if (File.Exists(this.CurrentlyPlaying)) { string args = "\"" + this.CurrentlyPlaying + "\""; if (this.UseSystemDefaultPlayer) { Process.Start(args); } else { if (!File.Exists(userSettingService.GetUserSetting <string>(UserSettingConstants.VLCPath))) { // Attempt to find VLC if it doesn't exist in the default set location. string vlcPath; if (8 == IntPtr.Size || (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432")))) { vlcPath = Environment.GetEnvironmentVariable("ProgramFiles(x86)"); } else { vlcPath = Environment.GetEnvironmentVariable("ProgramFiles"); } if (!string.IsNullOrEmpty(vlcPath)) { vlcPath = Path.Combine(vlcPath, "VideoLAN\\VLC\\vlc.exe"); } if (File.Exists(vlcPath)) { userSettingService.SetUserSetting(UserSettingConstants.VLCPath, vlcPath); } else { this.errorService.ShowMessageBox(Resources.StaticPreviewViewModel_UnableToFindVLC, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Warning); } } if (File.Exists(userSettingService.GetUserSetting <string>(UserSettingConstants.VLCPath))) { ProcessStartInfo vlc = new ProcessStartInfo(userSettingService.GetUserSetting <string>(UserSettingConstants.VLCPath), args); Process.Start(vlc); } } } else { this.errorService.ShowMessageBox(Resources.StaticPreviewViewModel_UnableToPlayFile, Resources.Error, MessageBoxButton.OK, MessageBoxImage.Warning); } } }
/// <summary> /// Initializes a new instance of the <see cref="frmAbout"/> class. /// </summary> public frmAbout() { InitializeComponent(); string nightly = userSettingService.GetUserSetting <string>(ASUserSettingConstants.HandBrakeVersion).Contains("svn") ? " (SVN / Nightly Build)" : string.Empty; lbl_GUIBuild.Text = userSettingService.GetUserSetting <string>(ASUserSettingConstants.HandBrakeVersion) + " (" + userSettingService.GetUserSetting <int>(ASUserSettingConstants.HandBrakeBuild) + ") " + nightly; }
/// <summary> /// Initializes a new instance of the <see cref="EncodeBase"/> class. /// </summary> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public EncodeBase(IUserSettingService userSettingService) { this.userSettingService = userSettingService; this.logBuffer = new StringBuilder(); header = GeneralUtilities.CreateCliLogHeader( userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeVersion), userSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild)); }
/// <summary> /// The create. /// </summary> /// <returns> /// The <see cref="HBConfiguration"/>. /// </returns> public static HBConfiguration Create() { HBConfiguration config = new HBConfiguration { PreviewScanCount = UserSettingService.GetUserSetting <int>(UserSettingConstants.PreviewScanCount), EnableQuickSyncDecoding = UserSettingService.GetUserSetting <bool>(UserSettingConstants.EnableQuickSyncDecoding), UseQSVDecodeForNonQSVEnc = UserSettingService.GetUserSetting <bool>(UserSettingConstants.UseQSVDecodeForNonQSVEnc), EnableQsvLowPower = UserSettingService.GetUserSetting <bool>(UserSettingConstants.EnableQuickSyncLowPower) }; return(config); }
private static string GetAutonamePath(IUserSettingService userSettingService, EncodeTask task, string sourceName) { string autoNamePath = userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNamePath).Trim() .Replace("/", "\\"); // If enabled, use the current Destination path. if (!userSettingService.GetUserSetting <bool>(UserSettingConstants.AlwaysUseDefaultPath) && !string.IsNullOrEmpty(task.Destination)) { string path = Path.GetDirectoryName(task.Destination); if (!string.IsNullOrEmpty(path)) { return(path); } } // Handle {source_path} if (autoNamePath.StartsWith("{source_path}") && !string.IsNullOrEmpty(task.Source)) { string savedPath = autoNamePath.Replace("{source_path}\\", string.Empty).Replace("{source_path}", string.Empty); string directory = Directory.Exists(task.Source) ? task.Source : Path.GetDirectoryName(task.Source); autoNamePath = Path.Combine(directory, savedPath); } // Handle {source} if (userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNamePath).Contains("{source}") && !string.IsNullOrEmpty(task.Source)) { sourceName = Path.GetInvalidPathChars().Aggregate(sourceName, (current, character) => current.Replace(character.ToString(), string.Empty)); autoNamePath = autoNamePath.Replace("{source}", sourceName); } // Handle {source_folder_name} if (userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNamePath).Contains("{source_folder_name}") && !string.IsNullOrEmpty(task.Source)) { // Second Case: We have a Path, with "{source_folder}" in it, therefore we need to replace it with the folder name from the source. string path = Path.GetDirectoryName(task.Source); if (!string.IsNullOrEmpty(path)) { string[] filesArray = path.Split(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); string sourceFolder = filesArray[filesArray.Length - 1]; autoNamePath = userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNamePath).Replace("{source_folder_name}", sourceFolder); } } // Fallback to the users "Videos" folder. if (string.IsNullOrEmpty(autoNamePath) || autoNamePath == Resources.OptionsView_SetDefaultLocationOutputFIle) { autoNamePath = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos); } return(autoNamePath); }
/// <summary> /// Check for Updates. /// </summary> public static void CheckForUpdates() { IUserSettingService userSettingService = IoC.Get <IUserSettingService>(); userSettingService.SetUserSetting(UserSettingConstants.LastUpdateCheckDate, DateTime.Now); string url = userSettingService.GetUserSetting <string>(ASUserSettingConstants.HandBrakePlatform).Contains("x86_64") ? userSettingService.GetUserSetting <string>(UserSettingConstants.Appcast_x64) : userSettingService.GetUserSetting <string>(UserSettingConstants.Appcast_i686); UpdateService.BeginCheckForUpdates(UpdateCheckDoneMenu, false, url, userSettingService.GetUserSetting <int>(ASUserSettingConstants.HandBrakeBuild), userSettingService.GetUserSetting <int>(UserSettingConstants.Skipversion)); }
/// <summary> /// Check if there is a valid autoname path. /// </summary> /// <returns> /// True if there is a valid path /// </returns> public static bool IsAutonamingEnabled() { IUserSettingService userSettingService = IoC.Get <IUserSettingService>(); if (!userSettingService.GetUserSetting <bool>(UserSettingConstants.AutoNaming)) { return(false); } // If there is an auto name path, use it... return(userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNamePath).Trim().StartsWith("{source_path}") || (userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNamePath).Contains("{source_folder_name}") || Directory.Exists(userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNamePath).Trim()))); }
public LogService(IUserSettingService userSettingService) { HandBrakeUtils.MessageLogged += this.HandBrakeUtils_MessageLogged; HandBrakeUtils.ErrorLogged += this.HandBrakeUtils_ErrorLogged; if (userSettingService.GetUserSetting <bool>(UserSettingConstants.RemoteServiceEnabled)) { this.ActivateRemoteLogPolling(); this.isRemotePollingEnabled = true; this.port = userSettingService.GetUserSetting <int>(UserSettingConstants.RemoteServicePort); this.serverUrl = string.Format("http://127.0.0.1:{0}/", this.port); } }
/// <summary> /// Generate the Command Line Arguments for the Source /// </summary> /// <param name="task"> /// The encode task. /// </param> /// <param name="duration"> /// The duration. /// </param> /// <param name="preview"> /// The preview. /// </param> /// <returns> /// A Cli Query as a string /// </returns> private static string SourceQuery(EncodeTask task, int?duration, string preview) { string query = string.Empty; // If we have a folder, strip it's trailing slash for the CLI. // It behaves a bit funny with trailing \ in some cases. if (task.Source.EndsWith("\\")) { task.Source = task.Source.TrimEnd('\\'); } query += string.Format(" -i \"{0}\"", task.Source); query += string.Format(" -t {0}", task.Title); query += string.Format(" --angle {0}", task.Angle); // Decide what part of the video we want to encode. switch (task.PointToPointMode) { case PointToPointMode.Chapters: // Chapters if (task.StartPoint == task.EndPoint) { query += string.Format(" -c {0}", task.StartPoint); } else { query += string.Format(" -c {0}-{1}", task.StartPoint, task.EndPoint); } break; case PointToPointMode.Seconds: // Seconds int calculatedDuration = task.EndPoint - task.StartPoint; query += string.Format(" --start-at duration:{0} --stop-at duration:{1}", task.StartPoint, calculatedDuration); break; case PointToPointMode.Frames: // Frames calculatedDuration = task.EndPoint - task.StartPoint; query += string.Format(" --start-at frame:{0} --stop-at frame:{1}", task.StartPoint, calculatedDuration); break; case PointToPointMode.Preview: // Preview query += " --previews " + UserSettingService.GetUserSetting <int>(ASUserSettingConstants.PreviewScanCount) + " "; query += " --start-at-preview " + preview; query += " --stop-at duration:" + duration + " "; break; } return(query); }
/// <summary> /// Setup the logging. /// </summary> /// <param name="encodeQueueTask"> /// The encode QueueTask. /// </param> protected void SetupLogging(QueueTask encodeQueueTask) { ShutdownFileWriter(); string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs"; string logFile = Path.Combine(logDir, string.Format("last_encode_log{0}.txt", GeneralUtilities.ProcessId)); string logFile2 = Path.Combine(logDir, string.Format("tmp_appReadable_log{0}.txt", GeneralUtilities.ProcessId)); try { string query = QueryGeneratorUtility.GenerateQuery(new EncodeTask(encodeQueueTask.Task), userSettingService.GetUserSetting <int>(ASUserSettingConstants.PreviewScanCount), userSettingService.GetUserSetting <int>(ASUserSettingConstants.Verbosity), userSettingService.GetUserSetting <bool>(ASUserSettingConstants.DisableLibDvdNav)); this.logBuffer = new StringBuilder(); this.logBuffer.AppendLine(String.Format("CLI Query: {0}", query)); this.logBuffer.AppendLine(String.Format("User Query: {0}", encodeQueueTask.CustomQuery)); this.logBuffer.AppendLine(); // Clear the current Encode Logs) if (File.Exists(logFile)) { File.Delete(logFile); } if (File.Exists(logFile2)) { File.Delete(logFile2); } this.fileWriter = new StreamWriter(logFile) { AutoFlush = true }; this.fileWriter.WriteLine(header); this.fileWriter.WriteLine(string.Format("CLI Query: {0}", query)); this.fileWriter.WriteLine(string.Format("User Query: {0}", encodeQueueTask.CustomQuery)); this.fileWriter.WriteLine(); } catch (Exception) { if (this.fileWriter != null) { this.fileWriter.Close(); this.fileWriter.Dispose(); } throw; } }
/// <summary> /// Initializes a new instance of the <see cref="LibScan"/> class. /// </summary> /// <param name="userSettingService"> /// The user Setting Service. /// </param> /// <param name="handBrakeInstance"> /// The hand Brake Instance. /// </param> public LibScan(IUserSettingService userSettingService, IHandBrakeInstance handBrakeInstance) { logging = new StringBuilder(); header = GeneralUtilities.CreateCliLogHeader( userSettingService.GetUserSetting<string>(ASUserSettingConstants.HandBrakeVersion), userSettingService.GetUserSetting<int>(ASUserSettingConstants.HandBrakeBuild)); instance = handBrakeInstance; instance.Initialize(1); instance.ScanProgress += this.InstanceScanProgress; instance.ScanCompleted += this.InstanceScanCompleted; HandBrakeUtils.MessageLogged += this.HandBrakeInstanceMessageLogged; HandBrakeUtils.ErrorLogged += this.HandBrakeInstanceErrorLogged; }
public static void Init(bool noHardwareMode, IUserSettingService userSettingService) { Thread thread = new Thread(() => { if (userSettingService.GetUserSetting <bool>(UserSettingConstants.ForceDisableHardwareSupport)) { noHardware = true; } else { noHardware = noHardwareMode; } HandBrakeUtils.RegisterLogger(); HandBrakeUtils.EnsureGlobalInit(noHardware); }); thread.Start(); if (!thread.Join(8000)) { // Something is likely handing in a graphics driver. Force disable this feature so we don't probe the hardware next time around. userSettingService.SetUserSetting(UserSettingConstants.ForceDisableHardwareSupport, true); throw new GeneralApplicationException(Resources.Startup_UnableToStart, Resources.Startup_UnableToStartInfo); } }
/// <summary> /// Convert a Quality Value to a position value for the Video Quality slider /// </summary> /// <param name="videoEncoder">The selected video encoder</param> /// <param name="value">The Quality value</param> /// <returns>The position on the video quality slider</returns> private static int QualityToSliderValue(VideoEncoder videoEncoder, double?value) { if (!value.HasValue) { // Default to a sensible level. return(20); } int sliderValue = 0; switch (videoEncoder) { case VideoEncoder.FFMpeg: case VideoEncoder.FFMpeg2: sliderValue = 32 - (int)value; break; case VideoEncoder.X264: double cqStep = UserSettingService.GetUserSetting <double>(ASUserSettingConstants.X264Step); sliderValue = (int)((51.0 / cqStep) - (value / cqStep)); break; case VideoEncoder.Theora: sliderValue = (int)value; break; } return(sliderValue); }
private static string CheckAndHandleFilenameCollisions(string autoNamePath, string destinationFilename, EncodeTask task, IUserSettingService userSettingService) { AutonameFileCollisionBehaviour behaviour = (AutonameFileCollisionBehaviour)userSettingService.GetUserSetting <int>(UserSettingConstants.AutonameFileCollisionBehaviour); string prefix = string.Empty, postfix = string.Empty; switch (behaviour) { case AutonameFileCollisionBehaviour.Postfix: postfix = userSettingService.GetUserSetting <string>(UserSettingConstants.AutonameFilePrePostString); break; case AutonameFileCollisionBehaviour.Prefix: prefix = userSettingService.GetUserSetting <string>(UserSettingConstants.AutonameFilePrePostString); break; } string extension = Path.GetExtension(destinationFilename); string filenameWithoutExt = Path.GetFileNameWithoutExtension(destinationFilename); if (behaviour != AutonameFileCollisionBehaviour.AppendNumber) { if (autoNamePath?.ToLower() == task.Source?.ToLower()) { autoNamePath = Path.Combine(Path.GetDirectoryName(autoNamePath), prefix + filenameWithoutExt + postfix + extension); int counter = 0; while (File.Exists(autoNamePath)) { counter = counter + 1; string appendedNumber = string.Format("({0})", counter); autoNamePath = Path.Combine(Path.GetDirectoryName(autoNamePath), prefix + filenameWithoutExt + postfix + appendedNumber + extension); } } } else { int counter = 0; while (File.Exists(autoNamePath)) { counter = counter + 1; string appendedNumber = string.Format("({0})", counter); autoNamePath = Path.Combine(Path.GetDirectoryName(autoNamePath), filenameWithoutExt + appendedNumber + extension); } } return(autoNamePath); }
/// <summary> /// Initializes a new instance of the <see cref="PreviewViewModel"/> class. /// </summary> /// <param name="errorService"> /// The error Service. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public PreviewViewModel(IErrorService errorService, IUserSettingService userSettingService) { // Preview needs a seperate instance rather than the shared singleton. This could maybe do with being refactored at some point this.encodeService = new EncodeServiceWrapper(userSettingService); this.errorService = errorService; this.userSettingService = userSettingService; this.Title = "Preview"; this.Percentage = "0.00%"; this.PercentageValue = 0; this.StartAt = 1; this.Duration = 30; this.CanPlay = true; UseSystemDefaultPlayer = userSettingService.GetUserSetting <bool>(UserSettingConstants.DefaultPlayer); this.Duration = userSettingService.GetUserSetting <int>(UserSettingConstants.LastPreviewDuration); }
/// <summary> /// Check if there is a valid autoname path. /// </summary> /// <returns> /// True if there is a valid path /// </returns> public static bool IsAutonamingEnabled() { IUserSettingService userSettingService = IoC.Get <IUserSettingService>(); if (!userSettingService.GetUserSetting <bool>(UserSettingConstants.AutoNaming)) { return(false); } if (string.IsNullOrEmpty( userSettingService.GetUserSetting <string>(UserSettingConstants.AutoNamePath).Trim())) { return(false); } return(true); }
public RemoteInstance(HBConfiguration configuration, ILog logService, IUserSettingService userSettingService) { this.configuration = configuration; this.logService = logService; this.userSettingService = userSettingService; this.port = this.GetOpenPort(userSettingService.GetUserSetting <int>(UserSettingConstants.ProcessIsolationPort)); this.serverUrl = string.Format("http://127.0.0.1:{0}/", this.port); }
/// <summary> /// The create. /// </summary> /// <returns> /// The <see cref="HBConfiguration"/>. /// </returns> public static HBConfiguration Create() { HBConfiguration config = new HBConfiguration { IsDvdNavDisabled = UserSettingService.GetUserSetting <bool>(UserSettingConstants.DisableLibDvdNav), DisableQuickSyncDecoding = UserSettingService.GetUserSetting <bool>(UserSettingConstants.DisableQuickSyncDecoding), EnableDxva = UserSettingService.GetUserSetting <bool>(UserSettingConstants.EnableDxva), ScalingMode = UserSettingService.GetUserSetting <VideoScaler>(UserSettingConstants.ScalingMode), PreviewScanCount = UserSettingService.GetUserSetting <int>(UserSettingConstants.PreviewScanCount), Verbosity = UserSettingService.GetUserSetting <int>(UserSettingConstants.Verbosity), MinScanDuration = UserSettingService.GetUserSetting <int>(UserSettingConstants.MinScanDuration), SaveLogToCopyDirectory = UserSettingService.GetUserSetting <bool>(UserSettingConstants.SaveLogToCopyDirectory), SaveLogWithVideo = UserSettingService.GetUserSetting <bool>(UserSettingConstants.SaveLogWithVideo), SaveLogCopyDirectory = UserSettingService.GetUserSetting <string>(UserSettingConstants.SaveLogCopyDirectory), }; return(config); }
/// <summary> /// Initializes a new instance of the <see cref="EncodeServiceWrapper"/> class. /// </summary> /// <param name="userSettingService"> /// The user setting service. /// </param> public EncodeServiceWrapper(IUserSettingService userSettingService) { var useLibHb = userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableLibHb); var useProcessIsolation = userSettingService.GetUserSetting<bool>(UserSettingConstants.EnableProcessIsolation); var port = userSettingService.GetUserSetting<string>(UserSettingConstants.ServerPort); if (useLibHb) { try { if (useProcessIsolation) { this.encodeService = new IsolatedEncodeService(port); } else { if (ScanServiceWrapper.HandbrakeInstance == null) { ScanServiceWrapper.HandbrakeInstance = new HandBrakeInstance(); } this.encodeService = new LibEncode(userSettingService, ScanServiceWrapper.HandbrakeInstance); } } catch (Exception exc) { // Try to recover from errors. userSettingService.SetUserSetting(UserSettingConstants.EnableLibHb, false); throw new GeneralApplicationException( "Unable to initialise LibHB or Background worker service", "Falling back to using HandBrakeCLI.exe. Setting has been reset", exc); } } else { this.encodeService = new Encode(userSettingService); } this.encodeService.EncodeCompleted += this.EncodeServiceEncodeCompleted; this.encodeService.EncodeStarted += this.EncodeServiceEncodeStarted; this.encodeService.EncodeStatusChanged += this.EncodeServiceEncodeStatusChanged; }
/// <summary> /// Initializes a new instance of the <see cref="EncodeServiceWrapper"/> class. /// </summary> /// <param name="userSettingService"> /// The user setting service. /// </param> public EncodeServiceWrapper(IUserSettingService userSettingService) { var useLibHb = userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableLibHb); var useProcessIsolation = userSettingService.GetUserSetting <bool>(UserSettingConstants.EnableProcessIsolation); var port = userSettingService.GetUserSetting <string>(UserSettingConstants.ServerPort); if (useLibHb) { try { if (useProcessIsolation) { this.encodeService = new IsolatedEncodeService(port); } else { if (ScanServiceWrapper.HandbrakeInstance == null) { ScanServiceWrapper.HandbrakeInstance = new HandBrakeInstance(); } this.encodeService = new LibEncode(userSettingService, ScanServiceWrapper.HandbrakeInstance); } } catch (Exception exc) { // Try to recover from errors. userSettingService.SetUserSetting(UserSettingConstants.EnableLibHb, false); throw new GeneralApplicationException( "Unable to initialise LibHB or Background worker service", "Falling back to using HandBrakeCLI.exe. Setting has been reset", exc); } } else { this.encodeService = new Encode(userSettingService); } this.encodeService.EncodeCompleted += this.EncodeServiceEncodeCompleted; this.encodeService.EncodeStarted += this.EncodeServiceEncodeStarted; this.encodeService.EncodeStatusChanged += this.EncodeServiceEncodeStatusChanged; }
public void Initialize(int verbosityLvl, bool noHardwareMode) { if (this.workerProcess == null || this.workerProcess.HasExited) { var plainTextBytes = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()); this.base64Token = Convert.ToBase64String(plainTextBytes); this.port = this.portService.GetOpenPort(userSettingService.GetUserSetting <int>(UserSettingConstants.ProcessIsolationPort)); this.serverUrl = string.Format("http://127.0.0.1:{0}/", this.port); workerProcess = new Process { StartInfo = { FileName = "HandBrake.Worker.exe", Arguments = string.Format(" --port={0} --token={1}", port, this.base64Token), UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true } }; workerProcess.Exited += this.WorkerProcess_Exited; workerProcess.OutputDataReceived += this.WorkerProcess_OutputDataReceived; workerProcess.ErrorDataReceived += this.WorkerProcess_OutputDataReceived; workerProcess.Start(); workerProcess.BeginOutputReadLine(); workerProcess.BeginErrorReadLine(); // Set Process Priority switch ((ProcessPriority)this.userSettingService.GetUserSetting <int>(UserSettingConstants.ProcessPriorityInt)) { case ProcessPriority.High: workerProcess.PriorityClass = ProcessPriorityClass.High; break; case ProcessPriority.AboveNormal: workerProcess.PriorityClass = ProcessPriorityClass.AboveNormal; break; case ProcessPriority.Normal: workerProcess.PriorityClass = ProcessPriorityClass.Normal; break; case ProcessPriority.Low: workerProcess.PriorityClass = ProcessPriorityClass.Idle; break; default: workerProcess.PriorityClass = ProcessPriorityClass.BelowNormal; break; } this.logService.LogMessage(string.Format("Worker Process started with Process ID: {0} and port: {1}", this.workerProcess.Id, port)); } }
/// <summary> /// Initializes a new instance of the <see cref="ShellView"/> class. /// </summary> public ShellView() { this.InitializeComponent(); IUserSettingService userSettingService = IoC.Get <IUserSettingService>(); bool minimiseToTray = userSettingService.GetUserSetting <bool>(UserSettingConstants.MainWindowMinimize); if (minimiseToTray) { this.notifyIcon = new System.Windows.Forms.NotifyIcon(); this.notifyIcon.ContextMenu = new ContextMenu(new[] { new MenuItem("Restore", NotifyIconClick) }); StreamResourceInfo streamResourceInfo = Application.GetResourceStream(new Uri("pack://application:,,,/handbrakepineapple.ico")); if (streamResourceInfo != null) { Stream iconStream = streamResourceInfo.Stream; this.notifyIcon.Icon = new System.Drawing.Icon(iconStream); } this.notifyIcon.DoubleClick += this.NotifyIconClick; this.StateChanged += this.ShellViewStateChanged; } // Start Encode (Ctrl+S) // Stop Encode (Ctrl+K) // Open Log Window (Ctrl+L) // Open Queue Window (Ctrl+Q) // Add to Queue (Ctrl+A) // Scan a File (Ctrl+F) // Scan a Folder (Ctrl+R) // Show CLI Query (Ctrl+Shift+D) this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.S, ModifierKeys.Control)), new KeyGesture(Key.S, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.K, ModifierKeys.Control)), new KeyGesture(Key.K, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.L, ModifierKeys.Control)), new KeyGesture(Key.L, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.Q, ModifierKeys.Control)), new KeyGesture(Key.Q, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.A, ModifierKeys.Control)), new KeyGesture(Key.A, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.F, ModifierKeys.Control)), new KeyGesture(Key.F, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.O, ModifierKeys.Control)), new KeyGesture(Key.O, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.R, ModifierKeys.Control)), new KeyGesture(Key.R, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D, ModifierKeys.Control | ModifierKeys.Shift)), new KeyGesture(Key.D, ModifierKeys.Control | ModifierKeys.Shift))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Shift)), new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Shift))); // Enable Windows 7 Taskbar progress indication. if (this.TaskbarItemInfo == null) { this.TaskbarItemInfo = Win7.WindowsTaskbar; } // Window Sizing if (AppArguments.IsInstantHandBrake) { this.SizeToContent = SizeToContent.WidthAndHeight; this.MinHeight = 380; this.MinWidth = 600; } }
/// <summary>Converts a value. </summary> /// <returns>A converted value. If the method returns null, the valid null value is used.</returns> /// <param name="value">The value produced by the binding source.</param> /// <param name="targetType">The type of the binding target property.</param> /// <param name="parameter">The converter parameter to use.</param> /// <param name="culture">The culture to use in the converter.</param> public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { IEnumerable <IPresetObject> presets = value as IEnumerable <IPresetObject>; if (presets == null) { return(null); } List <object> groupedMenu = new List <object>(); // Generate the Preset Manager Item if (parameter != null && "true".Equals(parameter)) { MenuItem savePresetMenuItem = new MenuItem { Header = Resources.MainView_SaveNewPreset, Tag = null, Command = new AddPresetCommand() }; groupedMenu.Add(savePresetMenuItem); MenuItem presetManagerMenuItem = new MenuItem { Header = Resources.PresetManger_Title, Tag = null, Command = new OpenPresetManagerCommand() }; groupedMenu.Add(presetManagerMenuItem); groupedMenu.Add(new Separator()); } IEnumerable <IPresetObject> presetObjects = presets.ToList(); PresetDisplayMode mode = userSettingService.GetUserSetting <PresetDisplayMode>(UserSettingConstants.PresetMenuDisplayMode); switch (mode) { case PresetDisplayMode.Flat: GenerateFlatList(groupedMenu, presetObjects.ToList()); break; case PresetDisplayMode.Partial: GenerateUserPresets(groupedMenu, presetObjects.FirstOrDefault(p => p.Category == PresetService.UserPresetCategoryName)); GeneratePresets(groupedMenu, presetObjects.ToList(), mode); break; case PresetDisplayMode.Category: GeneratePresets(groupedMenu, presetObjects.ToList(), mode); break; } return(groupedMenu); }
/// <summary> /// Initializes a new instance of the <see cref="ShellView"/> class. /// </summary> public ShellView() { this.InitializeComponent(); IUserSettingService userSettingService = IoC.Get <IUserSettingService>(); bool minimiseToTray = userSettingService.GetUserSetting <bool>(UserSettingConstants.MainWindowMinimize); if (minimiseToTray) { INotifyIconService notifyIconService = IoC.Get <INotifyIconService>(); this.notifyIcon = new NotifyIcon(); this.notifyIcon.ContextMenu = new ContextMenu(new[] { new MenuItem("Restore", NotifyIconClick), new MenuItem("Mini Status Display", ShowMiniStatusDisplay) }); notifyIconService.RegisterNotifyIcon(this.notifyIcon); StreamResourceInfo streamResourceInfo = Application.GetResourceStream(new Uri("pack://application:,,,/handbrakepineapple.ico")); if (streamResourceInfo != null) { Stream iconStream = streamResourceInfo.Stream; this.notifyIcon.Icon = new Icon(iconStream); } this.notifyIcon.Click += this.NotifyIconClick; this.StateChanged += this.ShellViewStateChanged; } this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.E, ModifierKeys.Control)), new KeyGesture(Key.E, ModifierKeys.Control))); // Start Encode this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.K, ModifierKeys.Control)), new KeyGesture(Key.K, ModifierKeys.Control))); // Stop Encode this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.L, ModifierKeys.Control)), new KeyGesture(Key.L, ModifierKeys.Control))); // Open Log Window this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.Q, ModifierKeys.Control)), new KeyGesture(Key.Q, ModifierKeys.Control))); // Open Queue Window this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.A, ModifierKeys.Control)), new KeyGesture(Key.A, ModifierKeys.Control))); // Add to Queue this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.A, ModifierKeys.Alt)), new KeyGesture(Key.A, ModifierKeys.Alt))); // Add all to Queue this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.A, ModifierKeys.Control | ModifierKeys.Shift)), new KeyGesture(Key.A, ModifierKeys.Control | ModifierKeys.Shift))); // Add selection to Queue this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.O, ModifierKeys.Control)), new KeyGesture(Key.O, ModifierKeys.Control))); // File Scan this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.O, ModifierKeys.Alt)), new KeyGesture(Key.O, ModifierKeys.Alt))); // Scan Window this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.O, ModifierKeys.Control | ModifierKeys.Shift)), new KeyGesture(Key.O, ModifierKeys.Control | ModifierKeys.Shift))); // Scan a Folder this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Shift)), new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Shift))); // Garbage Colleciton this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.F1, ModifierKeys.None)), new KeyGesture(Key.F1, ModifierKeys.None))); // Help this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.S, ModifierKeys.Control)), new KeyGesture(Key.S, ModifierKeys.Control))); // Browse Destination // Tabs Switching this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D1, ModifierKeys.Control)), new KeyGesture(Key.D1, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D2, ModifierKeys.Control)), new KeyGesture(Key.D2, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D3, ModifierKeys.Control)), new KeyGesture(Key.D3, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D4, ModifierKeys.Control)), new KeyGesture(Key.D4, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D5, ModifierKeys.Control)), new KeyGesture(Key.D5, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D6, ModifierKeys.Control)), new KeyGesture(Key.D6, ModifierKeys.Control))); this.InputBindings.Add(new InputBinding(new ProcessShortcutCommand(new KeyGesture(Key.D7, ModifierKeys.Control)), new KeyGesture(Key.D7, ModifierKeys.Control))); // Enable Windows 7 Taskbar progress indication. if (this.TaskbarItemInfo == null) { this.TaskbarItemInfo = Win7.WindowsTaskbar; } }
/// <summary> /// Generate the Command Line Arguments for the Source /// </summary> /// <param name="task"> /// The encode task. /// </param> /// <param name="duration"> /// The duration. /// </param> /// <param name="preview"> /// The preview. /// </param> /// <returns> /// A Cli Query as a string /// </returns> private static string SourceQuery(EncodeTask task, int?duration, string preview) { string query = string.Empty; query += string.Format(" -i \"{0}\"", task.Source); query += string.Format(" -t {0}", task.Title); query += string.Format(" --angle {0}", task.Angle); // Decide what part of the video we want to encode. switch (task.PointToPointMode) { case PointToPointMode.Chapters: // Chapters if (task.StartPoint == task.EndPoint) { query += string.Format(" -c {0}", task.StartPoint); } else { query += string.Format(" -c {0}-{1}", task.StartPoint, task.EndPoint); } break; case PointToPointMode.Seconds: // Seconds int calculatedDuration = task.EndPoint - task.StartPoint; query += string.Format(" --start-at duration:{0} --stop-at duration:{1}", task.StartPoint, calculatedDuration); break; case PointToPointMode.Frames: // Frames calculatedDuration = task.EndPoint - task.StartPoint; query += string.Format(" --start-at frame:{0} --stop-at frame:{1}", task.StartPoint, calculatedDuration); break; case PointToPointMode.Preview: // Preview query += " --previews " + UserSettingService.GetUserSetting <int>(ASUserSettingConstants.PreviewScanCount) + " "; query += " --start-at-preview " + preview; query += " --stop-at duration:" + duration + " "; break; } return(query); }
/// <summary> /// Initializes a new instance of the <see cref="StaticPreviewViewModel"/> class. /// </summary> /// <param name="scanService"> /// The scan service. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public StaticPreviewViewModel(IScan scanService, IUserSettingService userSettingService) { this.scanService = scanService; this.selectedPreviewImage = 1; this.Title = Properties.Resources.Preview; this.PreviewNotAvailable = true; // Live Preview this.userSettingService = userSettingService; this.encodeService = new EncodeServiceWrapper(userSettingService); // Preview needs a seperate instance rather than the shared singleton. This could maybe do with being refactored at some point this.Title = "Preview"; this.Percentage = "0.00%"; this.PercentageValue = 0; this.Duration = 30; this.CanPlay = true; UseSystemDefaultPlayer = userSettingService.GetUserSetting <bool>(UserSettingConstants.DefaultPlayer); this.Duration = userSettingService.GetUserSetting <int>(UserSettingConstants.LastPreviewDuration); }
/// <summary> /// Initializes a new instance of the <see cref="frmPreview"/> class. /// </summary> /// <param name="mw"> /// The mw. /// </param> public frmPreview(frmMain mw) { InitializeComponent(); this.mainWindow = mw; startPoint.SelectedIndex = 0; endPoint.SelectedIndex = 1; startPoint.Items.Clear(); for (int i = 1; i <= UserSettingService.GetUserSetting <int>(UserSettingConstants.PreviewScanCount); i++) { startPoint.Items.Add(i.ToString()); } startPoint.SelectedIndex = 0; encodeQueue.EncodeStarted += this.EncodeQueueEncodeStarted; encodeQueue.EncodeCompleted += this.EncodeQueueEncodeEnded; defaultPlayer.Checked = UserSettingService.GetUserSetting <bool>(UserSettingConstants.DefaultPlayer); }
private static string CleanupSourceName(string sourceName, IUserSettingService userSettingService) { if (userSettingService.GetUserSetting <bool>(UserSettingConstants.AutoNameRemoveUnderscore)) { sourceName = sourceName.Replace("_", " "); } if (userSettingService.GetUserSetting <bool>(UserSettingConstants.RemovePunctuation)) { sourceName = sourceName.Replace("-", string.Empty); sourceName = sourceName.Replace(",", string.Empty); sourceName = sourceName.Replace(".", string.Empty); } // Switch to "Title Case" if (userSettingService.GetUserSetting <bool>(UserSettingConstants.AutoNameTitleCase)) { sourceName = sourceName.ToTitleCase(); } return(sourceName); }
/// <summary> /// Initializes a new instance of the <see cref="PreviewViewModel"/> class. /// </summary> /// <param name="windowManager"> /// The window manager. /// </param> /// <param name="encodeService"> /// The encode Service. /// </param> /// <param name="errorService"> /// The error Service. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public PreviewViewModel(IWindowManager windowManager, IEncode encodeService, IErrorService errorService, IUserSettingService userSettingService) { this.encodeService = encodeService; this.errorService = errorService; this.userSettingService = userSettingService; this.Title = "Preview"; this.Percentage = "0.00%"; this.PercentageValue = 0; this.StartAt = 1; this.Duration = 30; UseSystemDefaultPlayer = userSettingService.GetUserSetting <bool>(UserSettingConstants.DefaultPlayer); }
/// <summary> /// Parse the Title Information /// </summary> /// <param name="output"> /// A StringReader of output data /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> /// <returns> /// A Title Object /// </returns> public static Title Parse(StringReader output, IUserSettingService userSettingService) { var thisTitle = new Title(); string nextLine = output.ReadLine(); // Get the Title Number Match m = Regex.Match(nextLine, @"^\+ title ([0-9]*):"); if (m.Success) thisTitle.TitleNumber = int.Parse(m.Groups[1].Value.Trim()); nextLine = output.ReadLine(); // Detect if this is the main feature m = Regex.Match(nextLine, @" \+ Main Feature"); if (m.Success) { thisTitle.MainTitle = true; nextLine = output.ReadLine(); } // Get the stream name for file import m = Regex.Match(nextLine, @"^ \+ stream:"); if (m.Success) { thisTitle.SourceName = nextLine.Replace("+ stream:", string.Empty).Trim(); nextLine = output.ReadLine(); } // Playlist m = Regex.Match(nextLine, @"^ \+ playlist:"); if (m.Success) { thisTitle.Playlist = nextLine.Replace("+ playlist:", string.Empty).Trim(); nextLine = output.ReadLine(); } // Jump over the VTS and blocks line m = Regex.Match(nextLine, @"^ \+ vts:"); if (nextLine.Contains("blocks") || nextLine.Contains("+ vts ")) { nextLine = output.ReadLine(); } // Multi-Angle Support if LibDvdNav is enabled if (!userSettingService.GetUserSetting<bool>(ASUserSettingConstants.DisableLibDvdNav)) { m = Regex.Match(nextLine, @" \+ angle\(s\) ([0-9])"); if (m.Success) { string angleList = m.Value.Replace("+ angle(s) ", string.Empty).Trim(); int angleCount; int.TryParse(angleList, out angleCount); thisTitle.AngleCount = angleCount; nextLine = output.ReadLine(); } } // Get duration for this title m = Regex.Match(nextLine, @"^ \+ duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})"); if (m.Success) thisTitle.Duration = TimeSpan.Parse(m.Groups[1].Value); // Get resolution, aspect ratio and FPS for this title m = Regex.Match(output.ReadLine(), @"^ \+ size: ([0-9]*)x([0-9]*), pixel aspect: ([0-9]*)/([0-9]*), display aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps"); if (m.Success) { thisTitle.Resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value)); thisTitle.ParVal = new Size(int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value)); thisTitle.AspectRatio = Math.Round(float.Parse(m.Groups[5].Value, CultureInfo.InvariantCulture), 2); thisTitle.Fps = float.Parse(m.Groups[6].Value, CultureInfo.InvariantCulture); } // Get autocrop region for this title m = Regex.Match(output.ReadLine(), @"^ \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)"); if (m.Success) { thisTitle.AutoCropDimensions = new Cropping { Top = int.Parse(m.Groups[1].Value), Bottom = int.Parse(m.Groups[2].Value), Left = int.Parse(m.Groups[3].Value), Right = int.Parse(m.Groups[4].Value) }; } thisTitle.Chapters.AddRange(Chapter.ParseList(output)); thisTitle.AudioTracks.AddRange(AudioHelper.ParseList(output)); thisTitle.Subtitles.AddRange(Subtitle.ParseList(output)); return thisTitle; }
/// <summary> /// Initializes a new instance of the <see cref="PreviewViewModel"/> class. /// </summary> /// <param name="errorService"> /// The error Service. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public PreviewViewModel(IErrorService errorService, IUserSettingService userSettingService) { // Preview needs a seperate instance rather than the shared singleton. This could maybe do with being refactored at some point this.encodeService = new EncodeServiceWrapper(userSettingService); this.errorService = errorService; this.userSettingService = userSettingService; this.Title = "Preview"; this.Percentage = "0.00%"; this.PercentageValue = 0; this.StartAt = 1; this.Duration = 30; this.CanPlay = true; UseSystemDefaultPlayer = userSettingService.GetUserSetting<bool>(UserSettingConstants.DefaultPlayer); this.Duration = userSettingService.GetUserSetting<int>(UserSettingConstants.LastPreviewDuration); }
/// <summary> /// Initializes a new instance of the <see cref="PreviewViewModel"/> class. /// </summary> /// <param name="encodeService"> /// The encode Service. /// </param> /// <param name="errorService"> /// The error Service. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public PreviewViewModel(IEncodeServiceWrapper encodeService, IErrorService errorService, IUserSettingService userSettingService) { this.encodeService = encodeService; this.errorService = errorService; this.userSettingService = userSettingService; this.Title = "Preview"; this.Percentage = "0.00%"; this.PercentageValue = 0; this.StartAt = 1; this.Duration = 30; UseSystemDefaultPlayer = userSettingService.GetUserSetting<bool>(UserSettingConstants.DefaultPlayer); }
/// <summary> /// Initializes a new instance of the <see cref="StaticPreviewViewModel"/> class. /// </summary> /// <param name="scanService"> /// The scan service. /// </param> /// <param name="userSettingService"> /// The user Setting Service. /// </param> public StaticPreviewViewModel(IScan scanService, IUserSettingService userSettingService) { this.scanService = scanService; this.selectedPreviewImage = 1; this.Title = Properties.Resources.Preview; this.PreviewNotAvailable = true; // Live Preview this.userSettingService = userSettingService; this.encodeService = new LibEncode(); // Preview needs a seperate instance rather than the shared singleton. This could maybe do with being refactored at some point this.Title = "Preview"; this.Percentage = "0.00%"; this.PercentageValue = 0; this.Duration = 30; this.CanPlay = true; UseSystemDefaultPlayer = userSettingService.GetUserSetting<bool>(UserSettingConstants.DefaultPlayer); this.Duration = userSettingService.GetUserSetting<int>(UserSettingConstants.LastPreviewDuration); }