/// <summary> /// Apply the caption settings /// </summary> /// <param name="settings">the new caption settings</param> public override void OnApplyCaptionSettings(PlayerFramework.CaptionSettings.Model.CustomCaptionSettings settings) { base.OnApplyCaptionSettings(settings); if (settings != null) { this.UpdateCaptionOptions(settings); } }
/// <summary> /// Update the Caption options /// </summary> /// <param name="settings">the custom caption settings</param> private void UpdateCaptionOptions(PlayerFramework.CaptionSettings.Model.CustomCaptionSettings settings) { CC608Plugin cc608plugIn = this.MediaPlayer.Plugins.OfType <CC608Plugin>().FirstOrDefault(); if (cc608plugIn != null) { var fontFamily = GetFontFamilyName(settings.FontFamily); var captionOptions = new Microsoft.PlayerFramework.CC608.CaptionOptions { FontFamily = fontFamily == null ? string.Empty : fontFamily, FontSize = settings.FontSize.HasValue ? settings.FontSize.Value : 100, FontBrush = settings.FontColor == null ? null : new SolidColorBrush(settings.FontColor.ToColor()), BackgroundBrush = settings.BackgroundColor == null ? null : new SolidColorBrush(settings.BackgroundColor.ToColor()), VideoWidth = this.MediaPlayer.ActualWidth }; if (settings.FontFamily == PlayerFramework.CaptionSettings.Model.FontFamily.Default || settings.FontFamily == PlayerFramework.CaptionSettings.Model.FontFamily.MonospaceSansSerif || settings.FontFamily == PlayerFramework.CaptionSettings.Model.FontFamily.MonospaceSerif) { captionOptions.CaptionWidth = 0; } else { double fontSize = 100; switch (captionOptions.FontSize) { case 50: fontSize = 75; break; case 100: break; case 150: fontSize = 120; break; case 200: fontSize = 130; break; } captionOptions.CaptionWidth = fontSize * this.MediaPlayer.ActualWidth * 0.5 / 100.0; } cc608plugIn.CaptionOptions = captionOptions; } }
/// <summary> /// Apply caption settings /// </summary> /// <param name="settings">the new caption settings</param> public override void OnApplyCaptionSettings(PlayerFramework.CaptionSettings.Model.CustomCaptionSettings settings) { var plugin = this.MediaPlayer.GetWebVTTPlugin(); var fontSize = plugin.CaptionsPanel.FontSize; var fontSizePercentage = plugin.CaptionsPanel.FontSizePercent; if (settings != null && settings.FontSize.HasValue) { fontSizePercentage = DefaultFontSizePercent * System.Convert.ToDouble(settings.FontSize.Value) / 100.0; plugin.CaptionsPanel.FontSizePercent = fontSizePercentage; } else { plugin.CaptionsPanel.FontSizePercent = DefaultFontSizePercent; } if (settings != null && settings.WindowColor != null) { var color = this.Settings.WindowColor.ToColor(); plugin.CaptionsPanel.PanelBackground = new Media.SolidColorBrush(color); } else { plugin.CaptionsPanel.PanelBackground = null; } if (settings != null && settings.BackgroundColor != null) { var color = this.Settings.BackgroundColor.ToColor(); var style = new Style(typeof(BoxElement)); style.Setters.Add(new Setter(Control.BackgroundProperty, new Media.SolidColorBrush(color))); plugin.CaptionsPanel.BoxStyle = style; } else { plugin.CaptionsPanel.BoxStyle = null; } }