Visual Studio .NET 2002Visual Studio 6Visual C++ 7.0Windows 2000Visual C++ 6.0Windows XPMFCIntermediateDevVisual StudioWindowsC++
MCI CD Player






3.55/5 (18 votes)
Jan 24, 2003

113363

2801
An article about Media Control Interface (MCI)
Introduction
This project explores the Microsoft Media Control Interface (MCI). I wrote a wrapper for MCI CD Audio commands. The class wrapper was named CCDAudio
.
Details
The CCDAudio
class declaration is:
//======================================================================== // A class wrapper of MCI API functions //======================================================================== class CCDAudio { public: // constructor CCDAudio(); // destructor virtual ~CCDAudio(); // Start playing CD Audio MCIERROR Play(); // Start playing CD Audio on given position MCIERROR Play(const int nPos); // Stop playing CD Audio MCIERROR Stop(); // Pause playing CD Audio MCIERROR Pause(); // Move to the next track MCIERROR Forward(); // Move to the previous track MCIERROR Backward(); // Eject the CDROM void EjectCDROM(); // Return the current position in seconds int GetCurrentPos(); // Return the current track number int GetCurrentTrack(); // Return length of all track in seconds int GetLenghtAllTracks(); // Return total tracks count int GetTracksCount(); // Return length of given track int GetTrackLength(const int nTrack); // Return begin time of given track int GetTrackBeginTime( const int nTrack ); // check wheter CD media is inserted bool IsMediaInsert(); // is paused mode bool IsPaused(); // is stopped mode bool IsStopped(); // the device is ready bool IsReady(); // is playing mode bool IsPlaying(); protected: // MCI error code MCIERROR m_nErrorCode; protected: // handle MCI errors inline void MCIError( MCIERROR MCIError ); };All of the functions are divided into three groups:
- Manage functions.
- Time and position functions.
- Status functions.
Use of CCDAudio
- First you should create an instance of this class:
protected: CCDAudio m_CDAudio;
- For starting to play the tracks:
m_CDAudio.Play();
- To pause playing:
m_CDAudio.Pause();
- To stop playing:
m_CDAudio.Stop();
- Move to the previous track:
m_CDAudio.Backward();
- Move to the next track:
m_CDAudio.Forward();
- Eject/Close CD ROM:
m_CDAudio.EjectCDROM();
- Play from begining of the selected track:
m_CDAudio.Play( m_CDAudio.GetTrackBeginTime( nTrack ) );
That is all. I hope this class will be useful.