コード例 #1
0
 void AdaptRefreshRate()
 {
     if (PluginConfiguration.Instance.AllowRefreshRateChange)
     {
         try
         {
             double fps = wmpCtrl.network.encodedFrameRate != 0 ? wmpCtrl.network.encodedFrameRate : (double)wmpCtrl.network.frameRate / 100.0f; //frames per hundred seconds
             if (fps > 1)
             {
                 Log.Instance.Info("WMPVideoPlayer got {0} FPS from WMP", fps);
                 double matchedFps = RefreshRateHelper.MatchConfiguredFPS(fps);
                 if (matchedFps != default(double))
                 {
                     RefreshRateHelper.ChangeRefreshRateToMatchedFps(matchedFps, currentFile);
                 }
                 else
                 {
                     Log.Instance.Info("No matching configured FPS found - skipping RefreshRate Adaption");
                 }
             }
         }
         catch (Exception ex)
         {
             Log.Instance.Warn("WMPVideoPlayer: Exception trying refresh rate change: {0}", ex.ToString());
         }
     }
 }
コード例 #2
0
        void AdaptRefreshRateFromVideoRenderer()
        {
            if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.EVR)
            {
                if (!refreshRateAdapted && m_state == PlayState.Playing)
                {
                    try
                    {
                        if (!PluginConfiguration.Instance.AllowRefreshRateChange)
                        {
                            refreshRateAdapted = true;
                            return;
                        }

                        double fps = EVRGetVideoFPS(0);
                        if (fps > 1)
                        {
                            refreshRateAdapted = true;
                            Log.Instance.Info("OnlineVideosPlayer got {0} FPS from dshowhelper.dll after {1} sec", fps, CurrentPosition);
                            double matchedFps = RefreshRateHelper.MatchConfiguredFPS(fps);
                            if (matchedFps != default(double))
                            {
                                RefreshRateHelper.ChangeRefreshRateToMatchedFps(matchedFps, m_strCurrentFile);
                                EVRUpdateDisplayFPS();
                            }
                            else
                            {
                                Log.Instance.Info("No matching configured FPS found - skipping RefreshRate Adaption");
                            }
                        }
                    }
                    catch (EntryPointNotFoundException)
                    {
                        Log.Instance.Warn("OnlineVideosPlayer: Your version of dshowhelper.dll does not support FPS reporting.");
                        refreshRateAdapted = true;
                    }
                    catch (Exception ex)
                    {
                        Log.Instance.Warn("OnlineVideosPlayer: Exception trying refresh rate change while playing : {0}", ex.ToString());
                        refreshRateAdapted = true;
                    }
                }
            }
        }
コード例 #3
0
        void AdaptRefreshRateFromCacheFile()
        {
            if (!PluginConfiguration.Instance.AllowRefreshRateChange)
            {
                refreshRateAdapted = true;
                return;
            }

            if (!string.IsNullOrEmpty(cacheFile))
            {
                try
                {
                    MediaInfo mi = new MediaInfo();
                    int       hr = mi.Open(cacheFile);
                    double    framerate;
                    double.TryParse(mi.Get(StreamKind.Video, 0, "FrameRate"), System.Globalization.NumberStyles.AllowDecimalPoint, new System.Globalization.NumberFormatInfo()
                    {
                        NumberDecimalSeparator = "."
                    }, out framerate);
                    if (framerate > 1)
                    {
                        Log.Instance.Info("OnlineVideosPlayer got {0} FPS from MediaInfo", framerate);
                        double matchedFps = RefreshRateHelper.MatchConfiguredFPS(framerate);
                        if (matchedFps != default(double))
                        {
                            refreshRateAdapted = true;
                            RefreshRateHelper.ChangeRefreshRateToMatchedFps(matchedFps, cacheFile);
                            try
                            {
                                if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.EVR)
                                {
                                    EVRUpdateDisplayFPS();
                                }
                            }
                            catch (EntryPointNotFoundException)
                            {
                                Log.Instance.Warn("OnlineVideosPlayer: Your version of dshowhelper.dll does not support FPS updating.");
                            }
                            catch (Exception ex)
                            {
                                Log.Instance.Warn("OnlineVideosPlayer: Exception trying update refresh rate fo EVR: {0}", ex.ToString());
                            }
                        }
                        else
                        {
                            Log.Instance.Info("No matching configured FPS found - skipping RefreshRate Adaption from Cache File");
                        }
                    }
                    else
                    {
                        Log.Instance.Info("OnlineVideosPlayer got no FPS from MediaInfo");
                    }
                }
                catch (Exception ex)
                {
                    Log.Instance.Warn("OnlineVideosPlayer: Exception trying refresh rate change from cache file: {0}", ex.ToString());
                }
            }
            else
            {
                Log.Instance.Info("OnlineVideosPlayer: No cache file, skipping FPS detection via MediaInfo");
            }
        }