Beispiel #1
0
        private void StopPlayback()
        {
            Console.Write("\nStopping play back...");

            mStop = true;
            HideCDGWindow();
            StopPlaybackBass();

            if (mCDGFile != null)
            {
                mCDGFile.Dispose();
            }
            CleanUp();
        }
Beispiel #2
0
        private void btSelectFile_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                edFilename.Text = openFileDialog1.FileName;

                if (cdg != null)
                {
                    cdg.Dispose();
                    cdg = null;
                }

                var cdgFile = Path.Combine(Path.GetDirectoryName(edFilename.Text), Path.GetFileNameWithoutExtension(edFilename.Text)) + ".cdg";
                if (File.Exists(cdgFile))
                {
                    cdg = new CDGFile(cdgFile);
                }
            }
        }
Beispiel #3
0
 public void StopCdgFile()
 {
     stopPlay = true;
     waveOutDevice.Stop();
     cdgFile.Dispose();
 }
Beispiel #4
0
        public void CDGtoAVI(string aviFileName, string cdgFileName, string mp3FileName, double frameRate, string backgroundFileName = "")
        {
            Bitmap      backgroundBmp = null;
            Bitmap      mergedBMP     = null;
            VideoStream aviStream     = default(VideoStream);
            CDGFile     myCDGFile     = new CDGFile(cdgFileName);

            myCDGFile.renderAtPosition(0);
            Bitmap bitmap__1 = (Bitmap)myCDGFile.RGBImage;

            if (!string.IsNullOrEmpty(backgroundFileName))
            {
                try
                {
                    if (IsMovie(backgroundFileName))
                    {
                        backgroundBmp = MovieFrameExtractor.GetBitmap(0, backgroundFileName, CDGFile.CDG_FULL_WIDTH, CDGFile.CDG_FULL_HEIGHT);
                    }
                    if (IsGraphic(backgroundFileName))
                    {
                        backgroundBmp = CDGNet.GraphicUtil.GetCDGSizeBitmap(backgroundFileName);
                    }
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message);
                }
            }
            AviManager aviManager = new AviManager(aviFileName, false);

            if (backgroundBmp != null)
            {
                mergedBMP = GraphicUtil.MergeImagesWithTransparency(backgroundBmp, bitmap__1);
                aviStream = aviManager.AddVideoStream(true, frameRate, mergedBMP);
                mergedBMP.Dispose();
                if (IsMovie(backgroundFileName))
                {
                    backgroundBmp.Dispose();
                }
            }
            else
            {
                aviStream = aviManager.AddVideoStream(true, frameRate, bitmap__1);
            }

            int    count         = 0;
            double frameInterval = 1000 / frameRate;
            long   totalDuration = myCDGFile.getTotalDuration();
            double position      = 0;

            while (position <= totalDuration)
            {
                count   += 1;
                position = count * frameInterval;
                myCDGFile.renderAtPosition(Convert.ToInt64(position));
                bitmap__1 = (Bitmap)myCDGFile.RGBImage;
                if (!string.IsNullOrEmpty(backgroundFileName))
                {
                    if (IsMovie(backgroundFileName))
                    {
                        backgroundBmp = MovieFrameExtractor.GetBitmap(position / 1000, backgroundFileName, CDGFile.CDG_FULL_WIDTH, CDGFile.CDG_FULL_HEIGHT);
                    }
                }
                if (backgroundBmp != null)
                {
                    mergedBMP = GraphicUtil.MergeImagesWithTransparency(backgroundBmp, bitmap__1);
                    aviStream.AddFrame(mergedBMP);
                    mergedBMP.Dispose();
                    if (IsMovie(backgroundFileName))
                    {
                        backgroundBmp.Dispose();
                    }
                }
                else
                {
                    aviStream.AddFrame(bitmap__1);
                }
                bitmap__1.Dispose();
                double percentageDone = (position / totalDuration) * 100;

                if (Status != null)
                {
                    Status(percentageDone.ToString());
                }
                Application.DoEvents();
            }
            myCDGFile.Dispose();
            aviManager.Close();
            if (backgroundBmp != null)
            {
                backgroundBmp.Dispose();
            }

            // Add MP3 to AVI
            Console.Write("|nAVI terminated, add MP3 to AVI");
            AddMP3toAVI(aviFileName, mp3FileName);
        }