Ejemplo n.º 1
0
        protected override void AddSubtitleFilter(bool isSourceFilterPresent)
        {
            VideoSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <VideoSettings>() ?? new VideoSettings();
            int           preferredSubtitleLcid      = settings.PreferredSubtitleLanguage;
            var           fileSystemResourceAccessor = _resourceAccessor as IFileSystemResourceAccessor;

            if (fileSystemResourceAccessor != null)
            {
                ServiceRegistration.Get <ILogger>().Debug("{0}: Adding MPC-HC subtitle engine", PlayerTitle);
                SubtitleStyle defStyle = new SubtitleStyle();
                defStyle.Load();
                MpcSubtitles.SetDefaultStyle(ref defStyle, false);

                IntPtr upDevice = SkinContext.Device.NativePointer;
                string filename = fileSystemResourceAccessor.ResourcePathName;

                MpcSubtitles.LoadSubtitles(upDevice, _displaySize, filename, _graphBuilder, @".\", preferredSubtitleLcid);
                if (settings.EnableSubtitles)
                {
                    MpcSubtitles.SetEnable(true);
                }
            }

            AddClosedCaptionsFilter();
        }
Ejemplo n.º 2
0
        public bool LoadSubtitles(IGraphBuilder graphBuilder, string filename)
        {
            LoadSettings();
            MpcSubtitles.SetDefaultStyle(ref this.defStyle, this.overrideASSStyle);
            if (selectionOff)
            {
                MpcSubtitles.SetShowForcedOnly(false);
            }
            else
            {
                MpcSubtitles.SetShowForcedOnly(!this.autoShow);
            }
            //remove DirectVobSub
            DirectVobSubUtil.RemoveFromGraph(graphBuilder);
            {
                //remove InternalScriptRenderer as it takes subtitle pin
                IBaseFilter isr = null;
                DirectShowUtil.FindFilterByClassID(graphBuilder, ClassId.InternalScriptRenderer, out isr);
                if (isr != null)
                {
                    graphBuilder.RemoveFilter(isr);
                    DirectShowUtil.ReleaseComObject(isr);
                }
            }

            FFDShowEngine.DisableFFDShowSubtitles(graphBuilder);

            Size size = new Size(GUIGraphicsContext.Width, GUIGraphicsContext.Height);

            return(MpcSubtitles.LoadSubtitles(
                       DirectShowUtil.GetUnmanagedDevice(GUIGraphicsContext.DX9Device),
                       size, filename, graphBuilder, subPaths));
        }
Ejemplo n.º 3
0
 public void SetDevice(IntPtr device)
 {
     if (GUIGraphicsContext.VideoRenderer == GUIGraphicsContext.VideoRendererType.madVR)
     {
         // Need to init there to have the setting for madVR.
         LoadSettings();
         MpcSubtitles.SetDefaultStyle(ref this.defStyle, this.overrideASSStyle);
         if (selectionOff)
         {
             MpcSubtitles.SetShowForcedOnly(false);
         }
         else
         {
             MpcSubtitles.SetShowForcedOnly(!this.autoShow);
         }
     }
     MpcSubtitles.SetDevice(device);
 }
Ejemplo n.º 4
0
        protected override void AddSubtitleFilter(bool isSourceFilterPresent)
        {
            VideoSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <VideoSettings>() ?? new VideoSettings();
            int           preferredSubtitleLcid = settings.PreferredSubtitleLanguage;

            ServiceRegistration.Get <ILogger>().Debug("{0}: Adding MPC-HC subtitle engine", PlayerTitle);
            SubtitleStyle defStyle = new SubtitleStyle();

            defStyle.Load();
            MpcSubtitles.SetDefaultStyle(ref defStyle, false);

            IntPtr upDevice = SkinContext.Device.NativePointer;
            string filename = string.Empty;

            string paths;

            if (GetSubtitlePath(out paths, out filename))
            {
                MpcSubtitles.LoadSubtitles(upDevice, _displaySize, filename, _graphBuilder, paths, preferredSubtitleLcid);
                MpcSubtitles.SetEnable(settings.EnableMpcSubtitlesEngine);
            }
        }
Ejemplo n.º 5
0
        public bool LoadSubtitles(IGraphBuilder graphBuilder, string filename)
        {
            LoadSettings();
            MpcSubtitles.SetDefaultStyle(ref this.defStyle, this.overrideASSStyle);
            if (selectionOff)
            {
                MpcSubtitles.SetShowForcedOnly(false);
            }
            else
            {
                MpcSubtitles.SetShowForcedOnly(!this.autoShow);
            }
            //remove DirectVobSub
            DirectVobSubUtil.RemoveFromGraph(graphBuilder);
            {
                //remove InternalScriptRenderer as it takes subtitle pin
                IBaseFilter isr = null;
                DirectShowUtil.FindFilterByClassID(graphBuilder, ClassId.InternalScriptRenderer, out isr);
                if (isr != null)
                {
                    graphBuilder.RemoveFilter(isr);
                    DirectShowUtil.ReleaseComObject(isr);
                }
            }

            FFDShowEngine.DisableFFDShowSubtitles(graphBuilder);

            Size size = new Size(GUIGraphicsContext.Width, GUIGraphicsContext.Height);

            // Get Default Language from MP Setting and parse it to MPC-HC Engine (needed for forced track)
            string defaultLanguageCulture = "EN";
            string localizedCINameSub     = "EN";
            int    lcidCI = 0;

            using (Settings xmlreader = new MPSettings())
            {
                try
                {
                    if (g_Player.IsVideo && (g_Player.CurrentFile.ToUpperInvariant().Contains(@"\BDMV\INDEX.BDMV")))
                    {
                        localizedCINameSub = (xmlreader.GetValueAsString("bdplayer", "subtitlelanguage", "English"));
                        foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.NeutralCultures))
                        {
                            if (ci.EnglishName == localizedCINameSub)
                            {
                                lcidCI = ci.TextInfo.LCID;;
                            }
                        }
                        Log.Info("MpcEngine: Subtitle Blu-ray Player CultureInfo {0}", localizedCINameSub);
                    }
                    else
                    {
                        CultureInfo ci = new CultureInfo(xmlreader.GetValueAsString("subtitles", "language", defaultLanguageCulture));
                        lcidCI = ci.TextInfo.LCID;
                        Log.Info("MpcEngine: Subtitle VideoPlayer CultureInfo {0}", ci);
                    }
                }
                catch (Exception ex)
                {
                    CultureInfo ci = new CultureInfo(defaultLanguageCulture);
                    lcidCI = ci.TextInfo.LCID;
                    Log.Error(
                        "MpcEngine: SelectSubtitleLanguage - unable to build CultureInfo, make sure MediaPortal.xml is not corrupted! - {0}",
                        ex);
                }
            }

            return(MpcSubtitles.LoadSubtitles(
                       DirectShowUtil.GetUnmanagedDevice(GUIGraphicsContext.DX9Device),
                       size, filename, graphBuilder, subPaths, lcidCI));
        }