/// <summary>
        /// Unregisters the specified media plugin so that it is no longer managed by this heuristics plugin.
        /// </summary>
        /// <param name="mediaPlugin">The media plugin to unregister.</param>
        public void UnregisterPlugin(IMediaPlugin mediaPlugin)
        {
            var ssme = mediaPlugin.VisualElement as SmoothStreamingMediaElement;

            if (IsLoaded && ssme != null)
            {
                if (ssme == _syncManager.HeuristicMasterMedia)
                {
                    _syncManager.HeuristicManager.StopMonitoring();
                    _syncManager.HeuristicMasterMedia = null;
                }

                if (ssme == _syncManager.MainMedia)
                {
                    _syncManager.MainMedia = null;
                }

                SlaveMediaElement subMediaElement =
                    _syncManager.SubMediaElements.Where(i => i.MediaElement == ssme).FirstOrDefault();

                if (subMediaElement != null)
                {
                    _syncManager.SubMediaElements.Remove(subMediaElement);
                    _syncManager.ResetHeuristics();
                }
            }
        }
        private void MediaPlugin_MediaOpened(IMediaPlugin mediaPlugin)
        {
            // restore state of player
            var livePlugin = _mediaPlugin as ILiveDvrMediaPlugin;

            if (livePlugin != null && livePlugin.IsSourceLive && LastPosition == TimeSpan.Zero)
            {
                // go to live if a live feed and don't have a last position,
                // most likely this is the result of the first load attempt
                livePlugin.Position = livePlugin.LivePosition;
                //livePlugin.SeekToLive();
            }
            else
            {
                // restore position
                _mediaPlugin.Position = LastPosition;
            }

            //Per IIS CP team, we set auto play = true so that the video will start playing when it
            //recovers from the retry.  Now that it has recovered, we will set it back to false.
            _mediaPlugin.AutoPlay = false;

            if (!_successTimer.IsEnabled)
            {
                _successTimer.Start();
            }
        }
        /// <summary>
        /// Handles the CurrentStateChanged event of the media element.
        /// </summary>
        private void MediaPluginCurrentStateChanged(IMediaPlugin plugin, MediaPluginState mediaPluginState)
        {
            if (this.mediaPlugin.CurrentState == MediaPluginState.Stopped || this.mediaPlugin.CurrentState == MediaPluginState.Paused || this.mediaPlugin.CurrentState == MediaPluginState.Closed)
            {
                this.Playing = false;
            }

            lock (this.lastSeekPositionLock)
            {
                if (mediaPluginState != MediaPluginState.Buffering && this.lastSeekPosition.HasValue)
                {
                    plugin.Position       = this.lastSeekPosition.Value;
                    this.lastSeekPosition = null;
                }
            }

            if (this.mediaPlugin.CurrentState == MediaPluginState.Buffering)
            {
                this.isBufferStarted = true;
                this.OnBufferStart();
            }
            else if (this.isBufferStarted)
            {
                this.OnBufferEnd();
                this.isBufferStarted = false;
            }
        }
 /// <summary>
 /// Handles the MediaOpened event of the MediaElement control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
 private void MediaElement_MediaOpened(IMediaPlugin mediaPlugin)
 {
     this.StartPositionTimer();
     this.mediaPlugin.IsMuted = this.MuteButton.IsChecked.HasValue ? this.MuteButton.IsChecked.Value : false;
     this.UpdateDisplay();
     this.PlayPauseMediaElement();
 }
        /// <summary>
        /// Registers the specified media plugin so that it can be managed by this heuristics plugin.
        /// </summary>
        /// <param name="mediaPlugin">The media plugin to register.</param>
        /// <param name="priority">The relative priority of this media plugin</param>
        /// <param name="enableSync">Indicates if synchronization of this media plugin with others should be enabled.</param>
        public void RegisterPlugin(IMediaPlugin mediaPlugin, int priority, bool enableSync)
        {
            var ssme = mediaPlugin.VisualElement as SmoothStreamingMediaElement;

            if (IsLoaded && ssme != null)
            {
                if (priority == 0)
                {
                    _syncManager.HeuristicMasterMedia = ssme;
                    _syncManager.RegisterMaster(ssme, ssme.Position);
                    _syncManager.ResetHeuristics();
                }
                else
                {
                    var slave = new SlaveMediaElement
                    {
                        IsLogicalSyncEnabled = enableSync,
                        MediaElement         = ssme,
                        Tolerance            = TimeSpan.FromMilliseconds(_settings.SyncToleranceMillis)
                    };

                    _syncManager.SubMediaElements.Add(slave);
                    if (_syncManager.HeuristicMasterMedia != null)
                    {
                        _syncManager.ResetHeuristics();
                    }
                }
            }
        }
 private void MediaPluginMediaEnded(IMediaPlugin mediaPlugin)
 {
     if (mediaPlugin.Duration == this.Duration)
     {
         this.RaiseOnFinishedPlayingEvent();
     }
 }
 public PlaySpeedManager(IMediaPlugin mediaPlugin, TimeSpan fastForwardStepSize, TimeSpan rewindStepSize,
                         TimeSpan fastForwardStepFrequency, TimeSpan rewindStepFrequency)
     : this(mediaPlugin)
 {
     FastForwardStepSize = fastForwardStepSize;
     FastForwardStepFrequency = fastForwardStepFrequency;
     RewindStepSize = rewindStepSize;
     RewindStepFrequency = rewindStepFrequency;
 }
        /// <summary>
        /// Handles the SeekCompleted event of the <see cref="CoreSmoothStreamingMediaElement"/> media element.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The event args instance cointaining event data.</param>
        private void MediaElement_SeekCompleted(IMediaPlugin mediaPlugin, bool success)
        {
            if (this.seekingToLive)
            {
                this.seekingToLive = false;

                this.OnLiveSeekCompleted(success);
            }
        }
        private void OnMediaElementFailed(IMediaPlugin plugin)
        {
            Action <IMediaPlugin> mediaElementFailed = this.MediaElementFailed;

            if (mediaElementFailed != null)
            {
                mediaElementFailed(plugin);
            }
        }
        /// <summary>
        /// Triggers MediaFailed event.
        /// </summary>
        protected void OnMediaFailed(IMediaPlugin plugin)
        {
            Action <IMediaPlugin> mediaFailed = this.MediaPluginFailed;

            if (mediaFailed != null)
            {
                mediaFailed(plugin);
            }
        }
 public PlaySpeedManager(IMediaPlugin mediaPlugin, TimeSpan fastForwardStepSize, TimeSpan rewindStepSize,
                         TimeSpan fastForwardStepFrequency, TimeSpan rewindStepFrequency)
     : this(mediaPlugin)
 {
     FastForwardStepSize      = fastForwardStepSize;
     FastForwardStepFrequency = fastForwardStepFrequency;
     RewindStepSize           = rewindStepSize;
     RewindStepFrequency      = rewindStepFrequency;
 }
        void smfPlayer_MediaPluginRegistered(object sender, CustomEventArgs <IMediaPlugin> e)
        {
            //When the media plugin (progressive or smooth streaming) is registered, we'll subscribe
            //to its loaded event so that we can begin the initialization of the Anaglyph setup.
            activeMediaPlugin = e.Value;

            //(Unsubscribing from any previously loaded plugins first):
            activeMediaPlugin.PluginLoaded -= new Action <IPlugin>(activeMediaPlugin_PluginLoaded);
            activeMediaPlugin.PluginLoaded += new Action <IPlugin>(activeMediaPlugin_PluginLoaded);
        }
 public ImageAdPlayer(ICreativeSource Source, IAdTarget Target, IMediaPlugin ActiveMediaPlugin)
     : base(Source.Dimensions, Source.IsScalable, Source.Type == CreativeSourceType.Linear)
 {
     this.ActiveMediaPlugin = ActiveMediaPlugin;
     AdTarget = Target;
     AdSource = Source;
     if (AdSource.ClickUrl != null)
     {
         this.NavigateUri = new Uri(AdSource.ClickUrl, UriKind.RelativeOrAbsolute);
     }
 }
 public AdaptiveVideoAdPlayer(ICreativeSource AdSource, IAdTarget AdTarget, IMediaPlugin ActiveMediaPlugin)
     : base(AdSource.Dimensions, AdSource.IsScalable, AdSource.Type == CreativeSourceType.Linear)
 {
     this.ActiveMediaPlugin = ActiveMediaPlugin;
     this.AdSource = AdSource;
     this.AdTarget = AdTarget;
     if (AdSource.ClickUrl != null)
     {
         this.NavigateUri = new Uri(AdSource.ClickUrl, UriKind.RelativeOrAbsolute);
     }
 }
 private void PausePlayback(IMediaPlugin mediaPlugin)
 {
     if (mediaPlugin.CurrentState == MediaPluginState.Buffering || mediaPlugin.CurrentState == MediaPluginState.Playing)
     {
         mediaPlugin.Pause();
     }
     else
     {
         mediaPlugin.CurrentStateChanged += MediaPlugin_CurrentStateChanged;
     }
 }
 public AdaptiveVideoAdPlayer(ICreativeSource AdSource, IAdTarget AdTarget, IMediaPlugin ActiveMediaPlugin)
     : base(AdSource.Dimensions, AdSource.IsScalable, AdSource.Type == CreativeSourceType.Linear)
 {
     this.ActiveMediaPlugin = ActiveMediaPlugin;
     this.AdSource          = AdSource;
     this.AdTarget          = AdTarget;
     if (AdSource.ClickUrl != null)
     {
         this.NavigateUri = new Uri(AdSource.ClickUrl, UriKind.RelativeOrAbsolute);
     }
 }
 public ImageAdPlayer(ICreativeSource Source, IAdTarget Target, IMediaPlugin ActiveMediaPlugin)
     : base(Source.Dimensions, Source.IsScalable, Source.Type == CreativeSourceType.Linear)
 {
     this.ActiveMediaPlugin = ActiveMediaPlugin;
     AdTarget = Target;
     AdSource = Source;
     if (AdSource.ClickUrl != null)
     {
         this.NavigateUri = new Uri(AdSource.ClickUrl, UriKind.RelativeOrAbsolute);
     }
 }
        private void ModelVisualMediaPlugin_CurrentStateChanged(IMediaPlugin mediaPlugin, MediaPluginState state)
        {
            var playableMediaData = this.manifestMediaModel.GetVisualMediaData() as ManifestPlayableMediaData;

            if (playableMediaData != null)
            {
                if (!playableMediaData.LastSeekPosition.HasValue || playableMediaData.LastSeekPosition.Value == playableMediaData.Position)
                {
                    this.View.EnablePlayButton(true);
                }
            }
        }
