/// <inheritdoc /> 
 protected override void OnDeactivate()
 {
     MediaPlayer.PositionChanged -= MediaPlayer_PositionChanged;
     MediaPlayer.SelectedCaptionChanged -= MediaPlayer_SelectedCaptionChanged;
     MediaPlayer.IsLiveChanged -= MediaPlayer_IsLiveChanged;
     MediaPlayer.IsCaptionsActive = false;
     captionsContainer.Children.Remove(captionsPanel);
     captionsContainer = null;
     captionsPanel.Clear();
     captionsPanel = null;
     markerManager.MarkerLeft -= MarkerManager_MarkerLeft;
     markerManager.MarkerReached -= MarkerManager_MarkerReached;
     markerManager.Clear();
     markerManager = null;
     IsSourceLoaded = false;
 }
        /// <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)
            {
                markerManager = new MediaMarkerManager();
                markerManager.MarkerLeft += MarkerManager_MarkerLeft;
                markerManager.MarkerReached += MarkerManager_MarkerReached;
                captionsPanel = new WebVTTPanel();
                if (CaptionsPanelStyle != null) captionsPanel.Style = CaptionsPanelStyle;
                MediaPlayer.IsCaptionsActive = (MediaPlayer.SelectedCaption as Caption != null);
                captionsContainer.Children.Add(captionsPanel);
                UpdateCaption(MediaPlayer.SelectedCaption as Caption);

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

                return true;
            }
            return false;
        }