Esempio n. 1
0
 /// <inheritdoc />
 protected override void OnDeactivate()
 {
     MediaPlayer.MediaOpened            -= MediaPlayer_MediaOpened;
     MediaPlayer.PositionChanged        -= MediaPlayer_PositionChanged;
     MediaPlayer.SelectedCaptionChanged -= MediaPlayer_SelectedCaptionChanged;
     MediaPlayer.IsLiveChanged          -= MediaPlayer_IsLiveChanged;
     MediaPlayer.IsCaptionsActive        = false;
     captionsContainer.Children.Remove(captionsPanel);
     captionsContainer = null;
     captionsPanel.Clear();
     captionsPanel.CaptionParsed -= captionsPanel_CaptionParsed;
     captionsPanel.ParseFailed   -= captionsPanel_ParseFailed;
     captionsPanel  = null;
     IsSourceLoaded = false;
 }
Esempio n. 2
0
        /// <inheritdoc />
        protected override bool OnActivate()
        {
            var mediaContainer = MediaPlayer.Containers.OfType <Panel>().FirstOrDefault(c => c.Name == MediaPlayerTemplateParts.MediaContainer);

            captionsContainer = mediaContainer.Children.OfType <Panel>().FirstOrDefault(c => c.Name == MediaPlayerTemplateParts.CaptionsContainer);
            if (captionsContainer != null)
            {
                //PoC: to use a custom marker manager
                //captionsPanel = new TimedTextCaptions(new MarkerManager<CaptionRegion>(MediaPlayer), m => new MarkerManager<TimedTextElement>(MediaPlayer) { Markers = m });
                captionsPanel = new TimedTextCaptions();
                captionsPanel.CaptionParsed   += captionsPanel_CaptionParsed;
                captionsPanel.ParseFailed     += captionsPanel_ParseFailed;
                captionsPanel.NaturalVideoSize = new Size(MediaPlayer.NaturalVideoWidth, MediaPlayer.NaturalVideoHeight);
                if (TimedTextCaptionsStyle != null)
                {
                    captionsPanel.Style = TimedTextCaptionsStyle;
                }
                if (CaptionRegionStyle != null)
                {
                    captionsPanel.CaptionBlockRegionStyle = CaptionRegionStyle;
                }

                MediaPlayer.IsCaptionsActive = (MediaPlayer.SelectedCaption as Caption != null);
                captionsContainer.Children.Add(captionsPanel);
                UpdateCaption(MediaPlayer.SelectedCaption as Caption);

                MediaPlayer.MediaOpened            += MediaPlayer_MediaOpened;
                MediaPlayer.PositionChanged        += MediaPlayer_PositionChanged;
                MediaPlayer.SelectedCaptionChanged += MediaPlayer_SelectedCaptionChanged;
                MediaPlayer.IsLiveChanged          += MediaPlayer_IsLiveChanged;
                if (MediaPlayer.IsLive)
                {
                    InitializeTimer();
                }

                return(true);
            }
            return(false);
        }