///////////////////////////////////////////////////////////////////////
//Media.h: interface for the CMedia class.
//
//Version:
// 1.4.3
//Date:
// 2007.07.19
//////////////////////////////////////////////////////////////////////
#ifndef MEDIA_H
#define MEDIA_H
#include <mmsystem.h>
#include <streams.h>
//--------------------------------------------------------------------
//Macro define
//The volume value
#define MAX_VOLUME 0
#define MIN_VOLUME -10000
//The balance value
#define MAX_BALANCE 10000
#define MIN_BALANCE -10000
//The flag means that the area is the whole window
const RECT RC_WHOLE_WINDOWN_AREA = {0,0,0,0};
//--------------------------------------------------------------------
//Enum value
enum DISPLAYMODE
{
//Fit to the play window size. How wide (height) the window is, how
//is the move. Keep aspect ratio.
DISP_FIT,
//Not support.Stretch to the play window size. Don't keep the aspect ratio.
DISP_STRETCH,
//Full screen play.
DISP_FULLSCREEN,
//When the size of video is smaller than the play window, it displayes
//as the video size. If it's bigger , it just like the DISP_FIT mode.
DISP_NATIVE
};
//--------------------------------------------------------------------
//The media file property
typedef struct
{
//The volume range is –10,000 to 0.
//Divide by 100 to get equivalent decibel value (for example –10,000 = –100 dB).
LONG lVolume;
//The value from –10,000 to 10,000 indicating the stereo balance
//As with the Volume property, units correspond to .01 decibels (multiplied by –1 when plBalance is a positive value).
//For example, a value of 1000 indicates –10 dB on the right channel and –90 dB on the left channel.
LONG lBalance;
//Width of the video
LONG lWidth;
//Height of the video
LONG lHeight;
//Approximate bit rate
LONG lBitRate;
//The length of time that the media stream will play.
//The duration assumes normal playback speed, and it is therefore unaffected by the rate
LONGLONG llDuration;
//Earliest time that can be efficiently seeked to.
LONGLONG llAvailableEarliest;
//Latest time that can be efficiently seeked to
LONGLONG llAvailableLatest;
}MEDIAPROPERTY,*PMEDIAPROPERTY;
//--------------------------------------------------------------------
class CMedia
{
public:
DISPLAYMODE GetDisplayMode();
BOOL SetPositionCurrent(LONGLONG llPos);
BOOL GetPositionCurrent(LONGLONG *pllPos);
BOOL GetRate(double *pdRate);
BOOL SetRate(double dRate);
BOOL GetEvent(LONG *plEvCode, LONG *plParam1, LONG *plParam2);
BOOL SetNotifyWindow(HWND hWnd, UINT wMsg,long lInstanceData);
BOOL SetVolume(LONG lVolume, LONG lBalance = 0);
BOOL SetDisplayMode(DISPLAYMODE mode);
BOOL GetMediaProperty(PMEDIAPROPERTY pOutProperty);
static CMedia * GetInstance();
void Close();
BOOL CheckVisibility();
BOOL SetVideoWindow(HWND hWndVideo,const RECT &rcDisp = RC_WHOLE_WINDOWN_AREA);
BOOL Open(const TCHAR *pcszFileName);
BOOL Stop();
BOOL Pause();
BOOL Play();
virtual ~CMedia();
protected:
CMedia();
// Collection of interfaces
IGraphBuilder *m_pGB;
IMediaControl *m_pMC;
IMediaEventEx *m_pME;
IVideoWindow *m_pVW;
IBasicAudio *m_pBA;
IBasicVideo *m_pBV;
IMediaSeeking *m_pMS;
TCHAR m_szFileName[MAX_PATH];
HWND m_hWndVideo; //The window play video
HWND m_hWndNotify; //The window notify
BOOL m_bExitThrd;
BOOL m_bThrdRunning;
static CMedia * m_pInstance;
DISPLAYMODE m_DispMode;
DWORD m_dwCapability;
RECT m_rcDisp;
};
#endif //#ifndef MEDIA_H