Click here to Skip to main content
Licence 
First Posted 23 Jan 2003
Views 81,847
Bookmarked 47 times

MCI CD Player

By | 23 Jan 2003 | Article
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

About the Author

Nikolai Serdiuk

Web Developer

Bulgaria Bulgaria

Member

I am a senior developer in Melon Technologies Ltd.
 


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionHow to eject Blank CDROM drive? Pinmemberreach2dpg18:11 1 Apr '06  
GeneralSmall Problem Pinmembergpsakhare21:03 30 Sep '05  
AnswerRe: Small Problem [modified] Pinmemberreach2dpg2:05 8 Sep '06  
GeneralBig prolem Pinmemberduc_nguyen20:28 14 Feb '05  
GeneralA little problem PinmemberTTT811:08 26 Jan '05  
GeneralRe: A little problem PinmemberWilliamZhou23:58 25 Feb '06  
Generalhi! have a error PinsussAnonymous16:05 17 Jan '05  
GeneralNo sound while playing... PinmemberAshokkumar21:19 22 May '03  
GeneralRe: No sound while playing... PinmemberNikolai Serdiuk21:26 26 May '03  
GeneralRe: No sound while playing... PinmemberHaiou14:00 10 Feb '06  
QuestionHow to choose the drive? PinmemberMiroslav Rajcic22:07 1 Feb '03  
AnswerRe: How to choose the drive? Pinmemberghori22:10 22 Apr '03  
AnswerRe: How to choose the drive? PinsussPaisano4:35 15 Jan '04  
AnswerRe: How to choose the drive? Pinmemberm.v.d.0:55 4 Mar '06  
GeneralYour code is nice and neat PinmemberMarc Clifton10:22 24 Jan '03  
Generalhmm... PinmemberNitron9:48 24 Jan '03  
GeneralRe: hmm... PinmemberLito14:18 28 Jan '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    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 | Mobile
Web04 | 2.5.120517.1 | Last Updated 24 Jan 2003
Article Copyright 2003 by Nikolai Serdiuk
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid