/// <summary> /// This method handles the GUIGraphicsContext.OnVideoReceived() calls /// </summary> private void OnVideoReceived() { if (!isPlaying) { isVideoReceived = false; updatePending = false; return; } if (!isVideoReceived) { Log.Debug("ViewModeSwitcher: OnVideoReceived()"); updatePending = false; LastSwitchedGeometry = GUIGraphicsContext.ARType; isVideoReceived = true; workerEvent.Set(); } else if (!workerBusy) { workerEvent.Set(); } if (updatePending) { if (currentSettings.verboseLog) { Log.Debug("ViewModeSwitcher: OnVideoReceived(), Updating AR and crop"); } SetAspectRatio(NewGeometryMessage, LastSwitchedGeometry); SetCropMode(); updatePending = false; } }
private void LoadSettings() { using (Settings xmlreader = new MPSettings()) { //Video Codecs _strVideoCodec = xmlreader.GetValueAsString("movieplayer", "mpeg2videocodec", ""); _strH264VideoCodec = xmlreader.GetValueAsString("movieplayer", "h264videocodec", ""); _strAudioCodec = xmlreader.GetValueAsString("movieplayer", "mpeg2audiocodec", ""); _strVC1VideoCodec = xmlreader.GetValueAsString("movieplayer", "vc1videocodec", ""); _strVC1iVideoCodec = xmlreader.GetValueAsString("movieplayer", "vc1ivideocodec", ""); _strDivXVideoCodec = xmlreader.GetValueAsString("movieplayer", "xvidvideocodec", ""); // AR string aspectRatioText = xmlreader.GetValueAsString("movieplayer", "defaultar", "Normal"); _aspectRatio = Utils.GetAspectRatio(aspectRatioText); // Audio codecs _strAudioRenderer = xmlreader.GetValueAsString("movieplayer", "audiorenderer", "Default DirectSound Device"); _strAACAudioCodec = xmlreader.GetValueAsString("movieplayer", "aacaudiocodec", ""); _defaultSubtitleLanguage = xmlreader.GetValueAsString("subtitles", "language", "EN"); _defaultAudioLanguage = xmlreader.GetValueAsString("movieplayer", "audiolanguage", "EN"); // Splitter _strSplitterFilter = xmlreader.GetValueAsString("movieplayer", "splitterfilter", ""); _strSplitterFilesyncFilter = xmlreader.GetValueAsString("movieplayer", "splitterfilefilter", ""); // Subs/Language _subtitleSettings = xmlreader.GetValueAsBool("subtitles", "enabled", false); btnEnableSubtitles.Selected = _subtitleSettings; _playAll = xmlreader.GetValueAsInt("movies", "playallinfolder", 3); } }
/// <summary> /// Constructor which initialises the video handler /// </summary> /// <param name="player">Instance of external player</param> /// <param name="osdHandler">Instance of the osdHandler</param> public VideoHandler(MPlayerExtPlayer player, IOSDHandler osdHandler) { _player = player; _osdHandler = osdHandler; _aspectRatio = "1.0"; _videoHeight = -1; _videoWidth = 0; _ar = GUIGraphicsContext.ARType; _mplayerBackgroundPanel = new Panel { ForeColor = Color.Black, BackColor = Color.Black, Size = new Size(0, 0), Location = new Point(0, 0) }; _mplayerOuterPanel = new Panel { ForeColor = Color.Black, BackColor = Color.Black, Size = new Size(0, 0), Location = new Point(0, 0) }; _mplayerInnerPanel = new Panel { Size = new Size(0, 0), ForeColor = Color.FromArgb(16, 16, 16), BackColor = Color.FromArgb(16, 16, 16) }; _mplayerOuterPanel.Controls.Add(_mplayerInnerPanel); _mplayerInnerPanel.Location = new Point(0, 0); }
private void OnAspectRatio() { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(941); // Change aspect ratio dlg.AddLocalizedString(943); // Normal dlg.AddLocalizedString(944); // Original dlg.AddLocalizedString(947); // Zoom dlg.AddLocalizedString(1190); // Zoom 14:9 dlg.AddLocalizedString(942); // Stretch dlg.AddLocalizedString(945); // Letterbox dlg.AddLocalizedString(946); // Non linear stretch // set the focus to currently used mode dlg.SelectedLabel = (int)_aspectRatio; // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { OnVideo(); return; } _aspectRatio = Utils.GetAspectRatioByLangID(dlg.SelectedId); OnVideo(); }
/// <summary> /// Handles the g_Player.PlayBackStarted event /// </summary> public void OnVideoStarted(g_Player.MediaType type, string s) { // do not handle e.g. visualization window, last.fm player, etc if (type == g_Player.MediaType.Music) { isPlaying = false; return; } if (currentSettings.disableForVideo && (type != g_Player.MediaType.TV)) { isPlaying = false; return; } if (currentSettings.disableLBForVideo && (type != g_Player.MediaType.TV)) { disableLBGlobally = true; } else { disableLBGlobally = currentSettings.DisableLBGlobaly; } if (currentSettings.verboseLog) { Log.Debug("ViewModeSwitcher: On Video Started"); } LastSwitchedGeometry = GUIGraphicsContext.ARType; isVideoReceived = false; isPlaying = true; }
/// <summary> /// Sets the type of primitives this geometry contains. /// </summary> /// <param name="geometryType">Array of indices.</param> /// <since_tizen> 3 </since_tizen> public void SetType(Geometry.Type geometryType) { NDalicPINVOKE.Geometry_SetType(swigCPtr, (int)geometryType); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } }
/// <summary> /// Gets the type of primitives this geometry contains. /// </summary> /// <returns>Type of primitives this geometry contains.</returns> /// <since_tizen> 3 </since_tizen> public new Geometry.Type GetType() { Geometry.Type ret = (Geometry.Type)NDalicPINVOKE.Geometry_GetType(swigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
/// <summary> /// Sets up a change to aspect ratio of MediaPortal (actually happens later) /// </summary> /// <param name="MessageString">Message text of the switch message</param> /// <param name="AR">the aspect ratio to switch to</param> private bool SetNewGeometry(string MessageString, Geometry.Type AR) { if (LastSwitchedGeometry == AR) { return(false); } LastSwitchedGeometry = AR; NewGeometryMessage = MessageString; return(true); }
/// <summary> /// Changes the aspect ratio of MediaPortal /// </summary> /// <param name="MessageString">Message text of the switch message</param> /// <param name="AR">the aspect ratio to switch to</param> private bool SetAspectRatio(string MessageString, Geometry.Type AR) { if (GUIGraphicsContext.ARType == AR) { return(false); } Log.Info("ViewModeSwitcher: Switching to viewmode: " + AR); GUIGraphicsContext.ARType = AR; return(true); }
private void LoadSettings() { using (Settings xmlreader = new MPSettings()) { //Video Codecs _strVideoCodec = xmlreader.GetValueAsString("movieplayer", "mpeg2videocodec", ""); _strH264VideoCodec = xmlreader.GetValueAsString("movieplayer", "h264videocodec", ""); _strAudioCodec = xmlreader.GetValueAsString("movieplayer", "mpeg2audiocodec", ""); _strVC1VideoCodec = xmlreader.GetValueAsString("movieplayer", "vc1videocodec", ""); _strVC1iVideoCodec = xmlreader.GetValueAsString("movieplayer", "vc1ivideocodec", ""); _strDivXVideoCodec = xmlreader.GetValueAsString("movieplayer", "xvidvideocodec", ""); // AR string aspectRatioText = xmlreader.GetValueAsString("movieplayer", "defaultar", "Normal"); _aspectRatio = Utils.GetAspectRatio(aspectRatioText); // Audio codecs _strAudioRenderer = xmlreader.GetValueAsString("movieplayer", "audiorenderer", "Default DirectSound Device"); _strAACAudioCodec = xmlreader.GetValueAsString("movieplayer", "aacaudiocodec", ""); _defaultSubtitleLanguage = xmlreader.GetValueAsString("subtitles", "language", "EN"); _defaultAudioLanguage = xmlreader.GetValueAsString("movieplayer", "audiolanguage", "EN"); // Splitter _strSplitterFilter = xmlreader.GetValueAsString("movieplayer", "splitterfilter", ""); _strSplitterFilesyncFilter = xmlreader.GetValueAsString("movieplayer", "splitterfilefilter", ""); // Subs/Language _subtitleSettings = xmlreader.GetValueAsBool("subtitles", "enabled", false); btnEnableSubtitles.Selected = _subtitleSettings; _playAll = xmlreader.GetValueAsInt("movies", "playallinfolder", 3); _autoDecoderSettings = xmlreader.GetValueAsBool("movieplayer", "autodecodersettings", false); _ForceSourceSplitter = xmlreader.GetValueAsBool("movieplayer", "forcesourcesplitter", false); _mpCheckBoxTS = xmlreader.GetValueAsBool("movieplayer", "usemoviecodects", false); btnForceSourceSplitter.Selected = _ForceSourceSplitter; btnUseMovieCodects.Selected = _mpCheckBoxTS; btnautoDecoderSettings.Selected = _autoDecoderSettings; _audioDefaultCheckBox = xmlreader.GetValueAsBool("movieplayer", "audiodefaultlanguage", false); _streamLAVSelectionCheckBox = xmlreader.GetValueAsBool("movieplayer", "streamlavselection", false); btnUseAudioDefaultCheckBox.Selected = _audioDefaultCheckBox; btnUseSstreamLAVSelection.Selected = _streamLAVSelectionCheckBox; // Set Source Splitter check for first init to true. if (btnForceSourceSplitter.Selected && (_strSplitterFilter == "LAV Splitter Source" || _strSplitterFilter == "LAV Splitter")) { btnUseAudioDefaultCheckBox.IsEnabled = true; btnUseSstreamLAVSelection.IsEnabled = true; } else { btnUseAudioDefaultCheckBox.IsEnabled = false; btnUseSstreamLAVSelection.IsEnabled = false; btnUseAudioDefaultCheckBox.Selected = false; btnUseSstreamLAVSelection.Selected = false; } } }
/// <summary> /// Changes the aspect ratio of MediaPortal /// </summary> /// <param name="MessageString">Message text of the switch message</param> /// <param name="AR">the aspect ratio to switch to</param> private void SetAspectRatio(string MessageString, Geometry.Type AR) { Log.Info("ViewModeSwitcher: Switching to viewmode: " + AR); GUIGraphicsContext.ARType = AR; if (currentSettings.ShowSwitchMsg) { GUIDialogNotify SwitchMsg = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY); SwitchMsg.SetHeading("ViewModeSwitcher"); SwitchMsg.SetText(MessageString + " > " + AR); SwitchMsg.TimeOut = 2; SwitchMsg.DoModal(GUIWindowManager.ActiveWindow); } }
private void OnAspectRatioZoomMode() { Geometry.Type aspectRatio = Geometry.Type.Normal; using (Settings xmlreader = new MPSettings()) { string aspectRatioText = xmlreader.GetValueAsString("dvdplayer", "defaultar", "Normal"); aspectRatio = Utils.GetAspectRatio(aspectRatioText); } GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(GUILocalizeStrings.Get(496)); //Menu dlg.AddLocalizedString(943); // Normal dlg.AddLocalizedString(944); // Original dlg.AddLocalizedString(947); // Zoom dlg.AddLocalizedString(1190); // Zoom 14:9 dlg.AddLocalizedString(942); // Stretch dlg.AddLocalizedString(945); // Letterbox dlg.AddLocalizedString(946); // Non linear stretch // set the focus to currently used mode dlg.SelectedLabel = (int)aspectRatio; // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { OnAspectRatio(); return; } aspectRatio = Utils.GetAspectRatioByLangID(dlg.SelectedId); using (Settings xmlwriter = new MPSettings()) { string aspectRatioText = Utils.GetAspectRatio(aspectRatio); xmlwriter.SetValue("dvdplayer", "defaultar", aspectRatioText); } OnAspectRatio(); }
private void LoadSettings() { using (Settings xmlreader = new MPSettings()) { //Video Codecs _strVideoCodec = xmlreader.GetValueAsString("movieplayer", "mpeg2videocodec", ""); _strH264VideoCodec = xmlreader.GetValueAsString("movieplayer", "h264videocodec", ""); _strAudioCodec = xmlreader.GetValueAsString("movieplayer", "mpeg2audiocodec", ""); _strVC1VideoCodec = xmlreader.GetValueAsString("movieplayer", "vc1videocodec", ""); _strVC1iVideoCodec = xmlreader.GetValueAsString("movieplayer", "vc1ivideocodec", ""); _strDivXVideoCodec = xmlreader.GetValueAsString("movieplayer", "xvidvideocodec", ""); // AR string aspectRatioText = xmlreader.GetValueAsString("movieplayer", "defaultar", "Normal"); _aspectRatio = Utils.GetAspectRatio(aspectRatioText); // Audio codecs _strAudioRenderer = xmlreader.GetValueAsString("movieplayer", "audiorenderer", "Default DirectSound Device"); _strAACAudioCodec = xmlreader.GetValueAsString("movieplayer", "aacaudiocodec", ""); _defaultSubtitleLanguage = xmlreader.GetValueAsString("subtitles", "language", "EN"); _defaultAudioLanguage = xmlreader.GetValueAsString("movieplayer", "audiolanguage", "EN"); // Splitter _strSplitterFilter = xmlreader.GetValueAsString("movieplayer", "splitterfilter", ""); _strSplitterFilesyncFilter = xmlreader.GetValueAsString("movieplayer", "splitterfilefilter", ""); // Subs/Language _subtitleSettings = xmlreader.GetValueAsBool("subtitles", "enabled", false); btnEnableSubtitles.Selected = _subtitleSettings; _playAll = xmlreader.GetValueAsInt("movies", "playallinfolder", 3); _autoDecoderSettings = xmlreader.GetValueAsBool("movieplayer", "autodecodersettings", false); _ForceSourceSplitter = xmlreader.GetValueAsBool("movieplayer", "forcesourcesplitter", false); _mpCheckBoxTS = xmlreader.GetValueAsBool("movieplayer", "usemoviecodects", false); btnForceSourceSplitter.Selected = _ForceSourceSplitter; btnUseMovieCodects.Selected = _mpCheckBoxTS; btnautoDecoderSettings.Selected = _autoDecoderSettings; } }
public override bool Play(string strFile) { updateTimer = DateTime.Now; m_speedRate = 10000; GUIGraphicsContext.IsWindowVisible = false; m_iVolume = 100; _state = PlayState.Init; m_strCurrentFile = strFile; m_bFullScreen = true; m_ar = GUIGraphicsContext.ARType; VideoRendererStatistics.VideoState = VideoRendererStatistics.State.VideoPresent; _updateNeeded = true; Log.Info("RTSPPlayer:play {0}", strFile); //lock ( typeof(VideoPlayerVMR7) ) { CloseInterfaces(); m_bStarted = false; if (!GetInterfaces()) { m_strCurrentFile = ""; CloseInterfaces(); return false; } int hr = mediaEvt.SetNotifyWindow(GUIGraphicsContext.ActiveForm, WM_GRAPHNOTIFY, IntPtr.Zero); if (hr < 0) { Error.SetError("Unable to play movie", "Can not set notifications"); m_strCurrentFile = ""; CloseInterfaces(); return false; } DirectShowUtil.SetARMode(graphBuilder, AspectRatioMode.Stretched); _rotEntry = new DsROTEntry((IFilterGraph)graphBuilder); // DsUtils.DumpFilters(graphBuilder); hr = _mediaCtrl.Run(); if (hr < 0) { Error.SetError("Unable to play movie", "Unable to start movie"); m_strCurrentFile = ""; CloseInterfaces(); return false; } GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAYBACK_STARTED, 0, 0, 0, 0, 0, null); msg.Label = strFile; GUIWindowManager.SendThreadMessage(msg); _state = PlayState.Playing; //Brutus GUIGraphicsContext.IsFullScreenVideo=true; m_iPositionX = GUIGraphicsContext.VideoWindow.X; m_iPositionY = GUIGraphicsContext.VideoWindow.Y; m_iWidth = GUIGraphicsContext.VideoWindow.Width; m_iHeight = GUIGraphicsContext.VideoWindow.Height; m_ar = GUIGraphicsContext.ARType; _updateNeeded = true; SetVideoWindow(); mediaPos.get_Duration(out _duration); Log.Info("RTSPPlayer:Duration:{0}", _duration); if (_mediaType == g_Player.MediaType.TV) { //if (_duration < 1) _duration = 1; //SeekAbsolute(_duration - 1); } else { //SeekAbsolute(0); } OnInitialized(); } // Wait for a while to wait VMR9 to get ready. // Implemented due to problems starting to play before VMR9 was ready resulting in black screen. Thread.Sleep(200); return true; }
/// <summary> /// load settings from configuration /// </summary> /// <returns></returns> public bool LoadSettings(string ImportFileName) { string tmpConfigFileName = Config.GetFile(Config.Dir.Config, "ViewModeSwitcher.xml"); if (ImportFileName != string.Empty) { tmpConfigFileName = ImportFileName; } using (Settings reader = new Settings(tmpConfigFileName)) { verboseLog = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmVerboselog, false); ShowSwitchMsg = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmShowSwitchMsg, false); UseFallbackRule = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmUseFallbackRule, true); String tmpFallbackViewMode = reader.GetValueAsString(ViewModeSwitcherSectionName, ParmFallbackViewMode, "Normal"); FallBackViewMode = StringToViewMode(tmpFallbackViewMode); DisableLBGlobaly = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmDisableLBGlobaly, false); LBBlackLevel = reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmBlackLevel, 40); fboverScan = reader.GetValueAsInt(ViewModeSwitcherSectionName, FallBackOverScan, 0); CropLeft = reader.GetValueAsInt("tv", "cropleft", 0); CropRight = reader.GetValueAsInt("tv", "cropright", 0); CropTop = reader.GetValueAsInt("tv", "croptop", 0); CropBottom = reader.GetValueAsInt("tv", "cropbottom", 0); bool tmpReturn = false; ViewModeRules.Clear(); int tmpRuleCount = reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmRuleCount, 0); if (tmpRuleCount <= 0) { Rule tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "4:3"; tmpRule.ARFrom = 1.1f; tmpRule.ARTo = 1.334f; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 2000; tmpRule.ChangeAR = true; tmpRule.ViewMode = Geometry.Type.NonLinearStretch; tmpRule.ChangeOs = true; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "16:9"; tmpRule.ARFrom = 1.77f; tmpRule.ARTo = 1.78f; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 2000; tmpRule.ChangeAR = true; tmpRule.ViewMode = Geometry.Type.Normal; tmpRule.ChangeOs = true; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = true; ViewModeRules.Add(tmpRule); return(true); } for (int i = 1; i <= tmpRuleCount; i++) { Rule tmpRule = new Rule(); tmpRule.Enabled = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Enabled", false); if (tmpRule.Enabled) { tmpReturn = true; } tmpRule.Name = reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Name", "noname"); tmpRule.ARFrom = (float) Convert.ToDouble(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ARFrom", "0")); tmpRule.ARTo = (float) Convert.ToDouble(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ARTo", "0")); tmpRule.MinWidth = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MinWidth", "0")); tmpRule.MaxWidth = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MaxWidth", "0")); tmpRule.MinHeight = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MinHeight", "0")); tmpRule.MaxHeight = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MaxHeight", "0")); tmpRule.ChangeAR = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ChangeAR", true); String tmpViewMode = reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ViewMode", "Normal"); tmpRule.ViewMode = StringToViewMode(tmpViewMode); tmpRule.ChangeOs = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ChangeOS", true); tmpRule.OverScan = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Overscan", "0")); tmpRule.EnableLBDetection = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "EnableLBDetection", false); tmpRule.VerticalOffSetZoom = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "VerticalOffSetZoom", "0")); tmpRule.VerticalOffSet14_9 = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "VerticalOffSet14_9", "0")); tmpRule.VerticalOffSetWide14_9 = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "VerticalOffSetWide14_9", "0")); ViewModeRules.Add(tmpRule); } return(tmpReturn); } }
/// <summary> /// load settings from configuration /// </summary> /// <returns></returns> public bool LoadSettings(string ImportFileName) { string tmpConfigFileName = Config.GetFile(Config.Dir.Config, SettingsFileName); if (ImportFileName != string.Empty) { tmpConfigFileName = ImportFileName; } using (Settings reader = new Settings(tmpConfigFileName)) { verboseLog = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmVerboselog, false); ShowSwitchMsg = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmShowSwitchMsg, false); UseFallbackRule = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmUseFallbackRule, true); String tmpFallbackViewMode = reader.GetValueAsString(ViewModeSwitcherSectionName, ParmFallbackViewMode, "Normal"); FallBackViewMode = StringToViewMode(tmpFallbackViewMode); DisableLBGlobaly = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmDisableLBGlobaly, false); LBMaxBlackLevel = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmBlackLevel, 32), 4), 255); LBMinBlackLevel = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmMinBlackLevel, 16), 4), 255); fboverScan = reader.GetValueAsInt(ViewModeSwitcherSectionName, FallBackOverScan, 8); CropLeft = reader.GetValueAsInt("tv", "cropleft", 0); CropRight = reader.GetValueAsInt("tv", "cropright", 0); CropTop = reader.GetValueAsInt("tv", "croptop", 0); CropBottom = reader.GetValueAsInt("tv", "cropbottom", 0); disableForVideo = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmDisableForVideo, false); disableLBForVideo = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmDisableLBForVideo, false); LBSymLimitPercent = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmSymLimitPercent, 10), 5), 90); LBdetectInterval = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmLBdetectInterval, 4), 2), 120); LBMaxCropLimitPercent = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmMaxCropLimitPercent, 12), 0), 50); DetectWidthPercent = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmDetectWidthPercent, 40), 10), 90); DetectHeightPercent = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmDetectHeightPercent, 40), 10), 90); if (verboseLog) { Log.Debug("ViewModeSwitcher: Global Rule, ShowSwitchMsg: " + ShowSwitchMsg); Log.Debug("ViewModeSwitcher: Global Rule, UseFallbackRule: " + UseFallbackRule); Log.Debug("ViewModeSwitcher: Global Rule, FallBackViewMode: " + FallBackViewMode); Log.Debug("ViewModeSwitcher: Global Rule, FallbackOverscan: " + fboverScan); Log.Debug("ViewModeSwitcher: Global Rule, DisableBBDetect: " + DisableLBGlobaly); Log.Debug("ViewModeSwitcher: Global Rule, BBMaxBlackLevel: " + LBMaxBlackLevel); Log.Debug("ViewModeSwitcher: Global Rule, BBMinBlackLevel: " + LBMinBlackLevel); Log.Debug("ViewModeSwitcher: Global Rule, BBSymLimitPercent: " + LBSymLimitPercent); Log.Debug("ViewModeSwitcher: Global Rule, BBdetectInterval: " + LBdetectInterval); Log.Debug("ViewModeSwitcher: Global Rule, BBMaxCropLimPercent: " + LBMaxCropLimitPercent); Log.Debug("ViewModeSwitcher: Global Rule, BBDetectWidthPercent: " + DetectWidthPercent); Log.Debug("ViewModeSwitcher: Global Rule, BBDetectHeightPercent: " + DetectHeightPercent); Log.Debug("ViewModeSwitcher: Global Rule, disableForVideo: " + disableForVideo); Log.Debug("ViewModeSwitcher: Global Rule, disableBBForVideo: " + disableLBForVideo); } bool tmpReturn = false; ViewModeRules.Clear(); int tmpRuleCount = reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmRuleCount, 0); if (tmpRuleCount <= 0) { Rule tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "4:3 SD"; tmpRule.ARFrom = 1.2; tmpRule.ARTo = 1.46; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 799; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 599; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = true; tmpRule.AutoCrop = true; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "4:3 HD"; tmpRule.ARFrom = 1.2; tmpRule.ARTo = 1.46; tmpRule.MinWidth = 800; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 600; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 16; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "16:9 SD"; tmpRule.ARFrom = 1.7; tmpRule.ARTo = 1.9; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 799; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 599; tmpRule.ViewMode = Geometry.Type.Normal; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = true; tmpRule.AutoCrop = true; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "16:9 HD"; tmpRule.ARFrom = 1.7; tmpRule.ARTo = 1.9; tmpRule.MinWidth = 800; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 600; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Normal; tmpRule.OverScan = 16; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "21:9 SD"; tmpRule.ARFrom = 2.2; tmpRule.ARTo = 2.45; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 799; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 599; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = true; tmpRule.AutoCrop = true; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "21:9 HD"; tmpRule.ARFrom = 2.2; tmpRule.ARTo = 2.45; tmpRule.MinWidth = 800; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 600; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 16; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "4:3 inside 16:9"; tmpRule.ARFrom = -1.2; tmpRule.ARTo = -1.46; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "16:9 inside 4:3"; tmpRule.ARFrom = -1.47; tmpRule.ARTo = -1.95; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Zoom; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "21:9 inside 16:9"; tmpRule.ARFrom = -2.1; tmpRule.ARTo = -2.57; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); return true; } for (int i = 1; i <= tmpRuleCount; i++) { Rule tmpRule = new Rule(); tmpRule.Enabled = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Enabled", false); if (tmpRule.Enabled) { tmpReturn = true; } tmpRule.Name = reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Name", "noname"); int tmpARFrom = Convert.ToInt32(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ARFromX1000", "1200")); tmpRule.ARFrom = ((double)tmpARFrom)/1000.0; int tmpARTo = Convert.ToInt32(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ARToX1000", "1460")); tmpRule.ARTo = ((double)tmpARTo)/1000.0; tmpRule.MinWidth = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MinWidth", "200")); tmpRule.MaxWidth = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MaxWidth", "2000")); tmpRule.MinHeight = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MinHeight", "200")); tmpRule.MaxHeight = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MaxHeight", "2000")); String tmpViewMode = reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ViewMode", "Normal"); tmpRule.ViewMode = StringToViewMode(tmpViewMode); tmpRule.OverScan = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Overscan", "8")); tmpRule.EnableLBDetection = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "EnableLBDetection", false); tmpRule.AutoCrop = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "AutoCrop", false); tmpRule.MaxCrop = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MaxCrop", true); ViewModeRules.Add(tmpRule); if (verboseLog) { Log.Debug("ViewModeSwitcher: Rule " + i + ", Name: " + tmpRule.Name ); Log.Debug("ViewModeSwitcher: Rule " + i + ", Enabled: " + tmpRule.Enabled ); Log.Debug("ViewModeSwitcher: Rule " + i + ", ARFrom: " + tmpRule.ARFrom ); Log.Debug("ViewModeSwitcher: Rule " + i + ", ARTo: " + tmpRule.ARTo ); Log.Debug("ViewModeSwitcher: Rule " + i + ", MinWidth: " + tmpRule.MinWidth ); Log.Debug("ViewModeSwitcher: Rule " + i + ", MaxWidth: " + tmpRule.MaxWidth ); Log.Debug("ViewModeSwitcher: Rule " + i + ", MinHeight: " + tmpRule.MinHeight ); Log.Debug("ViewModeSwitcher: Rule " + i + ", MaxHeight: " + tmpRule.MaxHeight ); Log.Debug("ViewModeSwitcher: Rule " + i + ", AutoCrop: " + tmpRule.AutoCrop ); Log.Debug("ViewModeSwitcher: Rule " + i + ", ViewMode: " + tmpRule.ViewMode ); Log.Debug("ViewModeSwitcher: Rule " + i + ", MaxCrop: " + tmpRule.MaxCrop ); Log.Debug("ViewModeSwitcher: Rule " + i + ", OverScan: " + tmpRule.OverScan ); Log.Debug("ViewModeSwitcher: Rule " + i + ", EnLBDet: " + tmpRule.EnableLBDetection); } } return tmpReturn; } }
/// <summary> /// Handles the g_Player.PlayBackStarted event /// </summary> public void OnVideoStarted(g_Player.MediaType type, string s) { // do not handle e.g. visualization window, last.fm player, etc if (type == g_Player.MediaType.Music) { isPlaying = false; return; } if (currentSettings.disableForVideo && (type != g_Player.MediaType.TV)) { isPlaying = false; return; } if (currentSettings.disableLBForVideo && (type != g_Player.MediaType.TV)) { disableLBGlobally = true; } else { disableLBGlobally = currentSettings.DisableLBGlobaly; } if (currentSettings.verboseLog) { Log.Debug("ViewModeSwitcher: On Video Started"); } LastSwitchedGeometry = GUIGraphicsContext.ARType; isVideoReceived = false; isPlaying = true; }
public override bool Play(string strFile) { Log.Info("Streambufferplayer play:{0}", strFile); if (!File.Exists(strFile)) { return false; } iSpeed = 1; _speedRate = 10000; _isLive = false; _duration = -1d; string extension = Path.GetExtension(strFile).ToLower(); if (extension.Equals(".tv")) { _isLive = true; } else { VideoRendererStatistics.VideoState = VideoRendererStatistics.State.VideoPresent; } _minBackingFiles = 6; _maxBackingFiles = 8; int iTimeShiftBuffer = 30; using (Settings xmlreader = new MPSettings()) { iTimeShiftBuffer = xmlreader.GetValueAsInt("capture", "timeshiftbuffer", 30); if (iTimeShiftBuffer < 5) { iTimeShiftBuffer = 5; } } iTimeShiftBuffer *= 60; //in seconds _backingFileDuration = (int)(iTimeShiftBuffer / 6); _isVisible = false; _isWindowVisible = false; _volume = 100; _state = PlayState.Init; _currentFile = strFile; _isFullscreen = false; _geometry = Geometry.Type.Normal; _updateNeeded = true; if (_bufferSource != null) { Log.Info("StreamBufferPlayer:replay {0}", strFile); IFileSourceFilter fileSource = (IFileSourceFilter)_bufferSource; fileSource.Load(strFile, null); ReInit(); } else { Log.Info("StreamBufferPlayer:play {0}", strFile); GC.Collect(); CloseInterfaces(); GC.Collect(); _isStarted = false; if (!GetInterfaces(strFile)) { Log.Error("StreamBufferPlayer:GetInterfaces() failed"); _currentFile = ""; return false; } _rotEntry = new DsROTEntry((IFilterGraph)_graphBuilder); } int hr = _mediaEvt.SetNotifyWindow(GUIGraphicsContext.ActiveForm, WM_GRAPHNOTIFY, IntPtr.Zero); if (hr < 0) { Log.Error("StreamBufferPlayer:SetNotifyWindow() failed"); _currentFile = ""; CloseInterfaces(); return false; } if (_videoWin != null) { _videoWin.put_Owner(GUIGraphicsContext.ActiveForm); _videoWin.put_WindowStyle( (WindowStyle)((int)WindowStyle.Child + (int)WindowStyle.ClipSiblings + (int)WindowStyle.ClipChildren)); _videoWin.put_MessageDrain(GUIGraphicsContext.form.Handle); } if (_basicVideo != null) { hr = _basicVideo.GetVideoSize(out _videoWidth, out _videoHeight); if (hr < 0) { Log.Error("StreamBufferPlayer:GetVideoSize() failed"); _currentFile = ""; CloseInterfaces(); return false; } Log.Info("StreamBufferPlayer:VideoSize:{0}x{1}", _videoWidth, _videoHeight); } GUIGraphicsContext.VideoSize = new Size(_videoWidth, _videoHeight); if (_mediaCtrl == null) { Log.Error("StreamBufferPlayer:_mediaCtrl==null"); _currentFile = ""; CloseInterfaces(); return false; } //DsUtils.DumpFilters(_graphBuilder); _positionX = GUIGraphicsContext.VideoWindow.X; _positionY = GUIGraphicsContext.VideoWindow.Y; _width = GUIGraphicsContext.VideoWindow.Width; _height = GUIGraphicsContext.VideoWindow.Height; _geometry = GUIGraphicsContext.ARType; _updateNeeded = true; SetVideoWindow(); DirectShowUtil.EnableDeInterlace(_graphBuilder); hr = _mediaCtrl.Run(); if (hr < 0) { Log.Error("StreamBufferPlayer:Rungraph failed"); _currentFile = ""; CloseInterfaces(); return false; } GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAYBACK_STARTED, 0, 0, 0, 0, 0, null); msg.Label = strFile; GUIWindowManager.SendThreadMessage(msg); _state = PlayState.Playing; if (_isLive) { /* DateTime dt = DateTime.Now; do { UpdateDuration(); System.Windows.Forms.Application.DoEvents(); TimeSpan ts = DateTime.Now - dt; if (ts.TotalSeconds > 0) break; } while (_duration < 4); */ UpdateDuration(); UpdateCurrentPosition(); double dPos = _duration - 2; if (dPos >= 0 && CurrentPosition < dPos) { //Log.Info("StreamBufferPlayer:Seek to end"); SeekAbsolute(dPos); } } else { //seek to end of file long lTime = 5 * 60 * 60; lTime *= 10000000; long pStop = 0; hr = _mediaSeeking.SetPositions(new DsLong(lTime), AMSeekingSeekingFlags.AbsolutePositioning, new DsLong(pStop), AMSeekingSeekingFlags.NoPositioning); if (hr == 0) { long lStreamPos; _mediaSeeking.GetCurrentPosition(out lStreamPos); // stream position _duration = lStreamPos; _duration /= 10000000d; SeekAsolutePercentage(0); } } //Log.Info("StreamBufferPlayer:playing duration:{0}",Utils.SecondsToHMSString( (int)_duration) ); _state = PlayState.Playing; OnInitialized(); return true; }
public override bool Play(string strFile) { updateTimer = DateTime.Now; m_speedRate = 10000; m_bVisible = false; m_iVolume = 100; m_state = PlayState.Init; m_strCurrentFile = strFile; m_bFullScreen = true; m_ar = GUIGraphicsContext.ARType; VideoRendererStatistics.VideoState = VideoRendererStatistics.State.VideoPresent; _updateNeeded = true; Log.Info("VideoPlayer:play {0}", strFile); //lock ( typeof(VideoPlayerVMR7) ) { CloseInterfaces(); m_bStarted = false; if (!GetInterfaces()) { m_strCurrentFile = ""; CloseInterfaces(); return false; } #region FFDShowEngine and PostProcessingEngine Detection ISubEngine engine = SubEngine.GetInstance(true); if (!engine.LoadSubtitles(graphBuilder, m_strCurrentFile)) { SubEngine.engine = new SubEngine.DummyEngine(); } IPostProcessingEngine postengine = PostProcessingEngine.GetInstance(true); if (!postengine.LoadPostProcessing(graphBuilder)) { PostProcessingEngine.engine = new PostProcessingEngine.DummyEngine(); } #endregion AnalyseStreams(); SelectSubtitles(); SelectAudioLanguage(); OnInitialized(); int hr = mediaEvt.SetNotifyWindow(GUIGraphicsContext.ActiveForm, WM_GRAPHNOTIFY, IntPtr.Zero); if (hr < 0) { Error.SetError("Unable to play movie", "Can not set notifications"); m_strCurrentFile = ""; CloseInterfaces(); return false; } if (videoWin != null) { videoWin.put_Owner(GUIGraphicsContext.ActiveForm); videoWin.put_WindowStyle( (WindowStyle)((int)WindowStyle.Child + (int)WindowStyle.ClipChildren + (int)WindowStyle.ClipSiblings)); videoWin.put_MessageDrain(GUIGraphicsContext.form.Handle); } if (basicVideo != null) { hr = basicVideo.GetVideoSize(out m_iVideoWidth, out m_iVideoHeight); if (hr < 0) { Error.SetError("Unable to play movie", "Can not find movie width/height"); m_strCurrentFile = ""; CloseInterfaces(); return false; } } /* GUIGraphicsContext.DX9Device.Clear( ClearFlags.Target, Color.Black, 1.0f, 0); try { // Show the frame on the primary surface. GUIGraphicsContext.DX9Device.Present(); } catch(DeviceLostException) { }*/ DirectShowUtil.SetARMode(graphBuilder, AspectRatioMode.Stretched); // DsUtils.DumpFilters(graphBuilder); try { hr = mediaCtrl.Run(); DsError.ThrowExceptionForHR(hr); } catch (Exception error) { Log.Error("VideoPlayer: Unable to play with reason - {0}", error.Message); } if (hr < 0) { Error.SetError("Unable to play movie", "Unable to start movie"); m_strCurrentFile = ""; CloseInterfaces(); return false; } GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAYBACK_STARTED, 0, 0, 0, 0, 0, null); msg.Label = strFile; GUIWindowManager.SendThreadMessage(msg); m_state = PlayState.Playing; //Brutus GUIGraphicsContext.IsFullScreenVideo=true; m_iPositionX = GUIGraphicsContext.VideoWindow.X; m_iPositionY = GUIGraphicsContext.VideoWindow.Y; m_iWidth = GUIGraphicsContext.VideoWindow.Width; m_iHeight = GUIGraphicsContext.VideoWindow.Height; m_ar = GUIGraphicsContext.ARType; _updateNeeded = true; SetVideoWindow(); mediaPos.get_Duration(out m_dDuration); Log.Info("VideoPlayer:Duration:{0}", m_dDuration); } return true; }
/// <summary> /// load settings from configuration /// </summary> /// <returns></returns> public bool LoadSettings(string ImportFileName) { string tmpConfigFileName = Config.GetFile(Config.Dir.Config, SettingsFileName); if (ImportFileName != string.Empty) { tmpConfigFileName = ImportFileName; } using (Settings reader = new Settings(tmpConfigFileName)) { verboseLog = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmVerboselog, false); ShowSwitchMsg = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmShowSwitchMsg, false); UseFallbackRule = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmUseFallbackRule, true); String tmpFallbackViewMode = reader.GetValueAsString(ViewModeSwitcherSectionName, ParmFallbackViewMode, "Normal"); FallBackViewMode = StringToViewMode(tmpFallbackViewMode); DisableLBGlobaly = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmDisableLBGlobaly, false); LBMaxBlackLevel = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmBlackLevel, 32), 4), 255); LBMinBlackLevel = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmMinBlackLevel, 16), 4), 255); fboverScan = reader.GetValueAsInt(ViewModeSwitcherSectionName, FallBackOverScan, 8); CropLeft = reader.GetValueAsInt("tv", "cropleft", 0); CropRight = reader.GetValueAsInt("tv", "cropright", 0); CropTop = reader.GetValueAsInt("tv", "croptop", 0); CropBottom = reader.GetValueAsInt("tv", "cropbottom", 0); disableForVideo = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmDisableForVideo, false); disableLBForVideo = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmDisableLBForVideo, false); LBSymLimitPercent = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmSymLimitPercent, 10), 5), 90); LBdetectInterval = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmLBdetectInterval, 4), 2), 120); LBMaxCropLimitPercent = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmMaxCropLimitPercent, 12), 0), 50); DetectWidthPercent = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmDetectWidthPercent, 40), 10), 90); DetectHeightPercent = Math.Min(Math.Max(reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmDetectHeightPercent, 40), 10), 90); if (verboseLog) { Log.Debug("ViewModeSwitcher: Global Rule, ShowSwitchMsg: " + ShowSwitchMsg); Log.Debug("ViewModeSwitcher: Global Rule, UseFallbackRule: " + UseFallbackRule); Log.Debug("ViewModeSwitcher: Global Rule, FallBackViewMode: " + FallBackViewMode); Log.Debug("ViewModeSwitcher: Global Rule, FallbackOverscan: " + fboverScan); Log.Debug("ViewModeSwitcher: Global Rule, DisableBBDetect: " + DisableLBGlobaly); Log.Debug("ViewModeSwitcher: Global Rule, BBMaxBlackLevel: " + LBMaxBlackLevel); Log.Debug("ViewModeSwitcher: Global Rule, BBMinBlackLevel: " + LBMinBlackLevel); Log.Debug("ViewModeSwitcher: Global Rule, BBSymLimitPercent: " + LBSymLimitPercent); Log.Debug("ViewModeSwitcher: Global Rule, BBdetectInterval: " + LBdetectInterval); Log.Debug("ViewModeSwitcher: Global Rule, BBMaxCropLimPercent: " + LBMaxCropLimitPercent); Log.Debug("ViewModeSwitcher: Global Rule, BBDetectWidthPercent: " + DetectWidthPercent); Log.Debug("ViewModeSwitcher: Global Rule, BBDetectHeightPercent: " + DetectHeightPercent); Log.Debug("ViewModeSwitcher: Global Rule, disableForVideo: " + disableForVideo); Log.Debug("ViewModeSwitcher: Global Rule, disableBBForVideo: " + disableLBForVideo); } bool tmpReturn = false; ViewModeRules.Clear(); int tmpRuleCount = reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmRuleCount, 0); if (tmpRuleCount <= 0) { Rule tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "4:3 SD"; tmpRule.ARFrom = 1.2; tmpRule.ARTo = 1.46; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 799; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 599; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = true; tmpRule.AutoCrop = true; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "4:3 HD"; tmpRule.ARFrom = 1.2; tmpRule.ARTo = 1.46; tmpRule.MinWidth = 800; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 600; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 16; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "16:9 SD"; tmpRule.ARFrom = 1.7; tmpRule.ARTo = 1.9; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 799; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 599; tmpRule.ViewMode = Geometry.Type.Normal; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = true; tmpRule.AutoCrop = true; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "16:9 HD"; tmpRule.ARFrom = 1.7; tmpRule.ARTo = 1.9; tmpRule.MinWidth = 800; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 600; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Normal; tmpRule.OverScan = 16; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "21:9 SD"; tmpRule.ARFrom = 2.2; tmpRule.ARTo = 2.45; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 799; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 599; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = true; tmpRule.AutoCrop = true; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "21:9 HD"; tmpRule.ARFrom = 2.2; tmpRule.ARTo = 2.45; tmpRule.MinWidth = 800; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 600; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 16; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "4:3 inside 16:9"; tmpRule.ARFrom = -1.2; tmpRule.ARTo = -1.46; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "16:9 inside 4:3"; tmpRule.ARFrom = -1.47; tmpRule.ARTo = -1.95; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Zoom; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "21:9 inside 16:9"; tmpRule.ARFrom = -2.1; tmpRule.ARTo = -2.57; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 2000; tmpRule.ViewMode = Geometry.Type.Zoom14to9; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = false; tmpRule.AutoCrop = false; tmpRule.MaxCrop = true; ViewModeRules.Add(tmpRule); return(true); } for (int i = 1; i <= tmpRuleCount; i++) { Rule tmpRule = new Rule(); tmpRule.Enabled = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Enabled", false); if (tmpRule.Enabled) { tmpReturn = true; } tmpRule.Name = reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Name", "noname"); int tmpARFrom = Convert.ToInt32(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ARFromX1000", "1200")); tmpRule.ARFrom = ((double)tmpARFrom) / 1000.0; int tmpARTo = Convert.ToInt32(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ARToX1000", "1460")); tmpRule.ARTo = ((double)tmpARTo) / 1000.0; tmpRule.MinWidth = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MinWidth", "200")); tmpRule.MaxWidth = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MaxWidth", "2000")); tmpRule.MinHeight = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MinHeight", "200")); tmpRule.MaxHeight = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MaxHeight", "2000")); String tmpViewMode = reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ViewMode", "Normal"); tmpRule.ViewMode = StringToViewMode(tmpViewMode); tmpRule.OverScan = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Overscan", "8")); tmpRule.EnableLBDetection = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "EnableLBDetection", false); tmpRule.AutoCrop = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "AutoCrop", false); tmpRule.MaxCrop = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MaxCrop", true); ViewModeRules.Add(tmpRule); if (verboseLog) { Log.Debug("ViewModeSwitcher: Rule " + i + ", Name: " + tmpRule.Name); Log.Debug("ViewModeSwitcher: Rule " + i + ", Enabled: " + tmpRule.Enabled); Log.Debug("ViewModeSwitcher: Rule " + i + ", ARFrom: " + tmpRule.ARFrom); Log.Debug("ViewModeSwitcher: Rule " + i + ", ARTo: " + tmpRule.ARTo); Log.Debug("ViewModeSwitcher: Rule " + i + ", MinWidth: " + tmpRule.MinWidth); Log.Debug("ViewModeSwitcher: Rule " + i + ", MaxWidth: " + tmpRule.MaxWidth); Log.Debug("ViewModeSwitcher: Rule " + i + ", MinHeight: " + tmpRule.MinHeight); Log.Debug("ViewModeSwitcher: Rule " + i + ", MaxHeight: " + tmpRule.MaxHeight); Log.Debug("ViewModeSwitcher: Rule " + i + ", AutoCrop: " + tmpRule.AutoCrop); Log.Debug("ViewModeSwitcher: Rule " + i + ", ViewMode: " + tmpRule.ViewMode); Log.Debug("ViewModeSwitcher: Rule " + i + ", MaxCrop: " + tmpRule.MaxCrop); Log.Debug("ViewModeSwitcher: Rule " + i + ", OverScan: " + tmpRule.OverScan); Log.Debug("ViewModeSwitcher: Rule " + i + ", EnLBDet: " + tmpRule.EnableLBDetection); } } return(tmpReturn); } }
private void Worker() { bool debugToggle = false; int loopCount = 0; while (true) { if (stopWorkerThread) { workerBusy = false; stopWorkerThread = false; videoRecvEvent.Set(); return; } if (isVideoReceived && isPlaying) { workerBusy = true; if (debugToggle) { Log.Debug("ViewModeSwitcher: Reset AR to original"); GUIGraphicsContext.ARType = Geometry.Type.Zoom14to9; updatePending = true; //force AR type update LastSwitchedAspectRatio = 0.0; LastDetectionResult = false; } else if (!updatePending) { if (LastSwitchedGeometry != GUIGraphicsContext.ARType) { //Geometry (zoom mode) has been changed by user //so disable black bar detection and //reset cropping to fallback settings Log.Debug("ViewModeSwitcher: Zoom mode changed by user"); enableLB = false; Crop((double)currentSettings.fboverScan); LastSwitchedGeometry = GUIGraphicsContext.ARType; updatePending = true; } CheckAspectRatios(); if ((loopCount % currentSettings.LBdetectInterval) == 0) { if (useAutoCrop) { LastDetectionResult = false; } if (!disableLBGlobally && !LastDetectionResult && enableLB) { if (currentSettings.verboseLog) { Log.Debug("ViewModeSwitcher: Black Bar detect"); } LastDetectionResult = true; SingleCrop(); } else { NoMatchCropCount = 0; } } } //debugToggle = !debugToggle; loopCount++; videoRecvEvent.Set(); workerEvent.WaitOne(247); // reset automatically - timeout after 247ms wait } else { workerBusy = false; LastSwitchedAspectRatio = 0.0; LastAnamorphFactor = 0.0; LastDetectionResult = true; isPBorLB = false; updatePending = false; forceAutoCrop = false; NoMatchCropCount = 0; loopCount = (currentSettings.LBdetectInterval-1); //Perform a black-bar detect one loop cycle after start if (currentSettings.verboseLog) { Log.Debug("ViewModeSwitcher: Worker thread -> idle"); } videoRecvEvent.Set(); workerEvent.WaitOne(); // reset automatically - sleep until triggered } } }
private void Worker() { bool debugToggle = false; int loopCount = 0; while (true) { if (stopWorkerThread) { workerBusy = false; stopWorkerThread = false; videoRecvEvent.Set(); return; } if (isVideoReceived && isPlaying) { workerBusy = true; if (debugToggle) { Log.Debug("ViewModeSwitcher: Reset AR to original"); GUIGraphicsContext.ARType = Geometry.Type.Zoom14to9; updatePending = true; //force AR type update LastSwitchedAspectRatio = 0.0; LastDetectionResult = false; } else if (!updatePending) { if (LastSwitchedGeometry != GUIGraphicsContext.ARType) { //Geometry (zoom mode) has been changed by user //so disable black bar detection and //reset cropping to fallback settings Log.Debug("ViewModeSwitcher: Zoom mode changed by user"); enableLB = false; Crop((double)currentSettings.fboverScan); LastSwitchedGeometry = GUIGraphicsContext.ARType; updatePending = true; } CheckAspectRatios(); if ((loopCount % currentSettings.LBdetectInterval) == 0) { if (useAutoCrop) { LastDetectionResult = false; } if (!disableLBGlobally && !LastDetectionResult && enableLB) { if (currentSettings.verboseLog) { Log.Debug("ViewModeSwitcher: Black Bar detect"); } LastDetectionResult = true; SingleCrop(); } else { NoMatchCropCount = 0; } } } //debugToggle = !debugToggle; loopCount++; videoRecvEvent.Set(); workerEvent.WaitOne(247); // reset automatically - timeout after 247ms wait } else { workerBusy = false; LastSwitchedAspectRatio = 0.0; LastAnamorphFactor = 0.0; LastDetectionResult = true; isPBorLB = false; updatePending = false; forceAutoCrop = false; NoMatchCropCount = 0; loopCount = (currentSettings.LBdetectInterval - 1); //Perform a black-bar detect one loop cycle after start if (currentSettings.verboseLog) { Log.Debug("ViewModeSwitcher: Worker thread -> idle"); } videoRecvEvent.Set(); workerEvent.WaitOne(); // reset automatically - sleep until triggered } } }
/// <summary> /// This method handles the GUIGraphicsContext.OnVideoReceived() calls /// </summary> private void OnVideoReceived() { if (!isPlaying) { isVideoReceived = false; updatePending = false; return; } if (!isVideoReceived) { Log.Debug("ViewModeSwitcher: OnVideoReceived()"); updatePending = false; LastSwitchedGeometry = GUIGraphicsContext.ARType; isVideoReceived = true; workerEvent.Set(); } else if (!workerBusy) { workerEvent.Set(); } if (updatePending) { if (currentSettings.verboseLog) { Log.Debug("ViewModeSwitcher: OnVideoReceived(), Updating AR and crop"); } SetAspectRatio(NewGeometryMessage, LastSwitchedGeometry); SetCropMode(); updatePending = false; } }
private void OnAspectRatio() { GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_MENU); if (dlg == null) { return; } dlg.Reset(); dlg.SetHeading(941); // Change aspect ratio dlg.AddLocalizedString(943); // Normal dlg.AddLocalizedString(944); // Original dlg.AddLocalizedString(947); // Zoom dlg.AddLocalizedString(1190); // Zoom 14:9 dlg.AddLocalizedString(942); // Stretch dlg.AddLocalizedString(945); // Letterbox dlg.AddLocalizedString(946); // Non linear stretch // set the focus to currently used mode dlg.SelectedLabel = (int)_aspectRatio; // show dialog and wait for result dlg.DoModal(GetID); if (dlg.SelectedId == -1) { OnVideo(); return; } _aspectRatio = Utils.GetAspectRatioByLangID(dlg.SelectedId); OnVideo(); }
public override bool Play(string file) { if (String.IsNullOrEmpty(file)) return false; _currTime = new DvdHMSFTimeCode(); _UOPs = 0; _started = false; _visible = false; _positionX = 80; _positionY = 400; _width = 200; _height = 100; _videoWidth = 100; _videoHeight = 100; _speed = 1; _defaultAudioLanguage = null; _defaultSubtitleLanguage = null; _forceSubtitles = true; _aspectRatio = Geometry.Type.Normal; _speed = 1; _currentTime = 0; _visible = true; _started = false; _rotEntry = null; _volume = 100; _mouseMsg = new ArrayList(); VideoRendererStatistics.VideoState = VideoRendererStatistics.State.VideoPresent; if (!FirstPlayDvd(file)) { return false; } _fullScreen = true; _updateNeeded = true; GUIGraphicsContext.IsFullScreenVideo = true; /* GUIGraphicsContext.DX9Device.Clear( ClearFlags.Target, Color.Black, 1.0f, 0); try { // Show the frame on the primary surface. GUIGraphicsContext.DX9Device.Present(); } catch(DeviceLostException) { }*/ SetVideoWindow(); return true; }
/// <summary> /// load settings from configuration /// </summary> /// <returns></returns> public bool LoadSettings(string ImportFileName) { string tmpConfigFileName = Config.GetFile(Config.Dir.Config, "ViewModeSwitcher.xml"); if (ImportFileName != string.Empty) { tmpConfigFileName = ImportFileName; } using (Settings reader = new Settings(tmpConfigFileName)) { verboseLog = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmVerboselog, false); ShowSwitchMsg = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmShowSwitchMsg, false); UseFallbackRule = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmUseFallbackRule, true); String tmpFallbackViewMode = reader.GetValueAsString(ViewModeSwitcherSectionName, ParmFallbackViewMode, "Normal"); FallBackViewMode = StringToViewMode(tmpFallbackViewMode); DisableLBGlobaly = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmDisableLBGlobaly, false); LBBlackLevel = reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmBlackLevel, 40); fboverScan = reader.GetValueAsInt(ViewModeSwitcherSectionName, FallBackOverScan, 0); CropLeft = reader.GetValueAsInt("tv", "cropleft", 0); CropRight = reader.GetValueAsInt("tv", "cropright", 0); CropTop = reader.GetValueAsInt("tv", "croptop", 0); CropBottom = reader.GetValueAsInt("tv", "cropbottom", 0); bool tmpReturn = false; ViewModeRules.Clear(); int tmpRuleCount = reader.GetValueAsInt(ViewModeSwitcherSectionName, ParmRuleCount, 0); if (tmpRuleCount <= 0) { Rule tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "4:3"; tmpRule.ARFrom = 1.1f; tmpRule.ARTo = 1.334f; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 2000; tmpRule.ChangeAR = true; tmpRule.ViewMode = Geometry.Type.NonLinearStretch; tmpRule.ChangeOs = true; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = true; ViewModeRules.Add(tmpRule); tmpRule = new Rule(); tmpRule.Enabled = true; tmpRule.Name = "16:9"; tmpRule.ARFrom = 1.77f; tmpRule.ARTo = 1.78f; tmpRule.MinWidth = 200; tmpRule.MaxWidth = 2000; tmpRule.MinHeight = 200; tmpRule.MaxHeight = 2000; tmpRule.ChangeAR = true; tmpRule.ViewMode = Geometry.Type.Normal; tmpRule.ChangeOs = true; tmpRule.OverScan = 8; tmpRule.EnableLBDetection = true; ViewModeRules.Add(tmpRule); return true; } for (int i = 1; i <= tmpRuleCount; i++) { Rule tmpRule = new Rule(); tmpRule.Enabled = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Enabled", false); if (tmpRule.Enabled) { tmpReturn = true; } tmpRule.Name = reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Name", "noname"); tmpRule.ARFrom = (float) Convert.ToDouble(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ARFrom", "0")); tmpRule.ARTo = (float) Convert.ToDouble(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ARTo", "0")); tmpRule.MinWidth = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MinWidth", "0")); tmpRule.MaxWidth = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MaxWidth", "0")); tmpRule.MinHeight = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MinHeight", "0")); tmpRule.MaxHeight = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "MaxHeight", "0")); tmpRule.ChangeAR = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ChangeAR", true); String tmpViewMode = reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ViewMode", "Normal"); tmpRule.ViewMode = StringToViewMode(tmpViewMode); tmpRule.ChangeOs = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "ChangeOS", true); tmpRule.OverScan = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "Overscan", "0")); tmpRule.EnableLBDetection = reader.GetValueAsBool(ViewModeSwitcherSectionName, ParmRulePrefix + i + "EnableLBDetection", false); tmpRule.VerticalOffSetZoom = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "VerticalOffSetZoom", "0")); tmpRule.VerticalOffSet14_9 = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "VerticalOffSet14_9", "0")); tmpRule.VerticalOffSetWide14_9 = Convert.ToInt16(reader.GetValueAsString(ViewModeSwitcherSectionName, ParmRulePrefix + i + "VerticalOffSetWide14_9", "0")); ViewModeRules.Add(tmpRule); } return tmpReturn; } }
public override bool Play(string strFile) { _endOfFileDetected = false; Log.Info("TSReaderPlayer play:{0} radio:{1}", strFile, _isRadio); if (strFile.ToLowerInvariant().StartsWith("rtsp:") == false) { if (!File.Exists(strFile)) { return false; } } Speed = 1; iSpeed = 1; _speedRate = 10000; _isLive = false; _duration = -1d; if (strFile.ToLowerInvariant().IndexOf(".tsbuffer") >= 0) { Log.Info("TSReaderPlayer: live tv"); _isLive = true; } if (strFile.ToLowerInvariant().IndexOf("rtsp") >= 0) { Log.Info("TSReaderPlayer: live tv"); _isLive = true; } ExclusiveMode(true); VideoRendererStatistics.VideoState = VideoRendererStatistics.State.VideoPresent; _isVisible = false; _isWindowVisible = false; _volume = 100; _state = PlayState.Init; _currentFile = strFile; _isFullscreen = false; _geometry = Geometry.Type.Normal; _updateNeeded = true; Log.Info("TSReaderPlayer:play {0}", strFile); _isStarted = false; if (!GetInterfaces(strFile)) { Log.Error("TSReaderPlayer:GetInterfaces() failed"); _currentFile = ""; CloseInterfaces(); ExclusiveMode(false); return false; } int hr = _mediaEvt.SetNotifyWindow(GUIGraphicsContext.ActiveForm, WM_GRAPHNOTIFY, IntPtr.Zero); if (hr < 0) { Log.Error("TSReaderPlayer:SetNotifyWindow() failed"); _currentFile = ""; CloseInterfaces(); ExclusiveMode(false); return false; } if (_videoWin != null) { _videoWin.put_Owner(GUIGraphicsContext.ActiveForm); _videoWin.put_WindowStyle( (WindowStyle)((int)WindowStyle.Child + (int)WindowStyle.ClipSiblings + (int)WindowStyle.ClipChildren)); _videoWin.put_MessageDrain(GUIGraphicsContext.form.Handle); } if (_basicVideo != null) { hr = _basicVideo.GetVideoSize(out _videoWidth, out _videoHeight); if (hr < 0) { Log.Error("TSReaderPlayer:GetVideoSize() failed"); _currentFile = ""; CloseInterfaces(); ExclusiveMode(false); return false; } Log.Info("TSReaderPlayer:VideoSize:{0}x{1}", _videoWidth, _videoHeight); } GUIGraphicsContext.VideoSize = new Size(_videoWidth, _videoHeight); if (_mediaCtrl == null) { Log.Error("TSReaderPlayer:_mediaCtrl==null"); _currentFile = ""; CloseInterfaces(); ExclusiveMode(false); return false; } hr = _mediaCtrl.Run(); if (hr < 0) { Log.Error("TSReaderPlayer: Unable to start playing"); _currentFile = ""; CloseInterfaces(); ExclusiveMode(false); return false; } // _interfaceTSReader = _fileSource; _startingUp = _isLive; GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAYBACK_STARTED, 0, 0, 0, 0, 0, null); msg.Label = strFile; GUIWindowManager.SendThreadMessage(msg); _state = PlayState.Playing; _positionX = GUIGraphicsContext.VideoWindow.X; _positionY = GUIGraphicsContext.VideoWindow.Y; _width = GUIGraphicsContext.VideoWindow.Width; _height = GUIGraphicsContext.VideoWindow.Height; _geometry = GUIGraphicsContext.ARType; _updateNeeded = true; SetVideoWindow(); UpdateCurrentPosition(); UpdateDuration(); OnInitialized(); Log.Info("TSReaderPlayer: position:{0}, duration:{1}", CurrentPosition, Duration); return true; }
public override bool Play(string strFile) { Log.Info("BDPlayer play: {0}", strFile); if (!File.Exists(strFile)) { return false; } if (!GetInterfaces(strFile, g_Player.SetResumeBDTitleState)) { MovieEnded(); if (_titleToPlay == -1 || g_Player.SetResumeBDTitleState == -1) return true; Log.Error("BDPlayer:GetInterfaces() failed"); return false; } iSpeed = 1; _duration = -1d; ExclusiveMode(true); VideoRendererStatistics.VideoState = VideoRendererStatistics.State.VideoPresent; _isVisible = false; _volume = 100; _state = PlayState.Init; _currentFile = strFile; _isFullscreen = false; _geometry = Geometry.Type.Normal; int hr = _mediaEvt.SetNotifyWindow(GUIGraphicsContext.ActiveForm, WM_GRAPHNOTIFY, IntPtr.Zero); if (hr < 0) { Log.Error("BDPlayer:SetNotifyWindow() failed"); MovieEnded(); return false; } if (_videoWin != null) { _videoWin.put_Owner(GUIGraphicsContext.ActiveForm); _videoWin.put_WindowStyle( (WindowStyle)((int)WindowStyle.Child + (int)WindowStyle.ClipSiblings + (int)WindowStyle.ClipChildren)); _videoWin.put_MessageDrain(GUIGraphicsContext.form.Handle); } if (_basicVideo != null) { hr = _basicVideo.GetVideoSize(out _videoWidth, out _videoHeight); if (hr < 0) { Log.Error("BDPlayer:GetVideoSize() failed"); MovieEnded(); return false; } Log.Debug("BDPlayer:VideoSize:{0}x{1}", _videoWidth, _videoHeight); } GUIGraphicsContext.VideoSize = new Size(_videoWidth, _videoHeight); if (_mediaCtrl == null) { Log.Error("BDPlayer:_mediaCtrl==null"); MovieEnded(); return false; } hr = _mediaCtrl.Run(); if (hr < 0) { Log.Error("BDPlayer: Unable to start playing"); MovieEnded(); return false; } _state = PlayState.Playing; GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAYBACK_STARTED, 0, 0, 0, 0, 0, null); msg.Label = strFile; GUIWindowManager.SendThreadMessage(msg); _positionX = GUIGraphicsContext.VideoWindow.X; _positionY = GUIGraphicsContext.VideoWindow.Y; _width = GUIGraphicsContext.VideoWindow.Width; _height = GUIGraphicsContext.VideoWindow.Height; _geometry = GUIGraphicsContext.ARType; OnInitialized(); Log.Debug("BDPlayer: position:{0}, duration:{1}", CurrentPosition, Duration); UpdateMenuItems(); return true; }
/// <summary> /// Sets up a change to aspect ratio of MediaPortal (actually happens later) /// </summary> /// <param name="MessageString">Message text of the switch message</param> /// <param name="AR">the aspect ratio to switch to</param> private bool SetNewGeometry(string MessageString, Geometry.Type AR) { if (LastSwitchedGeometry == AR) { return false; } LastSwitchedGeometry = AR; NewGeometryMessage = MessageString; return true; }
public override bool Play(string strFile) { updateTimer = DateTime.Now; m_speedRate = 10000; GUIGraphicsContext.IsWindowVisible = false; m_iVolume = 100; _state = PlayState.Init; m_strCurrentFile = strFile; m_bFullScreen = true; m_ar = GUIGraphicsContext.ARType; VideoRendererStatistics.VideoState = VideoRendererStatistics.State.VideoPresent; _updateNeeded = true; Log.Info("RTSPPlayer:play {0}", strFile); //lock ( typeof(VideoPlayerVMR7) ) { CloseInterfaces(); m_bStarted = false; if (!GetInterfaces()) { m_strCurrentFile = ""; CloseInterfaces(); return(false); } int hr = mediaEvt.SetNotifyWindow(GUIGraphicsContext.ActiveForm, WM_GRAPHNOTIFY, IntPtr.Zero); if (hr < 0) { Error.SetError("Unable to play movie", "Can not set notifications"); m_strCurrentFile = ""; CloseInterfaces(); return(false); } DirectShowUtil.SetARMode(graphBuilder, AspectRatioMode.Stretched); _rotEntry = new DsROTEntry((IFilterGraph)graphBuilder); // DsUtils.DumpFilters(graphBuilder); hr = _mediaCtrl.Run(); if (hr < 0) { Error.SetError("Unable to play movie", "Unable to start movie"); m_strCurrentFile = ""; CloseInterfaces(); return(false); } GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_PLAYBACK_STARTED, 0, 0, 0, 0, 0, null); msg.Label = strFile; GUIWindowManager.SendThreadMessage(msg); _state = PlayState.Playing; //Brutus GUIGraphicsContext.IsFullScreenVideo=true; m_iPositionX = GUIGraphicsContext.VideoWindow.X; m_iPositionY = GUIGraphicsContext.VideoWindow.Y; m_iWidth = GUIGraphicsContext.VideoWindow.Width; m_iHeight = GUIGraphicsContext.VideoWindow.Height; m_ar = GUIGraphicsContext.ARType; _updateNeeded = true; SetVideoWindow(); mediaPos.get_Duration(out _duration); Log.Info("RTSPPlayer:Duration:{0}", _duration); if (_mediaType == g_Player.MediaType.TV) { //if (_duration < 1) _duration = 1; //SeekAbsolute(_duration - 1); } else { //SeekAbsolute(0); } OnInitialized(); } // Wait for a while to wait VMR9 to get ready. // Implemented due to problems starting to play before VMR9 was ready resulting in black screen. Thread.Sleep(200); return(true); }
/// <summary> /// Constructor which initialises the video handler /// </summary> /// <param name="player">Instance of external player</param> /// <param name="osdHandler">Instance of the osdHandler</param> public VideoHandler(MPlayerExtPlayer player, IOSDHandler osdHandler) { _player = player; _osdHandler = osdHandler; _aspectRatio = "1.0"; _videoHeight = -1; _videoWidth = 0; _ar = GUIGraphicsContext.ARType; _mplayerBackgroundPanel = new Panel { ForeColor = Color.Black, BackColor = Color.Black, Size = new Size(0, 0), Location = new Point(0, 0) }; _mplayerOuterPanel = new Panel { ForeColor = Color.Black, BackColor = Color.Black, Size = new Size(0, 0), Location = new Point(0, 0) }; _mplayerInnerPanel = new Panel { Size = new Size(0, 0), ForeColor = Color.FromArgb(16, 16, 16), BackColor = Color.FromArgb(16, 16, 16) }; _mplayerOuterPanel.Controls.Add(_mplayerInnerPanel); _mplayerInnerPanel.Location = new Point(0, 0); }