Example #1
0
        public static CDInfo ReadCDInformationMCI(char driveLetter)
        {
            MCICDEngine mciCDEngine = new MCICDEngine();

            mciCDEngine.Open(driveLetter);
            mciCDEngine.Close();

            return(mciCDEngine.CDInfo);
        }
Example #2
0
        /// <summary>
        /// Spielt die angegebene Musikdatei ab.
        /// </summary>
        /// <param name="filename"></param>
        public void Play(string filename)
        {
            Filename = filename;

            if (!this.isPreListenSoundEngine)
            {
                if (currentSoundIndex == 0)
                {
                    currentSoundIndex = 1;
                }
                else
                {
                    currentSoundIndex = 0;
                }
            }

            if (IsPlaying)
            {
                Stop();
            }

            FMOD.RESULT result = FMOD.RESULT.OK;

            if (filename.StartsWith("cd:"))
            {
                string cdDrive     = string.Format("{0}:", filename[3]);
                int    trackNumber = Miscellaneous.Misc.Atoi(filename.Substring(5));

                if (Settings.Current.UseMCI)
                {
                    if (mciCDEngine == null)
                    {
                        mciCDEngine = new MCICDEngine();
                        mciCDEngine.Open(cdSoundDriveLetter[0]);
                    }

                    currentCDTrackNumber = trackNumber;

                    mciCDEngine.PlayTrack(trackNumber);
                    return;
                }
                else
                {
                    if (cdSound == null)
                    {
                        result = system.createStream(cdDrive, (FMOD.MODE._2D | FMOD.MODE.HARDWARE), ref cdSound);
                        ERRCHECK(result);
                    }
                    else
                    {
                        if (cdDrive != cdSoundDriveLetter)
                        {
                            cdSound.release();

                            result = system.createStream(cdDrive, (FMOD.MODE._2D | FMOD.MODE.HARDWARE), ref cdSound);
                            ERRCHECK(result);
                        }
                    }

                    if (currentSoundIndex == 0)
                    {
                        result = cdSound.getSubSound(trackNumber, ref sound1);
                    }
                    else
                    {
                        result = cdSound.getSubSound(trackNumber, ref sound2);
                    }
                    ERRCHECK(result);
                }

                cdSoundDriveLetter = cdDrive;
            }
            else
            {
                if (currentSoundIndex == 0)
                {
                    result = system.createStream(filename, (FMOD.MODE._2D | FMOD.MODE.HARDWARE), ref sound1);
                }
                else
                {
                    result = system.createStream(filename, (FMOD.MODE._2D | FMOD.MODE.HARDWARE), ref sound2);
                }
            }
            ERRCHECK(result);

            if (result == FMOD.RESULT.OK)
            {
                if (currentSoundIndex == 0)
                {
                    system.playSound(FMOD.CHANNELINDEX.FREE, currentSound, false, ref channel1);
                }
                else
                {
                    system.playSound(FMOD.CHANNELINDEX.FREE, currentSound, false, ref channel2);
                }

                // Hiermit wird der neu spielende Track "stumm" geschaltet.
                IsMuted = IsMuted;

                // Aktuelle Lautstärke setzen
                Volume = Volume;

                /*string str = string.Format("Detecting BPM...");
                 * Big3.Hitbase.SharedResources.HitbaseCommands.SetMainStatusText.Execute(str, System.Windows.Application.Current.MainWindow);
                 *
                 * BackgroundWorker bw = new BackgroundWorker();
                 * bw.DoWork += delegate
                 * {
                 *  float bpm = BPMDetection(filename);
                 *  CurrentTrackBPM = (int)(bpm + 0.5);         // Runden
                 * };
                 * bw.RunWorkerCompleted += delegate
                 * {
                 *  string bpmDetected = string.Format("BPM: {0}", CurrentTrackBPM);
                 *  Big3.Hitbase.SharedResources.HitbaseCommands.SetMainStatusText.Execute(bpmDetected, System.Windows.Application.Current.MainWindow);
                 * };
                 * bw.RunWorkerAsync();*/
            }
        }
Example #3
0
        public void Stop()
        {
            if (mciCDEngine != null)
            {
                mciCDEngine.Stop();
                mciCDEngine.Close();
                mciCDEngine = null;
            }

            if (currentChannel != null)
            {
                currentChannel.stop();

                if (currentSoundIndex == 0)
                {
                    channel1 = null;
                }
                else
                {
                    channel2 = null;
                }
            }

            // Bei einer CD den cdSound offen lassen, damit das wechseln zwischen subTracks schneller geht.
            if (cdSound == null)
            {
                if (currentSound != null)
                {
                    currentSound.release();
                    if (currentSoundIndex == 0)
                    {
                        sound1 = null;
                    }
                    else
                    {
                        sound2 = null;
                    }
                }
            }

            /* Aktuell keinen PlayCounter schreiben, das die ID3-Routinen Buggy sind!!
             * for (int i = PlayCountFileList.Count - 1; i >= 0;i-- )
             * {
             *   try
             *   {
             *       FileStream fs = File.OpenWrite(PlayCountFileList[i]);
             *       fs.Close();
             *
             *       SoundFileInformation sfi = SoundFileInformation.GetSoundFileInformation(PlayCountFileList[i]);
             *
             *       sfi.PlayCount++;
             *
             *       SoundFileInformation.WriteMP3Tags(sfi, Field.TrackPlayCount);
             *
             *       PlayCountFileList.RemoveAt(i);
             *   }
             *   catch
             *   {
             *
             *   }
             * }*/
        }