- Add simple multimedia player
svn path=/trunk/; revision=39947
|
@ -34,6 +34,9 @@
|
|||
<directory name="logoff">
|
||||
<xi:include href="logoff/logoff.rbuild" />
|
||||
</directory>
|
||||
<directory name="mplay32">
|
||||
<xi:include href="mplay32/mplay32.rbuild" />
|
||||
</directory>
|
||||
<directory name="msconfig">
|
||||
<xi:include href="msconfig/msconfig.rbuild" />
|
||||
</directory>
|
||||
|
|
29
reactos/base/applications/mplay32/lang/en-US.rc
Normal file
|
@ -0,0 +1,29 @@
|
|||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
IDR_MAINMENU MENU
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&Open...", IDM_OPEN_FILE
|
||||
MENUITEM "&Close", IDM_CLOSE_FILE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&Exit", IDM_EXIT
|
||||
END
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "&About...", IDM_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_ALL_TYPES_FILTER "All Supported (*.wav, *.cda, *.midi, *.mid, *.avi)\0*.wav;*.cda;*.midi;*.mid;*.avi\0"
|
||||
IDS_TOOLTIP_PLAY "Play"
|
||||
IDS_TOOLTIP_STOP "Stop"
|
||||
IDS_TOOLTIP_EJECT "Eject"
|
||||
IDS_TOOLTIP_BACKWARD "Skip Backward"
|
||||
IDS_TOOLTIP_SEEKBACK "Seek Backward"
|
||||
IDS_TOOLTIP_SEEKFORW "Seek Forward"
|
||||
IDS_TOOLTIP_FORWARD "Skip Forward"
|
||||
IDS_APPTITLE "ReactOS Multimedia Player"
|
||||
END
|
700
reactos/base/applications/mplay32/mplay32.c
Normal file
|
@ -0,0 +1,700 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Multimedia Player
|
||||
* FILE: base\applications\mplay32\mplay32.c
|
||||
* PROGRAMMERS: Dmitry Chapyshev (dmitry@reactos.org)
|
||||
*/
|
||||
|
||||
#include "mplay32.h"
|
||||
|
||||
#define MAIN_WINDOW_HEIGHT 125
|
||||
#define MAIN_WINDOW_MIN_WIDTH 250
|
||||
|
||||
HINSTANCE hInstance = NULL;
|
||||
HWND hTrackBar = NULL;
|
||||
HWND hToolBar = NULL;
|
||||
TCHAR szAppTitle[256] = _T("");
|
||||
TCHAR szPrevFile[MAX_PATH] = _T("\0");
|
||||
WORD wDeviceId;
|
||||
BOOL bIsOpened = FALSE;
|
||||
BOOL bIsPaused = FALSE;
|
||||
UINT MaxFilePos = 0;
|
||||
|
||||
/* Known types table */
|
||||
static const TYPEBYEXT ExtTypes[] =
|
||||
{
|
||||
{ _T(".wav"), WAVE_FILE },
|
||||
{ _T(".wave"), WAVE_FILE },
|
||||
{ _T(".mid"), MIDI_FILE },
|
||||
{ _T(".midi"), MIDI_FILE },
|
||||
{ _T(".cda"), AUDIOCD_FILE },
|
||||
{ _T(".avi"), AVI_FILE },
|
||||
{ _T("\0"), 0 }
|
||||
};
|
||||
|
||||
/* ToolBar Buttons */
|
||||
static const TBBUTTON Buttons[] =
|
||||
{ /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
|
||||
{TBICON_PLAY, IDC_PLAY, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
||||
{TBICON_STOP, IDC_STOP, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
||||
{TBICON_EJECT, IDC_EJECT, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
||||
{15, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},
|
||||
{TBICON_BACKWARD, IDC_BACKWARD, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
||||
{TBICON_SEEKBACK, IDC_SEEKBACK, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
||||
{TBICON_SEEKFORW, IDC_SEEKFORW, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
|
||||
{TBICON_FORWARD, IDC_FORWARD, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}
|
||||
};
|
||||
|
||||
static VOID
|
||||
SetImageList(HWND hwnd)
|
||||
{
|
||||
HIMAGELIST hImageList;
|
||||
|
||||
hImageList = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR24, 1, 1);
|
||||
|
||||
if (!hImageList)
|
||||
{
|
||||
MessageBox(hwnd, _T("ImageList it is not created!"), NULL, MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
ImageList_AddMasked(hImageList,
|
||||
LoadImage(hInstance, MAKEINTRESOURCE(IDB_PLAYICON), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR),
|
||||
RGB(255, 255, 255));
|
||||
|
||||
ImageList_AddMasked(hImageList,
|
||||
LoadImage(hInstance, MAKEINTRESOURCE(IDB_STOPICON), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR),
|
||||
RGB(255, 255, 255));
|
||||
|
||||
ImageList_AddMasked(hImageList,
|
||||
LoadImage(hInstance, MAKEINTRESOURCE(IDB_EJECTICON), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR),
|
||||
RGB(255, 255, 255));
|
||||
|
||||
ImageList_AddMasked(hImageList,
|
||||
LoadImage(hInstance, MAKEINTRESOURCE(IDB_BACKWARDICON), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR),
|
||||
RGB(255, 255, 255));
|
||||
|
||||
ImageList_AddMasked(hImageList,
|
||||
LoadImage(hInstance, MAKEINTRESOURCE(IDB_SEEKBACKICON), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR),
|
||||
RGB(255, 255, 255));
|
||||
|
||||
ImageList_AddMasked(hImageList,
|
||||
LoadImage(hInstance, MAKEINTRESOURCE(IDB_SEEKFORWICON), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR),
|
||||
RGB(255, 255, 255));
|
||||
|
||||
ImageList_AddMasked(hImageList,
|
||||
LoadImage(hInstance, MAKEINTRESOURCE(IDB_FORWARDICON), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR),
|
||||
RGB(255, 255, 255));
|
||||
|
||||
ImageList_Destroy((HIMAGELIST)SendMessage(hToolBar,
|
||||
TB_SETIMAGELIST,
|
||||
0,
|
||||
(LPARAM)hImageList));
|
||||
}
|
||||
|
||||
static VOID
|
||||
InitControls(HWND hwnd)
|
||||
{
|
||||
INT NumButtons = sizeof(Buttons) / sizeof(Buttons[0]);
|
||||
|
||||
InitCommonControls();
|
||||
|
||||
/* Create trackbar */
|
||||
hTrackBar = CreateWindowEx(0,
|
||||
TRACKBAR_CLASS,
|
||||
NULL,
|
||||
TBS_ENABLESELRANGE | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPSIBLINGS,
|
||||
0,
|
||||
0,
|
||||
340,
|
||||
30,
|
||||
hwnd,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
if (!hTrackBar)
|
||||
{
|
||||
MessageBox(hwnd, _T("TrackBar it is not created!"), NULL, MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create toolbar */
|
||||
hToolBar = CreateWindowEx(0,
|
||||
TOOLBARCLASSNAME,
|
||||
NULL,
|
||||
WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPSIBLINGS |
|
||||
TBSTYLE_FLAT | CCS_BOTTOM | TBSTYLE_TOOLTIPS,
|
||||
0,
|
||||
40,
|
||||
340,
|
||||
30,
|
||||
hwnd,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
if (!hToolBar)
|
||||
{
|
||||
MessageBox(hwnd, _T("ToolBar it is not created!"), NULL, MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
SetImageList(hwnd);
|
||||
SendMessage(hToolBar, TB_ADDBUTTONS, NumButtons, (LPARAM)Buttons);
|
||||
}
|
||||
|
||||
static UINT
|
||||
IsSupportedFileExtension(LPWSTR lpFileName)
|
||||
{
|
||||
TCHAR szExt[MAX_PATH];
|
||||
INT DotPos = 0, i, j;
|
||||
|
||||
for (i = _tcslen(lpFileName); i >= 0; --i)
|
||||
{
|
||||
if (lpFileName[i] == '.')
|
||||
{
|
||||
DotPos = _tcslen(lpFileName) - i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!DotPos) return UNSUPPORTED_FILE;
|
||||
|
||||
szExt[DotPos + 1] = _T('\0');
|
||||
for (i = _tcslen(lpFileName), j = DotPos; j >= 0; --i, --j)
|
||||
{
|
||||
szExt[j] = lpFileName[i];
|
||||
}
|
||||
|
||||
for (i = 0; ; i++)
|
||||
{
|
||||
if (ExtTypes[i].uType == UNSUPPORTED_FILE)
|
||||
{
|
||||
return UNSUPPORTED_FILE;
|
||||
}
|
||||
|
||||
if (_tcscmp(ExtTypes[i].szExt, szExt) == 0)
|
||||
{
|
||||
return ExtTypes[i].uType;
|
||||
}
|
||||
}
|
||||
|
||||
return UNSUPPORTED_FILE;
|
||||
}
|
||||
|
||||
static DWORD
|
||||
CloseMciDevice(VOID)
|
||||
{
|
||||
MCI_GENERIC_PARMS mciGeneric;
|
||||
DWORD dwError;
|
||||
|
||||
if (bIsOpened)
|
||||
{
|
||||
dwError = mciSendCommand(wDeviceId, MCI_CLOSE, MCI_WAIT, (DWORD)(LPMCI_GENERIC_PARMS)&mciGeneric);
|
||||
if (dwError) return dwError;
|
||||
bIsOpened = FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static DWORD
|
||||
OpenMciDevice(LPTSTR lpType, LPTSTR lpFileName)
|
||||
{
|
||||
MCI_STATUS_PARMS mciStatus;
|
||||
MCI_OPEN_PARMS mciOpen;
|
||||
DWORD dwError;
|
||||
|
||||
if (bIsOpened)
|
||||
{
|
||||
CloseMciDevice();
|
||||
}
|
||||
|
||||
mciOpen.lpstrDeviceType = lpType;
|
||||
mciOpen.lpstrElementName = lpFileName;
|
||||
mciOpen.dwCallback = 0;
|
||||
mciOpen.wDeviceID = 0;
|
||||
mciOpen.lpstrAlias = NULL;
|
||||
|
||||
dwError = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT | MCI_WAIT, (DWORD)(LPVOID)&mciOpen);
|
||||
if (dwError != 0)
|
||||
{
|
||||
MessageBox(0, _T("Can't open device! (1)"), NULL, MB_OK);
|
||||
return dwError;
|
||||
}
|
||||
|
||||
mciStatus.dwItem = MCI_STATUS_LENGTH;
|
||||
|
||||
dwError = mciSendCommand(mciOpen.wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD)(LPVOID)&mciStatus);
|
||||
if (dwError != 0)
|
||||
{
|
||||
MessageBox(0, _T("Can't open device! (2)"), NULL, MB_OK);
|
||||
return dwError;
|
||||
}
|
||||
|
||||
SendMessage(hTrackBar, TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG(1, mciStatus.dwReturn));
|
||||
SendMessage(hTrackBar, TBM_SETPAGESIZE, 0, 10);
|
||||
SendMessage(hTrackBar, TBM_SETLINESIZE, 0, 1);
|
||||
SendMessage(hTrackBar, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) 1);
|
||||
|
||||
if (mciStatus.dwReturn < 10000)
|
||||
{
|
||||
SendMessage(hTrackBar, TBM_SETTICFREQ, (WPARAM) 100, (LPARAM) 0);
|
||||
}
|
||||
else if (mciStatus.dwReturn < 100000)
|
||||
{
|
||||
SendMessage(hTrackBar, TBM_SETTICFREQ, (WPARAM) 1000, (LPARAM) 0);
|
||||
}
|
||||
else if (mciStatus.dwReturn < 1000000)
|
||||
{
|
||||
SendMessage(hTrackBar, TBM_SETTICFREQ, (WPARAM) 10000, (LPARAM) 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessage(hTrackBar, TBM_SETTICFREQ, (WPARAM) 100000, (LPARAM) 0);
|
||||
}
|
||||
|
||||
MaxFilePos = mciStatus.dwReturn;
|
||||
wDeviceId = mciOpen.wDeviceID;
|
||||
bIsOpened = TRUE;
|
||||
lstrcpy(szPrevFile, lpFileName);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static VOID
|
||||
StopPlayback(HWND hwnd)
|
||||
{
|
||||
if (bIsOpened)
|
||||
{
|
||||
SendMessage(hTrackBar, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) 1);
|
||||
KillTimer(hwnd, IDT_PLAYTIMER);
|
||||
CloseMciDevice();
|
||||
}
|
||||
}
|
||||
|
||||
static VOID
|
||||
SeekPlayback(HWND hwnd, DWORD dwNewPos)
|
||||
{
|
||||
MCI_SEEK_PARMS mciSeek;
|
||||
MCI_PLAY_PARMS mciPlay;
|
||||
DWORD dwError;
|
||||
|
||||
if (bIsOpened)
|
||||
{
|
||||
mciSeek.dwTo = dwNewPos;
|
||||
dwError = mciSendCommand(wDeviceId, MCI_SEEK, MCI_WAIT | MCI_TO, (DWORD)(LPVOID)&mciSeek);
|
||||
if (dwError != 0)
|
||||
{
|
||||
MessageBox(hwnd, _T("SeekPlayback: Can't seek!"), NULL, MB_OK);
|
||||
}
|
||||
|
||||
mciPlay.dwCallback = (DWORD)hwnd;
|
||||
dwError = mciSendCommand(wDeviceId, MCI_PLAY, MCI_NOTIFY, (DWORD)(LPVOID)&mciPlay);
|
||||
if (dwError != 0)
|
||||
{
|
||||
MessageBox(hwnd, _T("SeekPlayback: Can't play!"), NULL, MB_OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static VOID
|
||||
SeekBackPlayback(HWND hwnd)
|
||||
{
|
||||
MCI_STATUS_PARMS mciStatus;
|
||||
DWORD dwNewPos;
|
||||
|
||||
if (!bIsOpened) return;
|
||||
|
||||
mciStatus.dwItem = MCI_STATUS_POSITION;
|
||||
mciSendCommand(wDeviceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD)(LPVOID)&mciStatus);
|
||||
|
||||
dwNewPos = mciStatus.dwReturn - 1;
|
||||
|
||||
if((UINT)dwNewPos <= 1)
|
||||
{
|
||||
StopPlayback(hwnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
SeekPlayback(hwnd, dwNewPos);
|
||||
}
|
||||
}
|
||||
|
||||
static VOID
|
||||
SeekForwPlayback(HWND hwnd)
|
||||
{
|
||||
MCI_STATUS_PARMS mciStatus;
|
||||
DWORD dwNewPos;
|
||||
|
||||
if (!bIsOpened) return;
|
||||
|
||||
mciStatus.dwItem = MCI_STATUS_POSITION;
|
||||
mciSendCommand(wDeviceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD)(LPVOID)&mciStatus);
|
||||
|
||||
dwNewPos = mciStatus.dwReturn + 1;
|
||||
|
||||
if((UINT)dwNewPos >= MaxFilePos)
|
||||
{
|
||||
StopPlayback(hwnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
SeekPlayback(hwnd, dwNewPos);
|
||||
}
|
||||
}
|
||||
|
||||
static VOID
|
||||
PausePlayback(HWND hwnd)
|
||||
{
|
||||
MCI_GENERIC_PARMS mciGeneric;
|
||||
DWORD dwError;
|
||||
|
||||
if (bIsOpened)
|
||||
{
|
||||
dwError = mciSendCommand(wDeviceId, MCI_PAUSE, MCI_WAIT, (DWORD)(LPMCI_GENERIC_PARMS)&mciGeneric);
|
||||
if (dwError != 0)
|
||||
{
|
||||
MessageBox(hwnd, _T("Can't pause!"), NULL, MB_OK);
|
||||
}
|
||||
bIsPaused = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static VOID
|
||||
ResumePlayback(HWND hwnd)
|
||||
{
|
||||
MCI_GENERIC_PARMS mciGeneric;
|
||||
DWORD dwError;
|
||||
|
||||
if (bIsPaused)
|
||||
{
|
||||
dwError = mciSendCommand(wDeviceId, MCI_RESUME, MCI_WAIT, (DWORD)(LPMCI_GENERIC_PARMS)&mciGeneric);
|
||||
if (dwError != 0)
|
||||
{
|
||||
MessageBox(hwnd, _T("Can't resume!"), NULL, MB_OK);
|
||||
}
|
||||
bIsPaused = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
VOID CALLBACK
|
||||
PlayTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
|
||||
{
|
||||
MCI_STATUS_PARMS mciStatus;
|
||||
DWORD dwPos;
|
||||
|
||||
if (!bIsOpened) KillTimer(hwnd, IDT_PLAYTIMER);
|
||||
|
||||
mciStatus.dwItem = MCI_STATUS_POSITION;
|
||||
mciSendCommand(wDeviceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD)(LPVOID)&mciStatus);
|
||||
dwPos = mciStatus.dwReturn;
|
||||
|
||||
if((UINT)dwPos >= MaxFilePos)
|
||||
{
|
||||
StopPlayback(hwnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessage(hTrackBar, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) dwPos);
|
||||
}
|
||||
}
|
||||
|
||||
static VOID
|
||||
PlayFile(HWND hwnd, LPWSTR lpFileName)
|
||||
{
|
||||
MCI_PLAY_PARMS mciPlay;
|
||||
TCHAR szLocalFileName[MAX_PATH];
|
||||
UINT FileType;
|
||||
DWORD dwError;
|
||||
|
||||
if (lpFileName == NULL)
|
||||
{
|
||||
if (szPrevFile[0] == _T('\0'))
|
||||
return;
|
||||
|
||||
lstrcpy(szLocalFileName, szPrevFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
lstrcpy(szLocalFileName, lpFileName);
|
||||
}
|
||||
|
||||
if (GetFileAttributes(szLocalFileName) == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
MessageBox(hwnd, _T("Wrong path to a file!"), NULL, MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
FileType = IsSupportedFileExtension(szLocalFileName);
|
||||
|
||||
switch (FileType)
|
||||
{
|
||||
case UNSUPPORTED_FILE:
|
||||
MessageBox(hwnd, _T("Unsupported format!"), NULL, MB_OK);
|
||||
return;
|
||||
case WAVE_FILE:
|
||||
OpenMciDevice(_T("waveaudio"), szLocalFileName);
|
||||
break;
|
||||
case MIDI_FILE:
|
||||
OpenMciDevice(_T("sequencer"), szLocalFileName);
|
||||
break;
|
||||
case AUDIOCD_FILE:
|
||||
OpenMciDevice(_T("cdaudio"), szLocalFileName);
|
||||
break;
|
||||
case AVI_FILE:
|
||||
OpenMciDevice(_T("avivideo"), szLocalFileName);
|
||||
break;
|
||||
}
|
||||
|
||||
SetTimer(hwnd, IDT_PLAYTIMER, 100, (TIMERPROC) PlayTimerProc);
|
||||
|
||||
dwError = mciSendCommand(wDeviceId, MCI_SEEK, MCI_WAIT | MCI_SEEK_TO_START, 0);
|
||||
|
||||
mciPlay.dwCallback = (DWORD)hwnd;
|
||||
mciPlay.dwFrom = 0;
|
||||
mciPlay.dwTo = MaxFilePos;
|
||||
|
||||
dwError = mciSendCommand(wDeviceId, MCI_PLAY, MCI_NOTIFY | MCI_FROM | MCI_TO, (DWORD)(LPVOID)&mciPlay);
|
||||
if (dwError != 0)
|
||||
{
|
||||
MessageBox(hwnd, _T("Can't play!"), NULL, MB_OK);
|
||||
}
|
||||
}
|
||||
|
||||
static VOID
|
||||
OpenFileDialog(HWND hwnd)
|
||||
{
|
||||
OPENFILENAME OpenFileName;
|
||||
TCHAR szFile[MAX_PATH + 1] = _T("\0");
|
||||
TCHAR szFilter[MAX_PATH], szCurrentDir[MAX_PATH];
|
||||
|
||||
ZeroMemory(&OpenFileName, sizeof(OpenFileName));
|
||||
|
||||
LoadString(hInstance, IDS_ALL_TYPES_FILTER, szFilter, sizeof(szFilter) / sizeof(TCHAR));
|
||||
|
||||
if (!GetCurrentDirectory(sizeof(szCurrentDir) / sizeof(TCHAR), szCurrentDir))
|
||||
{
|
||||
lstrcpy(szCurrentDir, _T("c:\\"));
|
||||
}
|
||||
|
||||
OpenFileName.lStructSize = sizeof(OpenFileName);
|
||||
OpenFileName.hwndOwner = hwnd;
|
||||
OpenFileName.hInstance = hInstance;
|
||||
OpenFileName.lpstrFilter = szFilter;
|
||||
OpenFileName.lpstrFile = szFile;
|
||||
OpenFileName.nMaxFile = sizeof(szFile) / sizeof((szFile)[0]);
|
||||
OpenFileName.lpstrInitialDir = szCurrentDir;
|
||||
OpenFileName.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_SHAREAWARE;
|
||||
OpenFileName.lpstrDefExt = _T("\0");
|
||||
|
||||
if (GetOpenFileName(&OpenFileName))
|
||||
{
|
||||
PlayFile(hwnd, OpenFileName.lpstrFile);
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CALLBACK
|
||||
MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (Message)
|
||||
{
|
||||
case WM_CREATE:
|
||||
InitControls(hwnd);
|
||||
break;
|
||||
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
LPNMHDR pnmhdr = (LPNMHDR)lParam;
|
||||
|
||||
switch (pnmhdr->code)
|
||||
{
|
||||
case TTN_GETDISPINFO:
|
||||
{
|
||||
LPTOOLTIPTEXT lpttt = (LPTOOLTIPTEXT)lParam;
|
||||
UINT idButton = (UINT)lpttt->hdr.idFrom;
|
||||
|
||||
switch (idButton)
|
||||
{
|
||||
case IDC_PLAY:
|
||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PLAY);
|
||||
break;
|
||||
case IDC_STOP:
|
||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_STOP);
|
||||
break;
|
||||
case IDC_EJECT:
|
||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_EJECT);
|
||||
break;
|
||||
case IDC_BACKWARD:
|
||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_BACKWARD);
|
||||
break;
|
||||
case IDC_SEEKBACK:
|
||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SEEKBACK);
|
||||
break;
|
||||
case IDC_SEEKFORW:
|
||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SEEKFORW);
|
||||
break;
|
||||
case IDC_FORWARD:
|
||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_FORWARD);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SIZING:
|
||||
{
|
||||
LPRECT pRect = (LPRECT)lParam;
|
||||
|
||||
if (pRect->right - pRect->left < MAIN_WINDOW_MIN_WIDTH)
|
||||
pRect->right = pRect->left + MAIN_WINDOW_MIN_WIDTH;
|
||||
|
||||
if (pRect->bottom - pRect->top != MAIN_WINDOW_HEIGHT)
|
||||
pRect->bottom = pRect->top + MAIN_WINDOW_HEIGHT;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
RECT Rect;
|
||||
UINT Size;
|
||||
|
||||
if (hToolBar && hTrackBar)
|
||||
{
|
||||
SendMessage(hToolBar, TB_AUTOSIZE, 0, 0);
|
||||
SendMessage(hToolBar, TB_GETITEMRECT, 1, (LPARAM)&Rect);
|
||||
|
||||
Size = GetSystemMetrics(SM_CYMENU) + Rect.bottom;
|
||||
MoveWindow(hTrackBar, 0, 0, LOWORD(lParam), HIWORD(lParam) - Size, TRUE);
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
case WM_HSCROLL:
|
||||
{
|
||||
if (hTrackBar == (HWND) lParam)
|
||||
{
|
||||
DWORD dwNewPos = (DWORD) SendMessage(hTrackBar, TBM_GETPOS, 0, 0);
|
||||
SeekPlayback(hwnd, dwNewPos);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_PLAY:
|
||||
if (bIsOpened)
|
||||
{
|
||||
if (bIsPaused)
|
||||
ResumePlayback(hwnd);
|
||||
else
|
||||
PausePlayback(hwnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (szPrevFile[0] == _T('\0'))
|
||||
OpenFileDialog(hwnd);
|
||||
else
|
||||
PlayFile(hwnd, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_STOP:
|
||||
StopPlayback(hwnd);
|
||||
break;
|
||||
|
||||
case IDC_EJECT:
|
||||
break;
|
||||
|
||||
case IDC_BACKWARD:
|
||||
break;
|
||||
|
||||
case IDC_SEEKBACK:
|
||||
SeekBackPlayback(hwnd);
|
||||
break;
|
||||
|
||||
case IDC_SEEKFORW:
|
||||
SeekForwPlayback(hwnd);
|
||||
break;
|
||||
|
||||
case IDC_FORWARD:
|
||||
break;
|
||||
|
||||
case IDM_OPEN_FILE:
|
||||
OpenFileDialog(hwnd);
|
||||
return 0;
|
||||
|
||||
case IDM_CLOSE_FILE:
|
||||
StopPlayback(hwnd);
|
||||
lstrcpy(szPrevFile, _T("\0"));
|
||||
break;
|
||||
|
||||
case IDM_ABOUT:
|
||||
ShellAbout(hwnd, szAppTitle, 0, 0);
|
||||
break;
|
||||
|
||||
case IDM_EXIT:
|
||||
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
StopPlayback(hwnd);
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, Message, wParam, lParam);
|
||||
}
|
||||
|
||||
INT WINAPI
|
||||
_tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdShow)
|
||||
{
|
||||
WNDCLASSEX WndClass = {0};
|
||||
TCHAR szClassName[] = _T("ROSMPLAY32");
|
||||
HWND hwnd;
|
||||
MSG msg;
|
||||
|
||||
hInstance = hInst;
|
||||
|
||||
LoadString(hInstance, IDS_APPTITLE, szAppTitle, sizeof(szAppTitle) / sizeof(TCHAR));
|
||||
|
||||
WndClass.cbSize = sizeof(WNDCLASSEX);
|
||||
WndClass.lpszClassName = szClassName;
|
||||
WndClass.lpfnWndProc = MainWndProc;
|
||||
WndClass.hInstance = hInstance;
|
||||
WndClass.style = CS_HREDRAW | CS_VREDRAW;
|
||||
WndClass.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIN));
|
||||
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
WndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
||||
WndClass.lpszMenuName = MAKEINTRESOURCE(IDR_MAINMENU);
|
||||
|
||||
RegisterClassEx(&WndClass);
|
||||
|
||||
hwnd = CreateWindow(szClassName,
|
||||
szAppTitle,
|
||||
WS_SYSMENU | WS_MINIMIZEBOX | WS_THICKFRAME | WS_OVERLAPPED | WS_CAPTION | WS_CLIPCHILDREN,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
350,
|
||||
MAIN_WINDOW_HEIGHT,
|
||||
NULL,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
|
||||
/* Show it */
|
||||
ShowWindow(hwnd, SW_SHOW);
|
||||
UpdateWindow(hwnd);
|
||||
|
||||
/* Message Loop */
|
||||
while (GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
19
reactos/base/applications/mplay32/mplay32.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
||||
#define IDT_PLAYTIMER 1000
|
||||
|
||||
#define UNSUPPORTED_FILE 0
|
||||
#define WAVE_FILE 1
|
||||
#define MIDI_FILE 2
|
||||
#define AUDIOCD_FILE 3
|
||||
#define AVI_FILE 4
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TCHAR szExt[MAX_PATH];
|
||||
UINT uType;
|
||||
} TYPEBYEXT;
|
12
reactos/base/applications/mplay32/mplay32.rbuild
Normal file
|
@ -0,0 +1,12 @@
|
|||
<module name="mplay32" type="win32gui" installbase="system32" installname="mplay32.exe" unicode="yes">
|
||||
<include base="mplay32">.</include>
|
||||
<library>advapi32</library>
|
||||
<library>comctl32</library>
|
||||
<library>comdlg32</library>
|
||||
<library>kernel32</library>
|
||||
<library>user32</library>
|
||||
<library>winmm</library>
|
||||
<library>shell32</library>
|
||||
<file>mplay32.c</file>
|
||||
<file>mplay32.rc</file>
|
||||
</module>
|
24
reactos/base/applications/mplay32/mplay32.rc
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include <windows.h>
|
||||
#include "resource.h"
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Multimedia Player\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "mplay32\0"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "mplay32.exe\0"
|
||||
#include <reactos/version.rc>
|
||||
|
||||
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||
|
||||
/* Icons */
|
||||
IDI_MAIN ICON DISCARDABLE "resources/mplay32.ico"
|
||||
|
||||
/* Bitmaps */
|
||||
IDB_PLAYICON BITMAP "resources/play.bmp"
|
||||
IDB_STOPICON BITMAP "resources/stop.bmp"
|
||||
IDB_EJECTICON BITMAP "resources/eject.bmp"
|
||||
IDB_BACKWARDICON BITMAP "resources/backward.bmp"
|
||||
IDB_SEEKBACKICON BITMAP "resources/seekback.bmp"
|
||||
IDB_SEEKFORWICON BITMAP "resources/seekforw.bmp"
|
||||
IDB_FORWARDICON BITMAP "resources/forward.bmp"
|
||||
IDB_PAUSEICON BITMAP "resources/pause.bmp"
|
||||
|
||||
#include "rsrc.rc"
|
55
reactos/base/applications/mplay32/resource.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
#ifndef __RESOURCE_H_
|
||||
#define __RESOURCE_H_
|
||||
|
||||
/* Icons */
|
||||
#define IDI_MAIN 10
|
||||
|
||||
/* Bitmaps */
|
||||
#define IDB_PLAYICON 50
|
||||
#define IDB_STOPICON 51
|
||||
#define IDB_EJECTICON 52
|
||||
#define IDB_BACKWARDICON 53
|
||||
#define IDB_SEEKBACKICON 54
|
||||
#define IDB_SEEKFORWICON 55
|
||||
#define IDB_FORWARDICON 56
|
||||
#define IDB_PAUSEICON 57
|
||||
|
||||
/* Strings */
|
||||
#define IDS_APPTITLE 100
|
||||
#define IDS_TOOLTIP_PLAY 101
|
||||
#define IDS_TOOLTIP_STOP 102
|
||||
#define IDS_TOOLTIP_EJECT 103
|
||||
#define IDS_TOOLTIP_BACKWARD 104
|
||||
#define IDS_TOOLTIP_SEEKBACK 105
|
||||
#define IDS_TOOLTIP_SEEKFORW 106
|
||||
#define IDS_TOOLTIP_FORWARD 107
|
||||
#define IDS_ALL_TYPES_FILTER 108
|
||||
|
||||
/* Menu */
|
||||
#define IDR_MAINMENU 500
|
||||
|
||||
/* Menu items */
|
||||
#define IDM_OPEN_FILE 1000
|
||||
#define IDM_CLOSE_FILE 1001
|
||||
#define IDM_EXIT 1002
|
||||
#define IDM_ABOUT 1003
|
||||
|
||||
/* ToolBar Icons */
|
||||
#define TBICON_PLAY 0
|
||||
#define TBICON_STOP 1
|
||||
#define TBICON_EJECT 2
|
||||
#define TBICON_BACKWARD 3
|
||||
#define TBICON_SEEKBACK 4
|
||||
#define TBICON_SEEKFORW 5
|
||||
#define TBICON_FORWARD 6
|
||||
|
||||
/* ToolBar Buttons */
|
||||
#define IDC_PLAY 1500
|
||||
#define IDC_STOP 1501
|
||||
#define IDC_EJECT 1502
|
||||
#define IDC_BACKWARD 1503
|
||||
#define IDC_SEEKBACK 1504
|
||||
#define IDC_SEEKFORW 1505
|
||||
#define IDC_FORWARD 1506
|
||||
|
||||
#endif /* __RESOURCE_H_ */
|
BIN
reactos/base/applications/mplay32/resources/backward.bmp
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
reactos/base/applications/mplay32/resources/eject.bmp
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
reactos/base/applications/mplay32/resources/forward.bmp
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
reactos/base/applications/mplay32/resources/mplay32.ico
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
reactos/base/applications/mplay32/resources/pause.bmp
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
reactos/base/applications/mplay32/resources/play.bmp
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
reactos/base/applications/mplay32/resources/seekback.bmp
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
reactos/base/applications/mplay32/resources/seekforw.bmp
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
reactos/base/applications/mplay32/resources/stop.bmp
Normal file
After Width: | Height: | Size: 1.3 KiB |
4
reactos/base/applications/mplay32/rsrc.rc
Normal file
|
@ -0,0 +1,4 @@
|
|||
#include <windows.h>
|
||||
#include "resource.h"
|
||||
|
||||
#include "lang/en-US.rc"
|