Esempio n. 1
0
 /// <summary>
 /// Gets the instance of the media player to initialize
 /// our base classes with
 /// </summary>
 protected override MediaPlayerBase OnRequestMediaPlayer()
 {
     var player = new MediaUriPlayer();
     return player;
 }
 /// <summary>
 /// Gets the instance of the media player to initialize
 /// our base classes with
 /// </summary>
 protected override MediaPlayerBase OnRequestMediaPlayer()
 {
     var player = new MediaUriPlayer();
     player.BufferedPercentChanged += OnMediaPlayerBufferedPercentChanged;
     return player;
 }
Esempio n. 3
0
        /// <summary>
        /// Creates a new MediaUriPlayer, 
        /// running on it's own Dispatcher
        /// </summary>
        public static MediaUriPlayer CreateMediaUriPlayer()
        {
            MediaUriPlayer player = null;

            var reset = new ManualResetEvent(false);

            var t = new Thread((ThreadStart) delegate
            {
                player = new MediaUriPlayer();

                /* Make our thread name a little unique */
                Thread.CurrentThread.Name = string.Format("MediaUriPlayer Graph {0}",
                                                          player.GraphInstanceId);

                /* We queue up a method to execute
                 * when the Dispatcher is ran.
                 * This will wake up the calling thread. */
                player.Dispatcher.Invoke((Action) (() => reset.Set()));

                Dispatcher.Run();
            })
            {
                IsBackground = true
            };

            t.SetApartmentState(ApartmentState.MTA);

            /* Set this to low priority now and we'll
             * set it back to normal later on in hope
             * that our UI thread's priority stays higher */
            t.Priority = ThreadPriority.Lowest;

            /* Starts the thread and creates the object */
            t.Start();

            /* We wait until our object is created and
             * the new Dispatcher is running */
            reset.WaitOne();

            return player;
        }