Exemplo n.º 1
0
        public static int ShowSubtitle(List<Paragraph> paragraphs, Subtitle original, VideoPlayerContainer videoPlayerContainer)
        {
            if (videoPlayerContainer.VideoPlayer != null)
            {
                double positionInMilliseconds = (videoPlayerContainer.VideoPlayer.CurrentPosition * TimeCode.BaseUnit) + 15;
                for (int i = 0; i < paragraphs.Count; i++)
                {
                    var p = paragraphs[i];
                    if (p.StartTime.TotalMilliseconds <= positionInMilliseconds && p.EndTime.TotalMilliseconds > positionInMilliseconds)
                    {
                        var op = GetOriginalParagraph(0, p, original.Paragraphs);

                        string text = p.Text.Replace("|", Environment.NewLine);
                        if (op != null)
                        {
                            text = text + Environment.NewLine + Environment.NewLine + op.Text.Replace("|", Environment.NewLine);
                        }

                        bool isInfo = p == paragraphs[0] && p.StartTime.TotalMilliseconds == 0 && positionInMilliseconds > 3000;
                        if (!isInfo)
                        {
                            if (videoPlayerContainer.LastParagraph != p)
                            {
                                videoPlayerContainer.SetSubtitleText(text, p);
                            }
                            else if (videoPlayerContainer.SubtitleText != text)
                            {
                                videoPlayerContainer.SetSubtitleText(text, p);
                            }

                            return i;
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(videoPlayerContainer.SubtitleText))
            {
                videoPlayerContainer.SetSubtitleText(string.Empty, null);
            }

            return -1;
        }
Exemplo n.º 2
0
 public static void InitializeVideoPlayerAndContainer(string fileName, VideoInfo videoInfo, VideoPlayerContainer videoPlayerContainer, EventHandler onVideoLoaded, EventHandler onVideoEnded)
 {
     try
     {
         videoPlayerContainer.VideoPlayer = GetVideoPlayer();
         videoPlayerContainer.VideoPlayer.Initialize(videoPlayerContainer.PanelPlayer, fileName, onVideoLoaded, onVideoEnded);
         videoPlayerContainer.ShowStopButton = Configuration.Settings.General.VideoPlayerShowStopButton;
         videoPlayerContainer.ShowFullscreenButton = false;
         videoPlayerContainer.ShowMuteButton = Configuration.Settings.General.VideoPlayerShowMuteButton;
         videoPlayerContainer.Volume = Configuration.Settings.General.VideoPlayerDefaultVolume;
         videoPlayerContainer.EnableMouseWheelStep();
         videoPlayerContainer.VideoWidth = videoInfo.Width;
         videoPlayerContainer.VideoHeight = videoInfo.Height;
         videoPlayerContainer.VideoPlayer.Resize(videoPlayerContainer.PanelPlayer.Width, videoPlayerContainer.PanelPlayer.Height);
     }
     catch (Exception exception)
     {
         videoPlayerContainer.VideoPlayer = null;
         var videoError = new VideoError();
         videoError.Initialize(fileName, videoInfo, exception);
         videoError.ShowDialog();
     }
 }
Exemplo n.º 3
0
        public static int GetSubtitleIndex(List<Paragraph> paragraphs, VideoPlayerContainer videoPlayerContainer)
        {
            if (videoPlayerContainer.VideoPlayer != null)
            {
                double positionInMilliseconds = (videoPlayerContainer.VideoPlayer.CurrentPosition * TimeCode.BaseUnit) + 5;
                for (int i = 0; i < paragraphs.Count; i++)
                {
                    var p = paragraphs[i];
                    if (p.StartTime.TotalMilliseconds <= positionInMilliseconds &&
                        p.EndTime.TotalMilliseconds > positionInMilliseconds)
                    {
                        bool isInfo = p == paragraphs[0] &&
                            (p.StartTime.TotalMilliseconds == 0 &&
                            p.Duration.TotalMilliseconds == 0 ||
                            p.StartTime.TotalMilliseconds == Pac.PacNullTime.TotalMilliseconds);
                        if (!isInfo)
                        {
                            return i;
                        }
                    }
                }

                if (!string.IsNullOrEmpty(videoPlayerContainer.SubtitleText))
                {
                    videoPlayerContainer.SetSubtitleText(string.Empty, null);
                }
            }

            return -1;
        }
Exemplo n.º 4
0
        public static int ShowSubtitle(List <Paragraph> paragraphs, Subtitle original, VideoPlayerContainer videoPlayerContainer)
        {
            if (videoPlayerContainer.VideoPlayer != null)
            {
                double positionInMilliseconds = (videoPlayerContainer.VideoPlayer.CurrentPosition * TimeCode.BaseUnit) + 15;
                for (int i = 0; i < paragraphs.Count; i++)
                {
                    var p = paragraphs[i];
                    if (p.StartTime.TotalMilliseconds <= positionInMilliseconds &&
                        p.EndTime.TotalMilliseconds > positionInMilliseconds)
                    {
                        var op = Utilities.GetOriginalParagraph(0, p, original.Paragraphs);

                        string text = p.Text.Replace("|", Environment.NewLine);
                        if (op != null)
                        {
                            text = text + Environment.NewLine + Environment.NewLine + op.Text.Replace("|", Environment.NewLine);
                        }

                        bool isInfo = p == paragraphs[0] && p.StartTime.TotalMilliseconds == 0 && positionInMilliseconds > 3000;
                        if (!isInfo)
                        {
                            if (videoPlayerContainer.LastParagraph != p)
                            {
                                videoPlayerContainer.SetSubtitleText(text, p);
                            }
                            else if (videoPlayerContainer.SubtitleText != text)
                            {
                                videoPlayerContainer.SetSubtitleText(text, p);
                            }
                            return(i);
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(videoPlayerContainer.SubtitleText))
            {
                videoPlayerContainer.SetSubtitleText(string.Empty, null);
            }
            return(-1);
        }
Exemplo n.º 5
0
        public static bool InitializeVideoPlayerAndContainer(string fileName, VideoInfo videoInfo, VideoPlayerContainer videoPlayerContainer, EventHandler onVideoLoaded, EventHandler onVideoEnded)
        {
            try
            {
                videoPlayerContainer.VideoPlayer = GetVideoPlayer();
                videoPlayerContainer.VideoPlayer.Initialize(videoPlayerContainer.PanelPlayer, fileName, onVideoLoaded, onVideoEnded);
                videoPlayerContainer.ShowStopButton       = Configuration.Settings.General.VideoPlayerShowStopButton;
                videoPlayerContainer.ShowFullscreenButton = false;
                videoPlayerContainer.ShowMuteButton       = Configuration.Settings.General.VideoPlayerShowMuteButton;
                videoPlayerContainer.Volume = Configuration.Settings.General.VideoPlayerDefaultVolume;
                videoPlayerContainer.EnableMouseWheelStep();
                if (fileName != null && (fileName.StartsWith("https://", StringComparison.OrdinalIgnoreCase) || fileName.StartsWith("http://", StringComparison.OrdinalIgnoreCase)))
                {
                    // we don't have videoInfo for streams...
                }
                else
                {
                    videoPlayerContainer.VideoWidth  = videoInfo.Width;
                    videoPlayerContainer.VideoHeight = videoInfo.Height;
                    videoPlayerContainer.VideoPlayer.Resize(videoPlayerContainer.PanelPlayer.Width, videoPlayerContainer.PanelPlayer.Height);
                }

                return(true);
            }
            catch (Exception exception)
            {
                videoPlayerContainer.VideoPlayer = null;
                var videoError = new VideoError();
                videoError.Initialize(fileName, exception);
                videoError.ShowDialog();
                SeLogger.Error(exception, "InitializeVideoPlayerAndContainer failed to load video player");
                return(false);
            }
        }
Exemplo n.º 6
0
 public static void InitializeVideoPlayerAndContainer(string fileName, VideoInfo videoInfo, VideoPlayerContainer videoPlayerContainer, EventHandler onVideoLoaded, EventHandler onVideoEnded)
 {
     try
     {
         videoPlayerContainer.VideoPlayer = GetVideoPlayer();
         videoPlayerContainer.VideoPlayer.Initialize(videoPlayerContainer.PanelPlayer, fileName, onVideoLoaded, onVideoEnded);
         videoPlayerContainer.ShowStopButton       = Configuration.Settings.General.VideoPlayerShowStopButton;
         videoPlayerContainer.ShowFullscreenButton = false;
         videoPlayerContainer.ShowMuteButton       = Configuration.Settings.General.VideoPlayerShowMuteButton;
         videoPlayerContainer.Volume = Configuration.Settings.General.VideoPlayerDefaultVolume;
         videoPlayerContainer.EnableMouseWheelStep();
         videoPlayerContainer.VideoWidth  = videoInfo.Width;
         videoPlayerContainer.VideoHeight = videoInfo.Height;
         videoPlayerContainer.VideoPlayer.Resize(videoPlayerContainer.PanelPlayer.Width, videoPlayerContainer.PanelPlayer.Height);
     }
     catch (Exception exception)
     {
         videoPlayerContainer.VideoPlayer = null;
         var videoError = new VideoError();
         videoError.Initialize(fileName, videoInfo, exception);
         videoError.ShowDialog();
     }
 }