[MPLAY32]

Three patches for mplay32 by Ricardo Hanke. Some more or less heavy tabs->spaces fixing and removing of spaces which are too much by myself
CORE-7590 #resolve
CORE-7594 #resolve
CORE-7613 #resolve

svn path=/trunk/; revision=61640
This commit is contained in:
Daniel Reimer 2014-01-15 23:59:44 +00:00
parent bc31b865ff
commit 6360f5452f
25 changed files with 284 additions and 64 deletions

View file

@ -13,6 +13,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "Из&ход", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "Помо&щ"
BEGIN
MENUITEM "&За...", IDM_ABOUT
@ -31,4 +37,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Търсене напред"
IDS_APPTITLE "Мултимедийният възпроизводител на РеактОС"
IDS_PLAY "Възпроизвеждане"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -14,6 +14,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "&Ukončit", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "&Nápověda"
BEGIN
MENUITEM "&O programu...", IDM_ABOUT
@ -32,4 +38,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Přeskočit vpřed"
IDS_APPTITLE "ReactOS Přehrávač multimédií"
IDS_PLAY "Přehrát"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -9,6 +9,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "&Beenden", IDM_EXIT
END
POPUP "&Gerät"
BEGIN
MENUITEM "&Eigenschaften", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Lautstärkeregelung", IDM_VOLUMECTL
END
POPUP "&Hilfe"
BEGIN
MENUITEM "&Über...", IDM_ABOUT
@ -27,4 +33,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Weiter"
IDS_APPTITLE "ReactOS Multimedia Player"
IDS_PLAY "Abspielen"
IDS_DEFAULTMCIERRMSG "Für diesen Fehler steht keine Beschreibung zur Verfügung"
END

View file

@ -9,6 +9,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "&Exit", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "&Help"
BEGIN
MENUITEM "&About...", IDM_ABOUT
@ -27,4 +33,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Skip Forward"
IDS_APPTITLE "ReactOS Multimedia Player"
IDS_PLAY "Play"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -9,6 +9,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "&Salir", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "Ay&uda"
BEGIN
MENUITEM "&Acerca de...", IDM_ABOUT
@ -27,4 +33,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Marca siguiente"
IDS_APPTITLE "Reproductor Multimedia de ReactOS"
IDS_PLAY "Reproducir"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -9,6 +9,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "&Quitter", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "&Aide"
BEGIN
MENUITEM "&À propos...", IDM_ABOUT
@ -27,4 +33,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Suivant"
IDS_APPTITLE "ReactOS Multimedia Player"
IDS_PLAY "Lire"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -9,6 +9,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "&יציאה", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "&עזרה"
BEGIN
MENUITEM "&אודות", IDM_ABOUT
@ -27,4 +33,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "דלג קדימה"
IDS_APPTITLE "נגן המולטימדיה של ReactOS"
IDS_PLAY "נגן"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -9,6 +9,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "&Esci", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "&Aiuto"
BEGIN
MENUITEM "&Informazioni...", IDM_ABOUT
@ -27,4 +33,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Successivo"
IDS_APPTITLE "Riproduttore multimediale ReactOS"
IDS_PLAY "Riproduci"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -9,6 +9,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "終了(&E)", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "ヘルプ(&H)"
BEGIN
MENUITEM "バージョン情報(&A)...", IDM_ABOUT
@ -27,4 +33,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "前へスキップ"
IDS_APPTITLE "ReactOS マルチメディア プレーヤー"
IDS_PLAY "再生"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -9,6 +9,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "&Afsluiten", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "&Help"
BEGIN
MENUITEM "&Over...", IDM_ABOUT
@ -27,4 +33,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Volgende"
IDS_APPTITLE "ReactOS Multimedia Player"
IDS_PLAY "Play"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -9,6 +9,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "&Avslutt", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "&Hjelp"
BEGIN
MENUITEM "&Om...", IDM_ABOUT
@ -27,4 +33,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Spole fremover"
IDS_APPTITLE "ReactOS Multimedia avspiller"
IDS_PLAY "Spill"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -16,6 +16,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "&Wyjdź", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "&Pomoc"
BEGIN
MENUITEM "&O programie...", IDM_ABOUT
@ -34,4 +40,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Przeskocz do przodu"
IDS_APPTITLE "ReactOS Multimedia Player"
IDS_PLAY "Odtwórz"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -11,6 +11,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "&Sair", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "A&juda"
BEGIN
MENUITEM "&Sobre...", IDM_ABOUT
@ -29,4 +35,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Pular Próxima"
IDS_APPTITLE "ReactOS Multimedia Player"
IDS_PLAY "Executar"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -16,6 +16,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "I&eșire", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "&?"
BEGIN
MENUITEM "&Despre…", IDM_ABOUT
@ -34,4 +40,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Salt la următor"
IDS_APPTITLE "Lector multimedia"
IDS_PLAY "Lecturare"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -9,6 +9,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "&Выход", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "&Помощь"
BEGIN
MENUITEM "&О программе...", IDM_ABOUT
@ -27,4 +33,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Вперед"
IDS_APPTITLE "Проигрыватель ReactOS"
IDS_PLAY "Воспроизвести"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -14,6 +14,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "S&končiť", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "&Pomocník"
BEGIN
MENUITEM "Č&o je...", IDM_ABOUT
@ -32,4 +38,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Preskočiť dopredu"
IDS_APPTITLE "Multimediálny prehrávač systému ReactOS"
IDS_PLAY "Prehrať"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -13,6 +13,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "&Dil", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "&Ndihmë"
BEGIN
MENUITEM "&Rreth...", IDM_ABOUT
@ -31,4 +37,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Kalo para"
IDS_APPTITLE "Programi muzikor i ReactOS"
IDS_PLAY "Fillo"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -16,6 +16,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "&Avsluta", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "&Hjälp"
BEGIN
MENUITEM "&Om...", IDM_ABOUT
@ -34,4 +40,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Spola fremåt"
IDS_APPTITLE "ReactOS Multimediaspelare"
IDS_PLAY "Play"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -11,6 +11,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "&Çıkış", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "&Yardım"
BEGIN
MENUITEM "&Hakkında", IDM_ABOUT
@ -29,4 +35,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Bir Sonraki"
IDS_APPTITLE "Ortam Oynatıcısı"
IDS_PLAY "Çal"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -17,6 +17,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "&Вихід", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "&Довідка"
BEGIN
MENUITEM "&Про програму...", IDM_ABOUT
@ -35,4 +41,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "Вперед"
IDS_APPTITLE "Програвач ReactOS"
IDS_PLAY "Відтворити"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -11,6 +11,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "退出(&E)", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "帮助(&H)"
BEGIN
MENUITEM "关于... (&A)", IDM_ABOUT
@ -29,4 +35,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "向前跳过"
IDS_APPTITLE "ReactOS 多媒体播放器"
IDS_PLAY "播放"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -17,6 +17,12 @@ BEGIN
MENUITEM SEPARATOR
MENUITEM "結束(&E)", IDM_EXIT
END
POPUP "&Device"
BEGIN
MENUITEM "&Properties", IDM_DEVPROPS
MENUITEM SEPARATOR
MENUITEM "&Volume Control", IDM_VOLUMECTL
END
POPUP "說明(&H)"
BEGIN
MENUITEM "關於(&A)...", IDM_ABOUT
@ -35,4 +41,5 @@ BEGIN
IDS_TOOLTIP_FORWARD "快轉"
IDS_APPTITLE "ReactOS 多媒體播放器"
IDS_PLAY "播放"
IDS_DEFAULTMCIERRMSG "No description is available for this error"
END

View file