Beispiel #19
0
 void ActiveMediaPlugin_CurrentStateChanged(IMediaPlugin mp, MediaPluginState state)
 {
     switch (state)
     {
     case MediaPluginState.Paused:
         if (CurrentAdContext.CurrentAdState == MediaPluginState.Closed)
         {
             OnAdStopped();
         }
         break;
     }
 }
 public AdClipLinearAdPlayer(ICreativeSource AdSource, IAdTarget AdTarget, IPlayer AdHost)
     : base(AdSource.Dimensions, AdSource.IsScalable, true)
 {
     this.AdSource = AdSource;
     this.AdTarget = AdTarget;
     this.ActiveMediaPlugin = AdHost.ActiveMediaPlugin;
     this.AdHost = AdHost;
     if (AdSource.ClickUrl != null)
     {
         this.NavigateUri = new Uri(AdSource.ClickUrl, UriKind.RelativeOrAbsolute);
     }
 }
        /// <summary>
        /// Handles the MediaEnded event of the MediaElement control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void MediaElement_MediaEnded(IMediaPlugin mediaPlugin)
        {
            this.StopPositionTimer();
            this.TogglePlay();

            if (this.mediaPlugin != null)
            {
                if (!this.mediaPlugin.PlaySpeedManager.IsPlaySpeedNormal)
                {
                    this.mediaPlugin.PlaySpeedManager.RestoreNaturalPlaySpeed();
                }
            }
        }
        public PlaySpeedManager(IMediaPlugin mediaPlugin)
        {
            if (mediaPlugin == null) throw new ArgumentNullException("mediaPlugin");

            _mediaPlugin = mediaPlugin;
            _stepTimer = new DispatcherTimer();
            _stepTimer.Tick += StepTimer_Tick;

            FastForwardStepSize = TimeSpan.FromMilliseconds(DefaultFastForwardStepSizeMillis);
            RewindStepSize = TimeSpan.FromMilliseconds(DefaultRewindStepSizeMillis);
            FastForwardStepFrequency = TimeSpan.FromMilliseconds(DefaultFastForwardStepFrequencyMillis);
            RewindStepFrequency = TimeSpan.FromMilliseconds(DefaultRewindStepFrequencyMillis);
        }
 public ChunkDownloadManager(IMediaPlugin mediaPlugin, long maximumRequestRate = DefaultMaximumRequestRate)
 {
     MaximumRetryAttempts      = DefaultMaximumRetryAttempts;
     MaximumConcurrentRequests = DefaultMaximumConcurrentRequests;
     Timeout = TimeSpan.FromMilliseconds(DefaultTimeoutMillis);
     _chunkDownloadStrategy = ChunkDownloadStrategy.AsNeeded;
     _mediaPlugin           = mediaPlugin;
     _maximumRequestRate    = maximumRequestRate;
     _requests              = new DownloadRequestCollection();
     _rateMonitor           = new RateMonitor();
     _refreshTimer          = new DispatcherTimer();
     _refreshTimer.Interval = TimeSpan.FromMilliseconds(DefaultAsNeededWindowMillis - DefaultTimeoutMillis);
     _refreshTimer.Tick    += _refreshTimer_Tick;
 }
 public ChunkDownloadManager(IMediaPlugin mediaPlugin, long maximumRequestRate = DefaultMaximumRequestRate)
 {
     MaximumRetryAttempts = DefaultMaximumRetryAttempts;
     MaximumConcurrentRequests = DefaultMaximumConcurrentRequests;
     Timeout = TimeSpan.FromMilliseconds(DefaultTimeoutMillis);
     _chunkDownloadStrategy = ChunkDownloadStrategy.AsNeeded;
     _mediaPlugin = mediaPlugin;
     _maximumRequestRate = maximumRequestRate;
     _requests = new DownloadRequestCollection();
     _rateMonitor = new RateMonitor();
     _refreshTimer = new DispatcherTimer();
     _refreshTimer.Interval = TimeSpan.FromMilliseconds(DefaultAsNeededWindowMillis - DefaultTimeoutMillis);
     _refreshTimer.Tick += _refreshTimer_Tick;
 }
        private void MediaElement_MediaFailed(IMediaPlugin mediaPlugin, Exception exception)
        {
            this.StopPositionTimer();
            this.IsMediaErrorExpanded = true;

            if (exception != null)
            {
                this.logger.Log("PlayerControl", exception);
            }

            this.TogglePlay();

            this.OnMediaErrorExpandedChanged();
        }
        private void MediaElement_PlaybackRateChanged(IMediaPlugin mediaPlugin)
        {
            if (this.MediaPlugin.PlaySpeedManager.IsPlaySpeedNormal)
            {
                if (this.FastRewindButton.IsChecked.GetValueOrDefault())
                {
                    this.FastRewindButton.IsChecked = false;
                }

                if (this.FastForwardButton.IsChecked.GetValueOrDefault())
                {
                    this.FastForwardButton.IsChecked = false;
                }
            }
        }
        private void OnMediaOpened(IMediaPlugin obj)
        {
            this.sourceChanging = false;

            if (this.bufferedPosition.HasValue)
            {
                this.Position         = this.bufferedPosition.Value;
                this.bufferedPosition = null;
            }

            if (this.playEnqueued)
            {
                this.Play();
            }
        }
        public PlaySpeedManager(IMediaPlugin mediaPlugin)
        {
            if (mediaPlugin == null)
            {
                throw new ArgumentNullException("mediaPlugin");
            }

            _mediaPlugin     = mediaPlugin;
            _stepTimer       = new DispatcherTimer();
            _stepTimer.Tick += StepTimer_Tick;

            FastForwardStepSize      = TimeSpan.FromMilliseconds(DefaultFastForwardStepSizeMillis);
            RewindStepSize           = TimeSpan.FromMilliseconds(DefaultRewindStepSizeMillis);
            FastForwardStepFrequency = TimeSpan.FromMilliseconds(DefaultFastForwardStepFrequencyMillis);
            RewindStepFrequency      = TimeSpan.FromMilliseconds(DefaultRewindStepFrequencyMillis);
        }
        public override void Dispose()
        {
            if (AdLinear)
            {
                UnloadLinear();
            }

            if (Image != null)
            {
                Image.ImageFailed -= new EventHandler <ExceptionRoutedEventArgs>(image_ImageFailed);
                Image.ImageOpened -= new EventHandler <RoutedEventArgs>(image_ImageOpened);
            }

            ActiveMediaPlugin = null;

            base.Dispose();
        }
