示例#1
0
        /// <summary>
        /// Creates a new DvdPlayer, 
        /// running on it's own Dispatcher
        /// </summary>
        public static DvdPlayer CreateDvdPlayer()
        {
            DvdPlayer player = null;

            var reset = new ManualResetEvent(false);

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

                /* Make our thread name a little unique */
                Thread.CurrentThread.Name = string.Format("DvdPlayer 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);

            /* 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;
        }
 protected override MediaPlayerBase OnRequestMediaPlayer()
 {
     /* Initialize the DVD player and hook into it's events */
     var player = new DvdPlayer();
     player.OnDvdEjected += DvdPlayerOnDvdEjected;
     player.OnDvdInserted += DvdPlayerOnDvdInserted;
     player.OnOverDvdButton += DvdPlayerOnOverDvdButton;
     player.OnDvdTime += DvdPlayerOnDvdTime;
     player.OnDvdError += DvdPlayerOnDvdError;
     return player;
 }