Click here to Skip to main content
12,813,626 members (31,834 online)
Click here to Skip to main content
Add your own
alternative version


47 bookmarked
Posted 23 Jan 2003

MCI CD Player

, 23 Jan 2003
Rate this:
Please Sign up or sign in to vote.
An article about Media Control Interface (MCI)

Sample Image - cdplayer.png


This project explores the Microsoft Media Control Interface (MCI). I wrote a wrapper for MCI CD Audio commands. The class wrapper was named CCDAudio.


The CCDAudio class declaration is:

// A class wrapper of MCI API functions
class CCDAudio
// constructor
// destructor
virtual ~CCDAudio();

// Start playing CD Audio
// Start playing CD Audio on given position
MCIERROR Play(const int nPos);
// Stop playing CD Audio
// Pause playing CD Audio
// 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();

    // MCI error code
    MCIERROR m_nErrorCode;

    // handle MCI errors
    inline void MCIError( MCIERROR MCIError );
All of the functions are divided into three groups:
  1. Manage functions.
  2. Time and position functions.
  3. Status functions.
Note: The time is represented in seconds.

Use of CCDAudio

  1. First you should create an instance of this class:
        CCDAudio m_CDAudio;
  2. For starting to play the tracks:
  3. To pause playing:
  4. To stop playing:
  5. Move to the previous track:
  6. Move to the next track:
  7. Eject/Close CD ROM:
  8. Play from begining of the selected track:
    m_CDAudio.Play( m_CDAudio.GetTrackBeginTime( nTrack ) );

That is all. I hope this class will be useful.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Nikolai Serdiuk
Web Developer
Bulgaria Bulgaria
I am a senior developer in <a href=>Melon Technologies Ltd.

You may also be interested in...

Comments and Discussions

QuestionExcellent work Pin
nebojsa_j23-Apr-14 8:29
membernebojsa_j23-Apr-14 8:29 
QuestionHow to eject Blank CDROM drive? Pin
reach2dpg1-Apr-06 19:11
memberreach2dpg1-Apr-06 19:11 
GeneralSmall Problem Pin
gpsakhare30-Sep-05 22:03
membergpsakhare30-Sep-05 22:03 
AnswerRe: Small Problem [modified] Pin
reach2dpg8-Sep-06 3:05
memberreach2dpg8-Sep-06 3:05 
GeneralBig prolem Pin
duc_nguyen14-Feb-05 21:28
memberduc_nguyen14-Feb-05 21:28 
GeneralA little problem Pin
TTT8126-Jan-05 2:08
memberTTT8126-Jan-05 2:08 
GeneralRe: A little problem Pin
WilliamZhou26-Feb-06 0:58
memberWilliamZhou26-Feb-06 0:58 
Generalhi! have a error Pin
Anonymous17-Jan-05 17:05
sussAnonymous17-Jan-05 17:05 
GeneralNo sound while playing... Pin
Ashokkumar22-May-03 22:19
memberAshokkumar22-May-03 22:19 
GeneralRe: No sound while playing... Pin
Nikolai Serdiuk26-May-03 22:26
memberNikolai Serdiuk26-May-03 22:26 
GeneralRe: No sound while playing... Pin
Haiou10-Feb-06 15:00
memberHaiou10-Feb-06 15:00 
QuestionHow to choose the drive? Pin
Miroslav Rajcic1-Feb-03 23:07
memberMiroslav Rajcic1-Feb-03 23:07 
AnswerRe: How to choose the drive? Pin
ghori22-Apr-03 23:10
memberghori22-Apr-03 23:10 
AnswerRe: How to choose the drive? Pin
Paisano15-Jan-04 5:35
sussPaisano15-Jan-04 5:35 
AnswerRe: How to choose the drive? Pin
m.v.d.4-Mar-06 1:55
memberm.v.d.4-Mar-06 1:55 
GeneralYour code is nice and neat Pin
Marc Clifton24-Jan-03 11:22
memberMarc Clifton24-Jan-03 11:22 
Generalhmm... Pin
Nitron24-Jan-03 10:48
memberNitron24-Jan-03 10:48 
GeneralRe: hmm... Pin
Lito28-Jan-03 15:18
memberLito28-Jan-03 15:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170308.1 | Last Updated 24 Jan 2003
Article Copyright 2003 by Nikolai Serdiuk
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid