Exemple #1
0
        //这个线程在视频被停止之前就不听了,用BitmapPlayer的countFrame掐时间就好。。。
        public void playing()
        {
            loadedDanmu = 0;
            int current_count = 0;

            while (true)
            {
                if (BitmapPlayer.finish == 1)
                {
                    return;
                }
                while (current_count >= BitmapPlayer.countFrame)
                {
                }

                while (danmuList.danmu.Count < current_count + 1)
                {
                    danmuList.danmu.Add(new List <string>());
                }

                if (danmuList.danmu[current_count].Count > 0)
                {
                    foreach (String a in danmuList.danmu[current_count])
                    {
                        System.Windows.Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() =>
                        {
                            dmkCurt.Shoot(curtain, a);
                        }));
                    }
                }

                current_count++;
            }
        }
 private void send_Click(object sender, RoutedEventArgs e)
 {
     danmuPlayer.addDanmu(message.Text);
     Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
     {
         dmkCurt.Shoot(curtain, message.Text);
     }));
 }
 public void play(Grid curtain, DanmakuCurtain dmkCurt)
 {
     foreach (Tuple <String, double> item in hist)
     {
         Timer timer = new Timer(item.Item2);
         timer.Elapsed += new ElapsedEventHandler(
             delegate(object source, ElapsedEventArgs e){
             Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
             {
                 dmkCurt.Shoot(curtain, item.Item1);
             }));
         }
             );
         timer.AutoReset = false;
         timer.Enabled   = true;
     }
 }