Introduction
EY player is a Mp3, Wave, Mpg, Avi file player with capability to apply multiple special
effects (like recode, Play, increase- decrease speed, increase- decrease volume, change skin,
Zoom in, Zoom out, full screen, notify icon ...) on the media stream in run time using API,
It can manage surround systems by changing sound media place in surround environment and has a highly customizable skinning interface.
Media Control Interface
The Media Control Interface (MCI) provides standard commands for playing multimedia devices and recording multimedia resource files. These commands are a generic interface to nearly every kind of multimedia device.
Instructions
Can be use help.
Using the code
some class's
CCode_MCI
This header code file have control of Ey media Player ...
class CCode_MCI : public CWnd
{
public:
CCode_MCI();
CCode_MCI(HWND hwParent);
virtual ~CCode_MCI();
public:
HWND hwndParent;
public:
void OnView(int zoom);
void CombineWave(CString Path1,CString Path2);
void CutTo(unsigned to,unsigned from,CString &SavePath);
void PrepareWave(CString &Path);
void OnMuteCancel();
void OnMuteOK();
void OnFileInsert();
void OnFileEject();
void OnToolsSpeedDecrease();
void OnToolsSpeedIncrease();
long lPos;
void Rwd();
void Fwd();
void DecreaseVolume();
void IncreaseVolume();
DWORD lVolume;
long GetLength();
long GetPosition();
void SetPosition(long lPos);
HWND GetWindowHandle();
void Resume();
void Kill();
void Break();
void Loop();
void Close();
HWND Initialize();
void Play();
void Stop();
void Pause();
long GetMode();
CString GetPath();
void SetPath(CString sPath);
void SetParent(HWND hParent);
HWND GetParent();
void * m_buffer;
void SetVolume(DWORD dwVolume);
DWORD GetVolume();
protected:
HWND c_Player;
CEvent m_Event;
CString m_sPath;
afx_msg void OnDestroy();
DECLARE_MESSAGE_MAP()
private:
WAVEFORMATEX m_pcmWaveFormat;
WAVEFORMATEX m_pcmWaveFormat1;
WAVEFORMATEX m_pcmWaveFormat2;
void * m_buffer1;
void * m_buffer2;
DWORD m_dwNum;
DWORD m_dwNum1;
DWORD m_dwNum2;
};
class CParams
{
public:
CParams() {};
virtual ~CParams() {};
CWnd* pWnd;
HWND hWnd;
CEvent* pEvent;
};
CEYPlayerDlg
class file to main dilalog, write some most important function's, how open file by folder, skin browser..
void CEYPlayerDlg::OnOpenFolder()
{
ofstream output("C:/CurrentMusic.txt",ios::app);
BROWSEINFO brow;
LPITEMIDLIST path;
ZeroMemory(&brow,sizeof(brow));
brow.hwndOwner=m_hWnd;
brow.pszDisplayName=0;
brow.lpszTitle="Welcome to EY Player Select You List";
brow.ulFlags=BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;
TCHAR Display[MAX_PATH];
path=SHBrowseForFolder(&brow);
if (path)
SHGetPathFromIDList(path,Display);
LPCTSTR pstr=Display;
CFileFind finder;
CString strWildcard(pstr);
strWildcard += _T("\\*.*");
BOOL bWorking = finder.FindFile(strWildcard);
while (bWorking)
{
bWorking = finder.FindNextFile();
if (finder.IsDots())
continue;
LPTSTR nume;
CString nu=finder.GetFilePath();
nume=nu.GetBuffer(sizeof(nu));
if (finder.IsDirectory())
{
}
else
{
char ext[100];
strcpy(ext,PathFindExtension(nume));
char name[1024];
strcpy(name,PathFindFileName(nume));
name[strlen(name)-strlen(ext)]='\0';
if (
(strcmp(ext,".wav")==0)||
(strcmp(ext,".mp3")==0)||
(strcmp(ext,".mpg")==0)||
(strcmp(ext,".avi")==0)
)
{
strcpy(songs[id].name,name);
strcpy(songs[id].path,nume);
char ch[10];
if(songs[id].name!=NULL )
{
m_MusicName.SetTextMatrix(Index+1,1,songs[id].name);
m_MusicName.SetTextMatrix(Index+1,0,itoa(Index+1,ch,10));
Files[Index]=nume;
Index++;
}
m_MusicName.SetRows(Index+2);
CString repPath=nume;
repPath.Replace(92,'/');
repPath.Replace(32,'%');
output<<static_cast<string>(repPath)<<"\n";
}
}
if (finder.IsDirectory())
{
CString str = finder.GetFilePath();
}
}
finder.Close();
}
void CEYPlayerDlg::OnSkinbrowser()
{
CFileDialog sk(TRUE,NULL,NULL, OFN_HIDEREADONLY,"SKIN Files (*.skin)|*.skin|");
if(sk.DoModal() == IDOK)
{
m_Path = sk.GetPathName();
SetSkin(m_Path,m_Path.GetLength(),10);
if((isMPEG() ||isAVI())&&m_bPlay)
{
CRgn a,b;
CRect rect;
::GetWindowRect(m_hWnd,rect);
::SetWindowPos(m_hWnd,NULL,rect.left,rect.top,m_skin.iWidth+200,m_skin.iHeight+m_skin.iWidth,SWP_NOZORDER);
::ShowWindow(mci.GetWindowHandle(),SW_MAXIMIZE);
}
}
}
CFindEdit
Function's to update your current play list
void CFindEdit::OnAddItemes()
{
ofstream output("C:/CurrentMusic.txt",ios::app);
CFileDialog openMusic(TRUE,NULL,NULL,OFN_ALLOWMULTISELECT | OFN_HIDEREADONLY,"mp3 (*.mp3)|*.mp3|mpg (*.mpg)|*.mpg|wav (*.wav)|*.wav|avi (*.avi)|*.avi||");
if(openMusic.DoModal() == IDOK)
{
currPos = openMusic.GetStartPosition();
while(currPos != NULL)
{
m_Path = openMusic.GetNextPathName(currPos);
Files[indexfound]=m_Path;
CString setPath=Files[indexfound];
setPath.Replace(32,'%');
setPath.Replace(92,'/');
output<<static_cast<string> (setPath)<<"\n";
m_Edit.AddString(Files[indexfound]);
indexfound++;
}
}
}
void CFindEdit::OnSelchangeList1()
{
UpdateData(true);
m_Edit.GetText(m_Edit.GetCurSel(),m_Search);
UpdateData(false);
}
void CFindEdit::OnRemove()
{
for(int del=indexfound-m_Edit.GetCurSel()-1 ; del < indexfound ; del++ )
Files[del]=Files[del+1];
indexfound--;
m_Edit.DeleteString(m_Edit.GetCurSel());
}
CFullScreen
BOOL CFullScreen::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message==WM_KEYDOWN)
{
if(pMsg->wParam=='F'&&!bReturn)
{
long pos;
pos=mci.GetPosition();
mci.Pause();
mci.Initialize();
::SetWindowPos(m_hWnd, HWND_TOPMOST,-2,-30,cx+4,cy+31, SWP_NOZORDER);
::ShowWindow(mci.GetWindowHandle(),SW_MAXIMIZE);
mci.SetPosition(pos);
mci.Play();
bReturn=true;
}
if(pMsg->wParam==38)
OnVolumeIncrease();
if(pMsg->wParam==40)
OnVolumeDecrease();
if(pMsg->wParam==39)
OnPlaybackSpeed();
if(pMsg->wParam==37)
OnPlaybackSlow();
if(pMsg->wParam==83)
OnPlaybackStop();
if(pMsg->wParam==78)
OnPlaybackNext();
if(pMsg->wParam==80)
OnPlaybackPlay();
if(pMsg->wParam==77)
OnVolumeMute();
if(pMsg->wParam==107)
{
CRect rect;
::GetWindowRect(m_hWnd,rect);
CRect rect1;
if(rect.bottom-rect.top < cy + 30 && !bReturn)
{
iH+=10;
iW+=(w*10)/h;
::SetWindowPos(m_hWnd,NULL,rect.left,rect.top,iW+2,iH+30,SWP_NOZORDER);
::GetWindowRect(m_hWnd,rect1);
}
if(rect1.bottom-rect1.top>=cy+30&&!bReturn)
{
long pos;
pos=mci.GetPosition();
mci.Pause();
mci.Initialize();
::SetWindowPos(m_hWnd, HWND_TOPMOST,-2,-30,cx+4,cy+31, SWP_NOZORDER);
::ShowWindow(mci.GetWindowHandle(),SW_MAXIMIZE);
mci.SetPosition(pos);
mci.Play();
bReturn=true;
}
else if(!bReturn)
mci.OnView(((iW*100)/w));
}
if(pMsg->wParam==109)
{
if(bReturn)
{
bReturn=false;
::SetWindowPos(m_hWnd,NULL,0,0,(w*cy)/h+2,cy+30,NULL);
iH=cy;
iW=(w*cy)/h;
}
m_zoom-=1;
CRect rect;
CRect rect1;
::GetWindowRect(m_hWnd,rect);
if(rect.bottom-rect.top>h+30)
{
iH-=10;
iW-=(w*10)/h;
::SetWindowPos(m_hWnd,NULL,rect.left,rect.top,iW+2,iH+30,NULL);
::GetWindowRect(m_hWnd,rect1);
}
if(rect1.bottom-rect1.top<h+30)
{
::SetWindowPos(m_hWnd,NULL,rect.left,rect.top,w+2,h+30,SWP_NOZORDER);
iH=h;
iW=w;
}
else if(!bReturn)
mci.OnView((iW*100/w));
}
}
return CDialog::PreTranslateMessage(pMsg);
}
void CFullScreen::OnVolumeIncrease()
{
lVol=mci.GetVolume();
lVol+=10000;
mci.SetVolume(lVol);
}
void CFullScreen::OnVolumeDecrease()
{
if( lVol > 5000)
{
lVol=mci.GetVolume();
lVol-=5000;
mci.SetVolume((lVol<1?0:lVol));
}
}
BOOL findMute1=true;
void CFullScreen::OnVolumeMute()
{
if(findMute1==true)
{
mci.OnMuteOK();
findMute1=false;
}
else
{
mci.OnMuteCancel();
findMute1=true;
}
}
void CFullScreen::OnPlaybackSpeed()
{
mci.OnToolsSpeedIncrease();
}
void CFullScreen::OnPlaybackSlow()
{
mci.OnToolsSpeedDecrease();
}
void CFullScreen::OnPlaybackPause()
{
mci.Pause();
KillTimer(ID_PLAY_SLIDER);
}
void CFullScreen::OnPlaybackStop()
{
mci.Stop();
KillTimer(ID_PLAY_SLIDER);
}
void CFullScreen::OnPlaybackPlay()
{
mci.Play();
}
void CFullScreen::OnPlaybackNext()
{
CEYPlayerDlg m_CEYPlayerDlg;
MessageBox(m_CEYPlayerDlg.Files[fullIndex++]);
mci.Stop();
mci.SetPath(m_CEYPlayerDlg.Files[fullIndex++]);
mci.Play();
::ShowWindow(mci.GetWindowHandle(),SW_MAXIMIZE);
}
BOOL CFullScreen::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
if(zDelta<0)
{
CRect rect;
::GetWindowRect(m_hWnd,rect);
CRect rect1;
if(rect.bottom-rect.top < cy + 30 && !bReturn)
{
iH+=10;
iW+=(w*10)/h;
::SetWindowPos(m_hWnd,NULL,rect.left,rect.top,iW+2,iH+30,SWP_NOZORDER);
::GetWindowRect(m_hWnd,rect1);
}
if(rect1.bottom-rect1.top >= cy + 30 && !breturn)
{
long pos;
pos=mci.GetPosition();
mci.Pause();
mci.Initialize();
::SetWindowPos(m_hWnd, HWND_TOPMOST,-2,-30,cx+4,cy+31, SWP_NOZORDER);
::ShowWindow(mci.GetWindowHandle(),SW_MAXIMIZE);
mci.SetPosition(pos);
mci.Play();
bReturn=true;
}
else if(!bReturn)
mci.OnView((iW*100)/w);
}
else
{
if(bReturn)
{
bReturn=false;
::SetWindowPos(m_hWnd,NULL,0,0,(w*cy)/h+2,cy+30,NULL);
iH=cy;
iW=(w*cy)/h;
}
m_zoom-=1;
CRect rect;
CRect rect1;
::GetWindowRect(m_hWnd,rect);
if(rect.bottom-rect.top > h + 30 )
{
iH-=10;
iW-=(w*10)/h;
::SetWindowPos(m_hWnd,NULL,rect.left,rect.top,iW+2,iH+30,NULL);
::GetWindowRect(m_hWnd,rect1);
}
if(rect1.bottom-rect1.top < h + 30)
{
::SetWindowPos(m_hWnd,NULL,rect.left,rect.top,w+2,h+30,SWP_NOZORDER);
iH=h;
iW=w;
}
else if(!bReturn)
mci.OnView((iW*100/w));
}
return CDialog::OnMouseWheel(nFlags, zDelta, pt);
}
void CFullScreen::OnRButtonUp(UINT nFlags, CPoint point)
{
CDialog::OnRButtonUp(nFlags, point);
}
void CFullScreen::OnLButtonDown(Uint nFlags, CPoint point)
{
CDialog::OnLButtonDown(nFlags, point);
}
CSkin
class to change skin..
void CSkin::LoadSkin(CString path)
{
ifstream input(path,ios::in);
sFilePath=path;
char TestButton[6];
char TestSlider[6];
input>> sSkinPath ;
input>> sMainImage ;
input>> iWidth;
input>> iHeight;
input>> MainList ;
input>> iMainListWidth;
input>> iMainListHeight;
input>> bMainListDirection;
input>>TestButton;
input>> sPlay ;
input>> iPlayWidth;
input>> iPlayHeight;
input>> iPlayX;
input>> iPlayY;
input>> sStop ;
input>> iStopWidth;
input>> iStopHeight;
input>> iStopX;
input>> iStopY;
input>> sBack ;
input>> iBackWidth;
input>> iBackHeight;
input>> iBackX;
input>> iBackY;
input>> sBackword ;
input>> iBackwordWidth;
input>> iBackwordHeight;
input>> iBackwordX;
input>> iBackwordY;
input>> sCutfrom ;
input>> iCutfromWidth;
input>> iCutfromHeight;
input>> iCutfromX;
input>> iCutfromY;
input>> sCutto ;
input>> iCuttoWidth;
input>> iCuttoHeight;
input>> iCuttoX;
input>> iCuttoY;
input>> sExit ;
input>> iExitWidth;
input>> iExitHeight;
input>> iExitX;
input>> iExitY;
input>> sForword ;
input>> iForwordWidth;
input>> iForwprdHeight;
input>> iForwordX;
input>> iForwordY;
input>> sList ;
input>> iListWidth;
input>> iListHeight;
input>> iListX;
input>> iListY;
input>> sMinimize ;
input>> iMinimizeWidth;
input>> iMinimizeHeight;
input>> iMinimizeX;
input>> iMinimizeY;
input>> Next ;
input>> iNextWidth;
input>> iNextHeight;
input>> iNextX;
input>> iNextY;
input>> sRecord ;
input>> iRecordWidth;
input>> iRecordHeight;
input>> iRecordX;
input>> iRecordY;
input>> sFullScreen ;
input>> iFullScreenWidth;
input>> iFullScreenHeight;
input>> iFullScreenX;
input>> iFullScreenY;
input>> sSound ;
input>> iSoundWidth;
input>> iSoundHeight;
input>> iSoundX;
input>> iSoundY;
input>> sMenu ;
input>> iMenuWidth;
input>> iMenuHeight;
input>> iMenuX;
input>> iMenuY;
input>>TestSlider;
input>> sBalance ;
input>> iBalanceWidth;
input>> iBalanceHeight;
input>> iBalanceX;
input>> iBalanceY;
input>> iBalanceXStart;
input>> iBalanceXEnd;
input>> bBalanceDirection;
input>> sVolume ;
input>> iVolumeWidth;
input>> iVolumeHeight;
input>> iVolumeX;
input>> iVolumeY;
input>> iVolumeXStart;
input>> iVolumeXEnd;
input>> bVolumeDirection;
input>> sPlaySlider ;
input>> iPlaySliderWidth;
input>> iPlaySliderHeight;
input>> iPlaySliderX;
input>> iPlaySliderY;
input>> iPlaySliderXStart;
input>> iPlaySliderXEnd;
input>>bPlaySliderDirection;
}
CTaskBar
header file CTaskBar to create notfiy icon, Ey menu, Ey play list. in notfiy icon right click get "Ey menue", left click get "menu play list"
class CTaskBar : public CWnd
{
public:
int create ( CWnd* p, UINT message, LPCTSTR tip, HICON i ) ;
LRESULT onusermessage ( WPARAM w, LPARAM l ) ;
virtual LRESULT WindowProc ( UINT message, WPARAM w, LPARAM l ) ;
void remove( ) ;
void setdefault( ) ;
void seticon ( HICON h ) ;
int m_tIndex;
CString m_mPath[200];
private :
NOTIFYICONDATA m_nid ;
CMenu m_mymenu ;
CMenu m_mylist ;
DECLARE_MESSAGE_MAP()
};
CWave
class to wave operation combine to wave's, cut from, cut to, record sound from mic or sound card..
class CWave : public CObject
{
DECLARE_SERIAL(CWave)
public:
void SetBuffer(void* pBuffer, DWORD dwNumSamples, BOOL bCopy = false);
void Load(const CString& strFile);
void Save(const CString& strFile);
DWORD GetBufferLength() const;
DWORD GetNumSamples() const;
void* GetBuffer() const;
void Save(CFile* f);
void Load(CFile* f);
WAVEFORMATEX GetFormat() const;
void BuildFormat(WORD nChannels, DWORD nFrequency, WORD nBits);
CWave();
CWave(const CWave& copy);
CWave& operator=(const CWave& wave);
virtual ~CWave();
virtual void Serialize( CArchive& archive );
private:
CWaveBuffer m_buffer;
WAVEFORMATEX m_pcmWaveFormat;
};
CWaveBuffer
CWaveDevice
SONGINF
class's to wave operation combine to wave's, cut from, cut to, record sound from mic or sound card..
EY Media Player
After concluding that project, I decided to try writing a Media Player, and that'is it. Using potentials of CStatic control as a CWnd derived
class, I made a GUI for my wrapper class. I used a CStatic control to hold onto video media playback (if exist). This CStatic control rules as CEasyPlayer instance parent.
Changing approach this application did not used Loop() member function for continuous media playback. Instead a timer used to periodically check
if media stopped or not.
I must mention Ashraf Shaheen he Design the interface media player. Thank you very much Ashraf Shaheen.
This application is dedicated to my Yazan nemer & Emad ziad.
History
This application create in 2005, deployment in 2006.
Project Graduation from Al-zaytoonah university....