예제 #1
0
 public void UnLoad()
 {
     if (this.plugin != null)
     {
         this.plugin.Unload();
         this.plugin.Dispose();
         this.plugin = null;
     }
 }
예제 #2
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        /// <param name="disposing">Indicates if Dispose is being called from the Dispose method.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (disposing && !this.disposed)
            {
                if (this.plugin != null)
                {
                    this.plugin.MediaOpened   -= this.OnMediaOpened;
                    this.plugin.SeekCompleted -= this.OnSeekCompleted;
                    this.plugin.Unload();
                    this.plugin.Dispose();
                    this.plugin = null;
                }

                this.disposed = true;
            }
        }
예제 #3
0
        private void InitPlugin()
        {
            if (this.plugin == null)
            {
                this.plugin                          = new RCESmoothStreamingMediaPlugin();
                this.plugin.IsMuted                  = true;
                this.plugin.AutoPlay                 = false;
                this.plugin.MediaOpened             += this.OnMediaOpened;
                this.plugin.SeekCompleted           += this.OnSeekCompleted;
                this.plugin.VisualElement.Width      = 112;
                this.plugin.VisualElement.Height     = 63;
                this.plugin.VisualElement.Visibility = Visibility.Collapsed;
                this.LayoutRoot.Children.Add(this.plugin.VisualElement);
            }

            this.LoadingContainer.Visibility = Visibility.Collapsed;
        }
        /// <summary>
        /// Picks a thumbnail of the current media element.
        /// </summary>
        /// <param name="mediaData">The media data o the current element.</param>
        public void PickThumbnail(MediaData mediaData, ThumbnailType thumbnailType)
        {
            if (mediaData != null)
            {
                IRCESmoothStreamingMediaPlugin mediaElement = mediaData.MediaPlugin as IRCESmoothStreamingMediaPlugin;

                if (mediaElement != null)
                {
                    this.StartThumbnailBuffer();
                    bool     thumbnailSeekCompleted = false;
                    TimeSpan currentPosition        = mediaElement.Position;

                    IRCESmoothStreamingMediaPlugin plugin = new RCESmoothStreamingMediaPlugin();

                    DispatcherTimer thubmnailTimer = new DispatcherTimer {
                        Interval = new TimeSpan(0, 0, 0, 5)
                    };

                    thubmnailTimer.Tick += (sender, e) =>
                    {
                        if (thumbnailSeekCompleted)
                        {
                            thumbnailSeekCompleted = false;
                            thubmnailTimer.Stop();
                            WriteableBitmap writeableBitmap =
                                new WriteableBitmap(plugin.VisualElement, null);

                            // writeableBitmap.Render(mediaElement, null);
                            writeableBitmap.Invalidate();
                            this.Model.SetThumbnail(writeableBitmap, thumbnailType);
                            this.PlayerContainerGrid.Children.Remove(plugin.VisualElement);
                            plugin.Unload();
                            plugin         = null;
                            thubmnailTimer = null;
                            this.EndThumbnailBuffer();
                        }
                    };

                    thubmnailTimer.Start();

                    plugin.ManifestReady += e => plugin.SelectMaxAvailableBitrateTracks("cameraAngle", "camera1");

                    plugin.MediaOpened += e =>
                    {
                        e.Position = currentPosition;
                        e.VisualElement.Visibility = Visibility.Collapsed;
                    };

                    plugin.SeekCompleted += (e, success) => thumbnailSeekCompleted = true;
                    plugin.Load();
                    plugin.AutoPlay             = false;
                    plugin.Volume               = 0;
                    plugin.IsMuted              = true;
                    plugin.VisualElement.Width  = mediaElement.VisualElement.ActualWidth;
                    plugin.VisualElement.Height = mediaElement.VisualElement.ActualHeight;
                    this.PlayerContainerGrid.Children.Add(plugin.VisualElement);

                    plugin.AdaptiveSource = mediaElement.AdaptiveSource;
                }
            }
        }