Esempio n. 1
0
        private void SyncToPlayer(IVideoPlayer player)
        {
            if (_refreshRateChanger != null)
            {
                _refreshRateChanger.Dispose();
                _refreshRateChanger = null;
            }
            MediaItem mediaItem = GetCurrentMediaItem(player);

            if (mediaItem == null)
            {
                return;
            }

            int intFps;

            if (MediaItemAspect.TryGetAttribute(mediaItem.Aspects, VideoAspect.ATTR_FPS, out intFps))
            {
                ICollection <int> excludeRates = TryParseIntList(_settings.Settings.NoChangeForRate);
                if (excludeRates.Contains(intFps))
                {
                    ServiceRegistration.Get <ILogger>().Debug("RefreshRateChanger: Video fps: {0}; No change due to settings.", intFps);
                    return;
                }
                _refreshRateChanger = new TemporaryRefreshRateChanger(GetScreenNum());
                double fps = intFps;
                if (intFps == 23)
                {
                    fps = 23.976;
                }
                if (intFps == 29)
                {
                    fps = 29.970;
                }
                if (intFps == 59)
                {
                    fps = 59.940;
                }

                var currentRefreshRate = _refreshRateChanger.GetRefreshRate();
                if (!IsMultipleOf(currentRefreshRate, fps))
                {
                    ServiceRegistration.Get <ILogger>().Debug("RefreshRateChanger: Video fps: {0}; Screen refresh rate {1}, trying to change it.", fps, currentRefreshRate);
                    _refreshRateChanger.SetRefreshRate(fps);
                }
                else
                {
                    ServiceRegistration.Get <ILogger>().Debug("RefreshRateChanger: Video fps: {0}; Screen refresh rate {1}, no change required.", fps, currentRefreshRate);
                }
            }
        }
        private void SyncToPlayer(IVideoPlayer player)
        {
            if (_refreshRateChanger != null)
            {
                _refreshRateChanger.Dispose();
                _refreshRateChanger = null;
            }
            MediaItem mediaItem = GetCurrentMediaItem(player);

            if (mediaItem == null)
            {
                return;
            }

            IList <MultipleMediaItemAspect> videoAspects;

            if (!MediaItemAspect.TryGetAspects(mediaItem.Aspects, VideoStreamAspect.Metadata, out videoAspects))
            {
                return;
            }

            int intFps = Convert.ToInt32(videoAspects[0].GetAttributeValue <float>(VideoStreamAspect.ATTR_FPS));

            if (intFps > 0)
            {
                int mappedIntFps;
                if (!_settings.Settings.RateMappings.TryGetValue(intFps, out mappedIntFps) || mappedIntFps <= 0)
                {
                    ServiceRegistration.Get <ILogger>().Debug("RefreshRateChanger: Video fps: {0}; No mapping for this rate found.", intFps);
                    return;
                }

                _refreshRateChanger = new TemporaryRefreshRateChanger(GetScreenNum(), true);
                var fps = TranslateFps(mappedIntFps);

                var currentRefreshRate = _refreshRateChanger.GetRefreshRate();
                if (currentRefreshRate != fps)
                {
                    ServiceRegistration.Get <ILogger>().Info("RefreshRateChanger: Video fps: {0}; Screen refresh rate {1}, trying to change it.", fps, currentRefreshRate);
                    _refreshRateChanger.SetRefreshRate(fps);
                }
                else
                {
                    ServiceRegistration.Get <ILogger>().Debug("RefreshRateChanger: Video fps: {0}; Screen refresh rate {1}, no change required.", fps, currentRefreshRate);
                }
            }
        }