Beispiel #30
0
        void smfPlayer_MediaPluginRegistered(object sender, Core.CustomEventArgs <Plugins.IMediaPlugin> e)
        {
            //When the media plugin is registered, we'll enable and disable the appropriate
            //3D plugins, and record which media plugin is loaded.
            Choose3DPlugin();
            currentMediaPlugin = e.Value;

            //Subscribe to events indicating whether the 3D plugin's properties are valid
            if (Anaglyph3DPlugin.Current != null)
            {
                Anaglyph3DPlugin.Current.S3DPropertiesValid   -= Current_S3DPropertiesValid;
                Anaglyph3DPlugin.Current.S3DPropertiesInvalid -= Current_S3DPropertiesInvalid;

                Anaglyph3DPlugin.Current.S3DPropertiesValid   += Current_S3DPropertiesValid;
                Anaglyph3DPlugin.Current.S3DPropertiesInvalid += Current_S3DPropertiesInvalid;
            }
        }
		void smfPlayer_MediaPluginRegistered(object sender, Core.CustomEventArgs<Plugins.IMediaPlugin> e)
		{
			//When the media plugin is registered, we'll enable and disable the appropriate
			//3D plugins, and record which media plugin is loaded.
			Choose3DPlugin();
			currentMediaPlugin = e.Value;

			//Subscribe to events indicating whether the 3D plugin's properties are valid
			if (Anaglyph3DPlugin.Current != null)
			{
				Anaglyph3DPlugin.Current.S3DPropertiesValid -= Current_S3DPropertiesValid;
				Anaglyph3DPlugin.Current.S3DPropertiesInvalid -= Current_S3DPropertiesInvalid;

				Anaglyph3DPlugin.Current.S3DPropertiesValid += Current_S3DPropertiesValid;
				Anaglyph3DPlugin.Current.S3DPropertiesInvalid += Current_S3DPropertiesInvalid;
			}
		}
        private void OnManifestMediaModelMediaElementFailed(IMediaPlugin plugin)
        {
            if (plugin != null)
            {
                for (int i = 0; i <= this.maxNumberOfAudioTracks; i++)
                {
                    // all tracks have no strem to play
                    this.manifestMediaModel.InvokeMethodForAllMediaData(md => md.Hide());
                    this.manifestMediaModel.SetStreamSource(i, null);
                    this.manifestMediaModel.Stop();
                }

                this.operationBalance++;
                this.OnPropertyChanged("PlayerStatus");

                this.View.EnablePlayButton(true);
                this.View.ShowErrorMessage(true);
            }
        }
        public override void Dispose()
        {
            if (AdLinear)
            {
                UnloadLinear();
            }

            if (MediaElement != null)
            {
                MediaElement.MediaFailed         -= new EventHandler <ExceptionRoutedEventArgs>(OnAdPlayerMediaFailed);
                MediaElement.MediaEnded          -= new RoutedEventHandler(OnAdPlayerMediaEnded);
                MediaElement.MediaOpened         -= new RoutedEventHandler(OnAdPlayerMediaOpened);
                MediaElement.CurrentStateChanged -= new RoutedEventHandler(OnAdPlayerCurrentStateChanged);
                MediaElement.Source = null;
            }

            ActiveMediaPlugin = null;

            base.Dispose();
        }
        private void MediaPlugin_MediaFailed(IMediaPlugin mediaPlugin, Exception error)
        {
            if (_successTimer.IsEnabled)
            {
                _successTimer.Stop();
            }

            if (!exitOnFail)
            {
                RetryAttemptFailed.IfNotNull(i => i(this, error));
                // start up a timer to try again
                _waitTimer.Start();
            }
            else
            {
                exitOnFail = false;
                RetryFailed.IfNotNull(i => i(this));
                Deployment.Current.Dispatcher.BeginInvoke(StopRetrying);
            }
        }
        /// <summary>
        /// Releases the resources used by the RetryMonitor.
        /// </summary>
        public void Dispose()
        {
            _successTimer.Tick -= successTimer_Tick;
            if (_successTimer.IsEnabled)
            {
                _successTimer.Stop();
            }

            _waitTimer.Tick -= WaitTimer_Tick;
            if (_waitTimer.IsEnabled)
            {
                _waitTimer.Stop();
            }

            if (_giveupTimer != null)
            {
                _giveupTimer.Tick -= GiveupTimer_Tick;
                _giveupTimer.Stop();
                UnregisterMediaPlugin();
                _mediaPlugin = null;
                _mediaSource = null;
            }
        }
 private void MediaPlugin_SeekCompleted(IMediaPlugin obj)
 {
     isSeekActive = false;
     UpdateTimelinePositions(true);
     SeekCompleted.IfNotNull(i => i(this, EventArgs.Empty));
 }
 void _mediaPlugin_SeekCompleted(IMediaPlugin obj)
 {
     NotifyRequestAdded();
 }
 private void MediaPlugin_MediaOpened(IMediaPlugin mediaPlugin)
 {
     //All MediaPlugin events are being dispatched to the UI thread because
     //they may likely be coming in from another thread and errors can occur
     //if they interact with the UI
     Dispatcher.BeginInvoke(OnMediaOpened);
 }
 private void MediaPlugin_PlaybackRateChanged(IMediaPlugin mediaPlugin)
 {
     SendLogEntry(KnownLogEntryTypes.PlaybackRateChanged,
             extendedProperties: new Dictionary<string, object> { { "PlaybackRate", mediaPlugin.PlaybackRate } });
 }
        private void RegisterMediaPlugin(IMediaPlugin mediaPlugin)
        {
            var adaptiveMediaPlugin = mediaPlugin as IAdaptiveMediaPlugin;

            mediaPlugin.CurrentStateChanged += MediaPlugin_CurrentStateChanged;
            mediaPlugin.MediaOpened += MediaPlugin_MediaOpened;
            mediaPlugin.MediaFailed += MediaPlugin_MediaFailed;
            mediaPlugin.MediaEnded += MediaPlugin_MediaEnded;
            mediaPlugin.LogReady += Plugin_LogReady;
            mediaPlugin.MarkerReached += MediaPlugin_MarkerReached;
            mediaPlugin.BufferingProgressChanged += MediaPlugin_BufferingProgressChanged;
            mediaPlugin.DownloadProgressChanged += MediaPlugin_DownloadProgressChanged;
            mediaPlugin.PluginLoaded += MediaPlugIn_PluginLoaded;
            mediaPlugin.PluginLoadFailed += MediaPlugIn_PluginLoadFailed;
            mediaPlugin.PlaybackRateChanged += MediaPlugin_PlaybackRateChanged;
            mediaPlugin.AdClickThrough += MediaPlugin_AdClickThrough;
            mediaPlugin.AdProgressUpdated += MediaPlugin_AdProgressUpdated;
            mediaPlugin.AdStateChanged += mediaPlugin_AdStateChanged;
            mediaPlugin.AdError += MediaPlugin_AdError;
            mediaPlugin.SeekCompleted += MediaPlugin_SeekCompleted;


            if (adaptiveMediaPlugin != null)
            {
                adaptiveMediaPlugin.ManifestReady += MediaPlugin_ManifestReady;
                adaptiveMediaPlugin.StreamSelected += MediaPlugin_StreamSelected;
                adaptiveMediaPlugin.StreamUnselected += MediaPlugin_StreamUnselected;
                adaptiveMediaPlugin.StreamSelectionFailed += MediaPlugin_StreamSelectionFailed;
                adaptiveMediaPlugin.StreamDataAdded += MediaPlugin_StreamDataAdded;
                adaptiveMediaPlugin.StreamDataRemoved += MediaPlugin_StreamDataRemoved;
                adaptiveMediaPlugin.DownloadStreamDataFailed += MediaPlugin_DownloadStreamDataFailed;
                adaptiveMediaPlugin.DownloadStreamDataCompleted += MediaPlugin_DownloadStreamDataCompleted;
                adaptiveMediaPlugin.AdaptiveStreamingErrorOccurred += MediaPlugin_AdaptiveStreamingErrorOccurred;
                //adaptiveMediaPlugin.VideoPlaybackTrackChanged += MediaPlugin_VideoPlaybackTrackChanged;
                adaptiveMediaPlugin.VideoDownloadTrackChanged += MediaPlugin_VideoDownloadTrackChanged;
            }
            if (mediaPlugin is IVariableBitrateMediaPlugin)
            {
                ((IVariableBitrateMediaPlugin)mediaPlugin).VideoPlaybackBitrateChanged += MediaPlugin_VideoPlaybackBitrateChanged;
            }

            PlaySpeedManager = new PlaySpeedManager(mediaPlugin);
            InitPlaySpeedManager();

            _retryMonitor = new RetryMonitor
            {
                MediaPlugin = mediaPlugin
            };

            _retryMonitor.RetryAttemptFailed += RetryMonitor_RetryAttemptFailed;
            _retryMonitor.RetryCancelled += RetryMonitor_RetryCancelled;
            _retryMonitor.RetryFailed += RetryMonitor_RetryFailed;
            _retryMonitor.RetryStarted += RetryMonitor_RetryStarted;
            _retryMonitor.RetrySuccessful += RetryMonitor_RetrySuccessful;

            MediaPluginRegistered.IfNotNull(i => i(this, new CustomEventArgs<IMediaPlugin>(mediaPlugin)));
        }
        public override void Dispose()
        {
            if (AdLinear)
            {
                UnloadLinear();
            }

            if (MediaElement != null)
            {
                MediaElement.MediaFailed -= new EventHandler<ExceptionRoutedEventArgs>(OnAdPlayerMediaFailed);
                MediaElement.MediaEnded -= new RoutedEventHandler(OnAdPlayerMediaEnded);
                MediaElement.MediaOpened -= new RoutedEventHandler(OnAdPlayerMediaOpened);
                MediaElement.CurrentStateChanged -= new RoutedEventHandler(OnAdPlayerCurrentStateChanged);
                MediaElement.SmoothStreamingSource = null;
                MediaElement.Dispose();
            }

            ActiveMediaPlugin = null;

            base.Dispose();
        }
 private void PausePlayback(IMediaPlugin mediaPlugin)
 {
     if (mediaPlugin.CurrentState == MediaPluginState.Buffering || mediaPlugin.CurrentState == MediaPluginState.Playing)
     {
         mediaPlugin.Pause();
     }
     else
     {
         mediaPlugin.CurrentStateChanged += MediaPlugin_CurrentStateChanged;
     }
 }
 private void MediaPlugin_BufferingProgressChanged(IMediaPlugin progressiveMediaPlugin, double bufferingProgress)
 {
     Dispatcher.BeginInvoke(() => BufferingProgress = bufferingProgress);
 }
 private void MediaPlugin_MediaFailed(IMediaPlugin mediaPlugin, Exception error)
 {
     Dispatcher.BeginInvoke(() => OnMediaFailed(error));
 }
 public void OnPlayerStateChangedHandler(IMediaPlugin mediaPlugin, MediaPluginState mediaPluginState)
 {
 }
 private void MediaPlugin_MarkerReached(IMediaPlugin mediaPlugin, MediaMarker mediaMarker)
 {
     var timelineMarker = new TimelineMediaMarker
     {
         Begin = mediaMarker.Begin,
         Content = mediaMarker.Content,
         End = mediaMarker.End,
         Id = mediaMarker.Id,
         Type = mediaMarker.Type
     };
     Dispatcher.BeginInvoke(() => OnTimelineMarkerReached(timelineMarker, false));
 }
 private void MediaPlugin_DownloadProgressChanged(IMediaPlugin progressiveMediaPlugin, double downloadProgress)
 {
     Dispatcher.BeginInvoke(() => DownloadProgress = downloadProgress);
 }
 void ActiveMediaPlugin_CurrentStateChanged(IMediaPlugin mp, MediaPluginState state)
 {
     switch (state)
     {
         case MediaPluginState.Paused:
             if (CurrentAdContext.CurrentAdState == MediaPluginState.Closed)
             {
                 OnAdStopped();
             }
             break;
     }
 }
        public override void Dispose()
        {
            if (AdLinear)
            {
                UnloadLinear();
            }

            if (Image != null)
            {
                Image.ImageFailed -= new EventHandler<ExceptionRoutedEventArgs>(image_ImageFailed);
                Image.ImageOpened -= new EventHandler<RoutedEventArgs>(image_ImageOpened);
            }

            ActiveMediaPlugin = null;

            base.Dispose();
        }
Beispiel #50
0
 void mediaPlugin_MediaOpened(IMediaPlugin obj)
 {
     obj.MediaOpened -= mediaPlugin_MediaOpened;
     player.ActiveMediaPlugin.VisualElement.IfNotNull(v => v.Visibility = Visibility.Visible);
     ScheduleAds();
 }
        void smfPlayer_MediaPluginRegistered(object sender, CustomEventArgs<IMediaPlugin> e)
        {
            //When the media plugin (progressive or smooth streaming) is registered, we'll subscribe
            //to its loaded event so that we can begin the initialization of the Anaglyph setup.
            activeMediaPlugin = e.Value;

            //(Unsubscribing from any previously loaded plugins first):
            activeMediaPlugin.PluginLoaded -= new Action<IPlugin>(activeMediaPlugin_PluginLoaded);
            activeMediaPlugin.PluginLoaded += new Action<IPlugin>(activeMediaPlugin_PluginLoaded);
        }
 private void MediaPlugin_CurrentStateChanged(IMediaPlugin mediaPlugin, MediaPluginState playState)
 {
     Dispatcher.BeginInvoke(() => PlayState = playState);
 }
 void MediaPlugin_CurrentStateChanged(IMediaPlugin mediaPlugin, MediaPluginState state)
 {
     ActiveMediaPlugin.CurrentStateChanged -= MediaPlugin_CurrentStateChanged;
     PausePlayback(mediaPlugin);
 }
 private void MediaPlugin_MediaEnded(IMediaPlugin mediaPlugin)
 {
     Dispatcher.BeginInvoke(OnMediaEnded);
 }
 public void PluginSeekCompleted(IMediaPlugin obj, bool sucess)
 {
 }
        private void UnregisterMediaPlugin(IMediaPlugin mediaPlugin)
        {
            var adaptiveMediaPlugin = mediaPlugin as IAdaptiveMediaPlugin;

            _adMarkerManager.Reset();
            _captionManager.Reset();
            _timelineMarkerManager.Reset();

            mediaPlugin.CurrentStateChanged -= MediaPlugin_CurrentStateChanged;
            mediaPlugin.MediaOpened -= MediaPlugin_MediaOpened;
            mediaPlugin.MediaFailed -= MediaPlugin_MediaFailed;
            mediaPlugin.MediaEnded -= MediaPlugin_MediaEnded;
            mediaPlugin.LogReady -= Plugin_LogReady;
            mediaPlugin.MarkerReached -= MediaPlugin_MarkerReached;
            mediaPlugin.BufferingProgressChanged -= MediaPlugin_BufferingProgressChanged;
            mediaPlugin.DownloadProgressChanged -= MediaPlugin_DownloadProgressChanged;
            mediaPlugin.PluginLoaded -= MediaPlugIn_PluginLoaded;
            mediaPlugin.PluginLoadFailed -= MediaPlugIn_PluginLoadFailed;
            mediaPlugin.PlaybackRateChanged -= MediaPlugin_PlaybackRateChanged;
            mediaPlugin.AdClickThrough -= MediaPlugin_AdClickThrough;
            mediaPlugin.AdProgressUpdated -= MediaPlugin_AdProgressUpdated;
            mediaPlugin.AdStateChanged -= mediaPlugin_AdStateChanged;
            mediaPlugin.AdError -= MediaPlugin_AdError;
            mediaPlugin.SeekCompleted -= MediaPlugin_SeekCompleted;

            if (adaptiveMediaPlugin != null)
            {
                ActiveHeuristicsPlugin.IfNotNull(i => i.UnregisterPlugin(adaptiveMediaPlugin));
                adaptiveMediaPlugin.ManifestReady -= MediaPlugin_ManifestReady;
                adaptiveMediaPlugin.StreamSelected -= MediaPlugin_StreamSelected;
                adaptiveMediaPlugin.StreamSelectionFailed -= MediaPlugin_StreamSelectionFailed;
                adaptiveMediaPlugin.StreamDataAdded -= MediaPlugin_StreamDataAdded;
                adaptiveMediaPlugin.DownloadStreamDataFailed -= MediaPlugin_DownloadStreamDataFailed;
                adaptiveMediaPlugin.DownloadStreamDataCompleted -= MediaPlugin_DownloadStreamDataCompleted;
                adaptiveMediaPlugin.AdaptiveStreamingErrorOccurred -= MediaPlugin_AdaptiveStreamingErrorOccurred;
                adaptiveMediaPlugin.StreamUnselected -= MediaPlugin_StreamUnselected;
                adaptiveMediaPlugin.StreamDataRemoved -= MediaPlugin_StreamDataRemoved;
                //adaptiveMediaPlugin.VideoPlaybackTrackChanged -= MediaPlugin_VideoPlaybackTrackChanged;
                adaptiveMediaPlugin.VideoDownloadTrackChanged -= MediaPlugin_VideoDownloadTrackChanged;
            }
            if (mediaPlugin is IVariableBitrateMediaPlugin)
            {
                ((IVariableBitrateMediaPlugin)mediaPlugin).VideoPlaybackBitrateChanged -= MediaPlugin_VideoPlaybackBitrateChanged;
            }

            if (PlaySpeedManager != null)
            {
                PlaySpeedManager.Dispose();
                PlaySpeedManager = null;
            }

            if (_retryMonitor != null)
            {
                _retryMonitor.RetryAttemptFailed -= RetryMonitor_RetryAttemptFailed;
                _retryMonitor.RetryCancelled -= RetryMonitor_RetryCancelled;
                _retryMonitor.RetryFailed -= RetryMonitor_RetryFailed;
                _retryMonitor.RetryStarted -= RetryMonitor_RetryStarted;
                _retryMonitor.RetrySuccessful -= RetryMonitor_RetrySuccessful;
                _retryMonitor.Dispose();
                _retryMonitor = null;
            }

            if (mediaPlugin.IsLoaded)
            {
                mediaPlugin.Unload();
            }

            MediaPresenterElement.IfNotNull(i => i.Content = null);
        }
 /// <summary>
 /// Determines if this plugin supports management of the specified media plugin.
 /// </summary>
 /// <param name="mediaPlugin">The media plugin.</param>
 /// <returns>True if this media plugin is supported.</returns>
 public bool SupportsPlugin(IMediaPlugin mediaPlugin)
 {
     return mediaPlugin is IAdaptiveMediaPlugin;
 }
 /// <summary>
 /// Registers the specified media plugin so that it can be managed by this heuristics plugin.
 /// </summary>
 /// <param name="mediaPlugin">The media plugin to register.</param>
 /// <param name="priority">The relative priority of this media plugin</param>
 /// <param name="enableSync">Indicates if synchronization of this media plugin with others should be enabled.</param>
 public void RegisterPlugin(IMediaPlugin mediaPlugin, int priority, bool enableSync)
 {
     var adaptivePlugin = mediaPlugin as IAdaptiveMediaPlugin;
     adaptivePlugin.IfNotNull(i => _heuristicsManager.RegisterPlugin(i, priority));
 }
 /// <summary>
 /// Unregisters the specified media plugin so that it is no longer managed by this heuristics plugin.
 /// </summary>
 /// <param name="mediaPlugin">The media plugin to unregister.</param>
 public void UnregisterPlugin(IMediaPlugin mediaPlugin)
 {
     var adaptivePlugin = mediaPlugin as IAdaptiveMediaPlugin;
     adaptivePlugin.IfNotNull(_heuristicsManager.UnregisterPlugin);
 }
Beispiel #60
0
 void ActiveMediaPlugin_MediaEnded(IMediaPlugin obj)
 {
     obj.MediaEnded -= ActiveMediaPlugin_MediaEnded;
     PlayPostRoll();
 }