Click here to Skip to main content
12,241,564 members (50,536 online)
Click here to Skip to main content
Add your own
alternative version

Stats

93.1K views
2.4K downloads
47 bookmarked
Posted

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

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:
  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:
    protected:
        CCDAudio m_CDAudio;
  2. For starting to play the tracks:
    m_CDAudio.Play();
  3. To pause playing:
    m_CDAudio.Pause();
  4. To stop playing:
    m_CDAudio.Stop();
  5. Move to the previous track:
    m_CDAudio.Backward();
  6. Move to the next track:
    m_CDAudio.Forward();
  7. Eject/Close CD ROM:
    m_CDAudio.EjectCDROM();
  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.

License

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

Share

About the Author

Nikolai Serdiuk
Web Developer
Bulgaria Bulgaria
I am a senior developer in 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.

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