private void TickTimer(object sender, EventArgs e)
 {
     if (msecsRemaining > 0)
     {
         msecsRemaining = (long)endTime.Subtract(DateTime.Now).TotalMilliseconds;
         var pos = cdgLength - msecsRemaining;
         cdgFile.renderAtPosition(pos);
         var image = (System.Drawing.Bitmap)cdgFile.get_RGBImage();
         if (!firstFrame)
         {
             ChangeAnnounceColor(image);
         }
         if (step1 && pos > 10000)
         {
             txtAnuncio.Visibility = System.Windows.Visibility.Hidden;
             step1 = false;
             step2 = true;
         }
         if (step2 && msecsRemaining < 15000)
         {
             txtAnuncio.Visibility = System.Windows.Visibility.Visible;
             txtAnuncio.Text       = messageEnd;
             step2 = false;
         }
         karImage.Source = loadBitmap(image);
     }
     else
     {
         waveOutDevice.Stop();
         KaraokeEnded(currentId);
     }
 }
 private void TickTimer(object sender, EventArgs e)
 {
     if (msecsRemaining > 0)
     {
         msecsRemaining = (long)endTime.Subtract(DateTime.Now).TotalMilliseconds;
         var pos = cdgLength - msecsRemaining;
         cdgFile.renderAtPosition(pos);
         var image = cdgFile.get_RGBImage();
         imagen.Source = loadBitmap((System.Drawing.Bitmap)image);
     }
 }
示例#3
0
        public void PlayCdg(string fileName, System.Windows.Forms.PictureBox canvas)
        {
            int frameCount = 0;

            stopPlay = false;
            cdgFile  = new CDGFile(fileName);
            var mp3FileName = fileName.Replace(Path.GetExtension(fileName), ".mp3");
            var cdgLength   = cdgFile.getTotalDuration();

            PlayMp3File(mp3FileName);
            var startTime      = DateTime.Now;
            var endTime        = startTime.AddMilliseconds(cdgLength);
            var msecsRemaining = cdgLength;

            while (msecsRemaining > 0)
            {
                if (stopPlay)
                {
                    break;
                }
                msecsRemaining = (long)endTime.Subtract(DateTime.Now).TotalMilliseconds;
                var pos = cdgLength - msecsRemaining;
                while (pausePlay)
                {
                    endTime = DateTime.Now.AddMilliseconds(msecsRemaining);
                    System.Windows.Forms.Application.DoEvents();
                }
                cdgFile.renderAtPosition(pos);
                ++frameCount;
                canvas.Image     = cdgFile.get_RGBImage(false);
                canvas.BackColor = ((System.Drawing.Bitmap)canvas.Image).GetPixel(1, 1);
                canvas.Refresh();
                System.Windows.Forms.Application.DoEvents();
            }
            StopCdgFile();
        }