///////////////////////////////////////////////////////////
//
//  DEFINITION
//
//  CONTEXT: Genesis3D lightweight framework
//  MODULE:	 general MCI player, here just used for MIDI
//  PREREQ:	 mainviewcontroller.h
//  FILE:	 mci.h
//	AUTHOR:  Klaus Zerbe <klaus@zerbe.com>
//  ORIGIN:  http://klaus.zerbe.com
//  VERSION: 1.0
//  DATE:    3.2.1999
//  PURPOSE: play music and maybe larger WAVE files or CD-audio
//           can be easily extended for playing videos etc.
//
///////////////////////////////////////////////////////////

#ifndef __MCI__
#define __MCI__

// encapsulate the windows MCI functions
//
class CMCI_Player {
public:
	// player state
	enum State { stopped, pausing, playing, ready };
	CMCI_Player();
	~CMCI_Player();
	// support a MIDI player singleton
	static CMCI_Player* GetMidiPlayer();
	// open file pFileName to play
	void Open(LPSTR pFileName);
	// start playing once or continous
	void Play(bool bContinous= false);
	// stop playing / device
	void Stop();
	// close played file / playing device
	void Close();
	// get file duration in milliseconds
	DWORD GetDuration();
	// set playing start/end position in milliseconds
	void SetPosition(DWORD dwFrom=0, DWORD dwTo=0) {
		m_dwFrom= dwFrom; m_dwTo= dwTo; }
	// pause player 
	void Pause();
	// return player state
    State GetState() { return state; }
private:
	// notification callback on end of file
	void Notify(WORD wFlags);
	static bool bWndClassRegistered; // MCI window class registered?
	static CMCI_Player* m_pMidiPlayer; // MIDI player singleton instance
	// window function used for notification on end of file or error
	friend long CALLBACK MciWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
	State state; // player state
	HWND m_hWnd; // callback window handle
	DWORD m_deviceID, m_dwFrom, m_dwTo; // device id and sequence to play
	WORD m_wNotification; // notification code
	bool m_bContinous, m_bEnabled; // continous play/play enabled flags
	LPSTR m_pPlayItem; // play file name
};


#endif