@ -12,6 +12,7 @@
HINSTANCE hInstance = NULL;
HWND hTrackBar = NULL;
HWND hToolBar = NULL;
HMENU hMainMenu = NULL;
TCHAR szAppTitle[256] = _T("");
TCHAR szPrevFile[MAX_PATH] = _T("\0");
WORD wDeviceId;
@ -19,17 +20,6 @@ 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[] =
@ -44,6 +34,26 @@ static const TBBUTTON Buttons[] =
{TBICON_FORWARD, IDC_FORWARD, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}
};
void EnableMenuItems(void)
{
MCI_GENERIC_PARMS mciGeneric;
DWORD dwError;
EnableMenuItem(hMainMenu, IDM_CLOSE_FILE, MF_BYCOMMAND | MF_ENABLED);
dwError = mciSendCommand(wDeviceId, MCI_CONFIGURE, MCI_TEST, (DWORD_PTR)&mciGeneric);
if (dwError == 0)
{
EnableMenuItem(hMainMenu, IDM_DEVPROPS, MF_BYCOMMAND | MF_ENABLED);
}
}
void DisableMenuItems(void)
{
EnableMenuItem(hMainMenu, IDM_CLOSE_FILE, MF_BYCOMMAND | MF_GRAYED);
EnableMenuItem(hMainMenu, IDM_DEVPROPS, MF_BYCOMMAND | MF_GRAYED);
}
static VOID
SetImageList(HWND hwnd)
{
@ -91,6 +101,21 @@ SetImageList(HWND hwnd)
(LPARAM)hImageList));
}
static VOID
ShowMCIError(HWND hwnd, DWORD dwError)
{
TCHAR szErrorMessage[256];
TCHAR szTempMessage[300];
if (mciGetErrorString(dwError, szErrorMessage, sizeof(szErrorMessage) / sizeof(TCHAR)) == FALSE)
{
LoadString(hInstance, IDS_DEFAULTMCIERRMSG, szErrorMessage, sizeof(szErrorMessage) / sizeof(TCHAR));
}
_stprintf(szTempMessage, _T("MMSYS%u: %s"), dwError, szErrorMessage);
MessageBox(hwnd, szTempMessage, szAppTitle, MB_OK | MB_ICONEXCLAMATION);
}
static VOID
InitControls(HWND hwnd)
{
@ -141,43 +166,39 @@ InitControls(HWND hwnd)
SendMessage(hToolBar, TB_ADDBUTTONS, NumButtons, (LPARAM)Buttons);
}
static UINT
IsSupportedFileExtension(LPTSTR lpFileName)
static BOOL
IsSupportedFileExtension(LPTSTR lpFileName, LPTSTR lpDeviceName, LPDWORD dwSize)
{
TCHAR szExt[MAX_PATH];
INT DotPos = 0, i, j;
HKEY hKey;
DWORD dwType;
TCHAR *pathend;
for (i = _tcslen(lpFileName); i >= 0; --i)
pathend = _tcsrchr(lpFileName, '.');
if (pathend == NULL)
{
if (lpFileName[i] == '.')
{
DotPos = _tcslen(lpFileName) - i;
break;
}
return FALSE;
}
if (!DotPos) return UNSUPPORTED_FILE;
pathend++;
szExt[DotPos + 1] = _T('\0');
for (i = _tcslen(lpFileName), j = DotPos; j >= 0; --i, --j)
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\MCI Extensions"), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
szExt[j] = lpFileName[i];
if (RegQueryValueEx(hKey, pathend, NULL, &dwType, (LPBYTE)lpDeviceName, dwSize) == ERROR_SUCCESS)
{
RegCloseKey(hKey);
if (dwType != REG_SZ)
{
return FALSE;
}
return TRUE;
}
RegCloseKey(hKey);
}
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;
return FALSE;
}
static DWORD
@ -193,6 +214,8 @@ CloseMciDevice(VOID)
bIsOpened = FALSE;
}
DisableMenuItems();
return TRUE;
}
@ -218,7 +241,7 @@ OpenMciDevice(HWND hwnd, LPTSTR lpType, LPTSTR lpFileName)
dwError = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT | MCI_WAIT, (DWORD_PTR)&mciOpen);
if (dwError != 0)
{
MessageBox(0, _T("Can't open device! (1)"), NULL, MB_OK);
ShowMCIError(hwnd, dwError);
return dwError;
}
@ -227,7 +250,7 @@ OpenMciDevice(HWND hwnd, LPTSTR lpType, LPTSTR lpFileName)
dwError = mciSendCommand(mciOpen.wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD_PTR)&mciStatus);
if (dwError != 0)
{
MessageBox(0, _T("Can't open device! (2)"), NULL, MB_OK);
ShowMCIError(hwnd, dwError);
return dwError;
}
@ -261,6 +284,9 @@ OpenMciDevice(HWND hwnd, LPTSTR lpType, LPTSTR lpFileName)
wDeviceId = mciOpen.wDeviceID;
bIsOpened = TRUE;
_tcscpy(szPrevFile, lpFileName);
EnableMenuItems();
return TRUE;
}
@ -288,14 +314,14 @@ SeekPlayback(HWND hwnd, DWORD dwNewPos)
dwError = mciSendCommand(wDeviceId, MCI_SEEK, MCI_WAIT | MCI_TO, (DWORD_PTR)&mciSeek);
if (dwError != 0)
{
MessageBox(hwnd, _T("SeekPlayback: Can't seek!"), NULL, MB_OK);
ShowMCIError(hwnd, dwError);
}
mciPlay.dwCallback = (DWORD_PTR)hwnd;
dwError = mciSendCommand(wDeviceId, MCI_PLAY, MCI_NOTIFY, (DWORD_PTR)&mciPlay);
if (dwError != 0)
{
MessageBox(hwnd, _T("SeekPlayback: Can't play!"), NULL, MB_OK);
ShowMCIError(hwnd, dwError);
}
}
}
@ -357,7 +383,7 @@ PausePlayback(HWND hwnd)
dwError = mciSendCommand(wDeviceId, MCI_PAUSE, MCI_WAIT, (DWORD_PTR)&mciGeneric);
if (dwError != 0)
{
MessageBox(hwnd, _T("Can't pause!"), NULL, MB_OK);
ShowMCIError(hwnd, dwError);
}
bIsPaused = TRUE;
}
@ -374,12 +400,25 @@ ResumePlayback(HWND hwnd)
dwError = mciSendCommand(wDeviceId, MCI_RESUME, MCI_WAIT, (DWORD_PTR)&mciGeneric);
if (dwError != 0)
{
MessageBox(hwnd, _T("Can't resume!"), NULL, MB_OK);
ShowMCIError(hwnd, dwError);
}
bIsPaused = FALSE;
}
}
static VOID
ShowDeviceProperties(HWND hwnd)
{
MCI_GENERIC_PARMS mciGeneric;
DWORD dwError;
dwError = mciSendCommand(wDeviceId, MCI_CONFIGURE, MCI_WAIT, (DWORD_PTR)&mciGeneric);
if (dwError != 0)
{
MessageBox(0, _T("Can't display the device properties!"), NULL, MB_OK);
}
}
VOID CALLBACK
PlayTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
@ -407,7 +446,9 @@ PlayFile(HWND hwnd, LPTSTR lpFileName)
{
MCI_PLAY_PARMS mciPlay;
TCHAR szLocalFileName[MAX_PATH];
UINT FileType;
TCHAR szDeviceName[MAX_PATH];
DWORD dwSize;
BOOL IsSupported;
MCIERROR mciError;
if (lpFileName == NULL)
@ -427,25 +468,13 @@ PlayFile(HWND hwnd, LPTSTR lpFileName)
return;
}
FileType = IsSupportedFileExtension(szLocalFileName);
dwSize = sizeof(szDeviceName) - 2;
_tcsnset(szDeviceName, _T('\0'), dwSize / sizeof(TCHAR));
IsSupported = IsSupportedFileExtension(szLocalFileName, szDeviceName, &dwSize);
switch (FileType)
if (IsSupported == TRUE)
{
case UNSUPPORTED_FILE:
MessageBox(hwnd, _T("Unsupported format!"), NULL, MB_OK);
return;
case WAVE_FILE:
OpenMciDevice(hwnd, _T("waveaudio"), szLocalFileName);
break;
case MIDI_FILE:
OpenMciDevice(hwnd, _T("sequencer"), szLocalFileName);
break;
case AUDIOCD_FILE:
OpenMciDevice(hwnd, _T("cdaudio"), szLocalFileName);
break;
case AVI_FILE:
OpenMciDevice(hwnd, _T("avivideo"), szLocalFileName);
break;
OpenMciDevice(hwnd, szDeviceName, szLocalFileName);
}
SetTimer(hwnd, IDT_PLAYTIMER, 100, (TIMERPROC) PlayTimerProc);
@ -459,7 +488,7 @@ PlayFile(HWND hwnd, LPTSTR lpFileName)
mciError = mciSendCommand(wDeviceId, MCI_PLAY, MCI_NOTIFY | MCI_FROM /*| MCI_TO*/, (DWORD_PTR)&mciPlay);
if (mciError != 0)
{
MessageBox(hwnd, _T("Can't play!"), NULL, MB_OK);
ShowMCIError(hwnd, mciError);
}
}
@ -502,8 +531,21 @@ MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
case WM_CREATE:
InitControls(hwnd);
hMainMenu = GetMenu(hwnd);
break;
case WM_DROPFILES:
{
HDROP drophandle;
TCHAR droppedfile[MAX_PATH];
drophandle = (HDROP)wParam;
DragQueryFile(drophandle, 0, droppedfile, sizeof(droppedfile));
DragFinish(drophandle);
PlayFile(hwnd, droppedfile);
break;
}
case WM_NOTIFY:
{
LPNMHDR pnmhdr = (LPNMHDR)lParam;
@ -641,6 +683,14 @@ MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
_tcscpy(szPrevFile, _T("\0"));
break;
case IDM_DEVPROPS:
ShowDeviceProperties(hwnd);
break;
case IDM_VOLUMECTL:
ShellExecute(hwnd, NULL, _T("SNDVOL32.EXE"), NULL, NULL, SW_SHOWNORMAL);
break;
case IDM_ABOUT:
{
HICON mplayIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MAIN));
@ -670,6 +720,7 @@ _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdShow)
TCHAR szClassName[] = _T("ROSMPLAY32");
HWND hwnd;
MSG msg;
DWORD dwError;
hInstance = hInst;
@ -699,6 +750,16 @@ _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdShow)
hInstance,
NULL);
DragAcceptFiles(hwnd, TRUE);
DisableMenuItems();
dwError = SearchPath(NULL, _T("SNDVOL32.EXE"), NULL, 0, NULL, NULL);
if (dwError == 0)
{
EnableMenuItem(hMainMenu, IDM_VOLUMECTL, MF_BYCOMMAND | MF_GRAYED);
}
/* Show it */
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);

View file

@ -3,9 +3,11 @@
#include <winbase.h>
#include <winuser.h>
#include <wingdi.h>
#include <winreg.h>
#include <commdlg.h>
#include <shellapi.h>
#include <mmsystem.h>
#include <digitalv.h>
#include <commctrl.h>
#include <tchar.h>

View file

@ -24,6 +24,7 @@
#define IDS_TOOLTIP_FORWARD 107
#define IDS_ALL_TYPES_FILTER 108
#define IDS_PLAY 109
#define IDS_DEFAULTMCIERRMSG 110
/* Menu */
#define IDR_MAINMENU 500
@ -33,6 +34,8 @@
#define IDM_CLOSE_FILE 1001
#define IDM_EXIT 1002
#define IDM_ABOUT 1003
#define IDM_VOLUMECTL 1004
#define IDM_DEVPROPS 1005
/* ToolBar Icons */
#define TBICON_PLAY 0