[MPLAY32]

- Additional improvements by Ricardo Hanke, see CORE-8477 for all the details!
- Add support for play/pause button: now we change its icon and tooltip.
- Do not block when repeatedly change play/pause state.

svn path=/trunk/; revision=66593
This commit is contained in:
Hermès Bélusca-Maïto 2015-03-06 23:49:49 +00:00
parent 529183cda7
commit 551a042b6f
25 changed files with 245 additions and 248 deletions

View file

@ -55,8 +55,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Търсене назад" IDS_TOOLTIP_SEEKBACK "Търсене назад"
IDS_TOOLTIP_SEEKFORW "Търсене напред" IDS_TOOLTIP_SEEKFORW "Търсене напред"
IDS_TOOLTIP_FORWARD "Търсене напред" IDS_TOOLTIP_FORWARD "Търсене напред"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "Мултимедийният възпроизводител на РеактОС" IDS_APPTITLE "Мултимедийният възпроизводител на РеактОС"
IDS_PLAY "Възпроизвеждане" IDS_PLAY "Възпроизвеждане"
IDS_DEFAULTMCIERRMSG "No description is available for this error." IDS_DEFAULTMCIERRMSG "No description is available for this error."
IDS_UNKNOWNFILEEXT "Cannot determine the device type from the given filename extension."
END END

View file

@ -56,8 +56,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Posunout zpět" IDS_TOOLTIP_SEEKBACK "Posunout zpět"
IDS_TOOLTIP_SEEKFORW "Posunout vpřed" IDS_TOOLTIP_SEEKFORW "Posunout vpřed"
IDS_TOOLTIP_FORWARD "Přeskočit vpřed" IDS_TOOLTIP_FORWARD "Přeskočit vpřed"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "ReactOS Přehrávač multimédií" IDS_APPTITLE "ReactOS Přehrávač multimédií"
IDS_PLAY "Přehrát" IDS_PLAY "Přehrát"
IDS_DEFAULTMCIERRMSG "Pro tuto chybu není dostupný žádný popis." IDS_DEFAULTMCIERRMSG "Pro tuto chybu není dostupný žádný popis."
IDS_UNKNOWNFILEEXT "Nelze určit typ zařízení z dané přípony souboru."
END END

View file

@ -51,8 +51,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Schneller Rücklauf" IDS_TOOLTIP_SEEKBACK "Schneller Rücklauf"
IDS_TOOLTIP_SEEKFORW "Schneller Vorlauf" IDS_TOOLTIP_SEEKFORW "Schneller Vorlauf"
IDS_TOOLTIP_FORWARD "Weiter" IDS_TOOLTIP_FORWARD "Weiter"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "ReactOS Multimedia Player" IDS_APPTITLE "ReactOS Multimedia Player"
IDS_PLAY "Abspielen" IDS_PLAY "Abspielen"
IDS_DEFAULTMCIERRMSG "Für diesen Fehler steht keine Beschreibung zur Verfügung." IDS_DEFAULTMCIERRMSG "Für diesen Fehler steht keine Beschreibung zur Verfügung."
IDS_UNKNOWNFILEEXT "Kann keinen Gerätetyp aus der angegebenen Dateinamenerweiterung ermitteln."
END END

View file

@ -51,8 +51,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Seek Backward" IDS_TOOLTIP_SEEKBACK "Seek Backward"
IDS_TOOLTIP_SEEKFORW "Seek Forward" IDS_TOOLTIP_SEEKFORW "Seek Forward"
IDS_TOOLTIP_FORWARD "Skip Forward" IDS_TOOLTIP_FORWARD "Skip Forward"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "ReactOS Multimedia Player" IDS_APPTITLE "ReactOS Multimedia Player"
IDS_PLAY "Play" IDS_PLAY "Play"
IDS_DEFAULTMCIERRMSG "No description is available for this error." IDS_DEFAULTMCIERRMSG "No description is available for this error."
IDS_UNKNOWNFILEEXT "Cannot determine the device type from the given filename extension."
END END

View file

@ -51,8 +51,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Rebobinar" IDS_TOOLTIP_SEEKBACK "Rebobinar"
IDS_TOOLTIP_SEEKFORW "Avance rápido" IDS_TOOLTIP_SEEKFORW "Avance rápido"
IDS_TOOLTIP_FORWARD "Siguiente marca" IDS_TOOLTIP_FORWARD "Siguiente marca"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "Reproductor multimedia de ReactOS" IDS_APPTITLE "Reproductor multimedia de ReactOS"
IDS_PLAY "Reproducir" IDS_PLAY "Reproducir"
IDS_DEFAULTMCIERRMSG "No hay una descripción disponible para este error." IDS_DEFAULTMCIERRMSG "No hay una descripción disponible para este error."
IDS_UNKNOWNFILEEXT "No se puede determinar el tipo de dispositivo a partir de la extensión del archivo."
END END

View file

@ -51,8 +51,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Retour rapide" IDS_TOOLTIP_SEEKBACK "Retour rapide"
IDS_TOOLTIP_SEEKFORW "Avance rapide" IDS_TOOLTIP_SEEKFORW "Avance rapide"
IDS_TOOLTIP_FORWARD "Suivant" IDS_TOOLTIP_FORWARD "Suivant"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "ReactOS Multimedia Player" IDS_APPTITLE "ReactOS Multimedia Player"
IDS_PLAY "Lire" IDS_PLAY "Lire"
IDS_DEFAULTMCIERRMSG "No description is available for this error." IDS_DEFAULTMCIERRMSG "No description is available for this error."
IDS_UNKNOWNFILEEXT "Cannot determine the device type from the given filename extension."
END END

View file

@ -51,8 +51,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "חפש אחורנית" IDS_TOOLTIP_SEEKBACK "חפש אחורנית"
IDS_TOOLTIP_SEEKFORW "חפש קדימה" IDS_TOOLTIP_SEEKFORW "חפש קדימה"
IDS_TOOLTIP_FORWARD "דלג קדימה" IDS_TOOLTIP_FORWARD "דלג קדימה"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "נגן המולטימדיה של ReactOS" IDS_APPTITLE "נגן המולטימדיה של ReactOS"
IDS_PLAY "נגן" IDS_PLAY "נגן"
IDS_DEFAULTMCIERRMSG "No description is available for this error." IDS_DEFAULTMCIERRMSG "No description is available for this error."
IDS_UNKNOWNFILEEXT "Cannot determine the device type from the given filename extension."
END END

View file

@ -51,8 +51,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Riavvolgimento rapido" IDS_TOOLTIP_SEEKBACK "Riavvolgimento rapido"
IDS_TOOLTIP_SEEKFORW "Avanzamento rapido" IDS_TOOLTIP_SEEKFORW "Avanzamento rapido"
IDS_TOOLTIP_FORWARD "Successivo" IDS_TOOLTIP_FORWARD "Successivo"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "Riproduttore multimediale ReactOS" IDS_APPTITLE "Riproduttore multimediale ReactOS"
IDS_PLAY "Riproduci" IDS_PLAY "Riproduci"
IDS_DEFAULTMCIERRMSG "No description is available for this error." IDS_DEFAULTMCIERRMSG "No description is available for this error."
IDS_UNKNOWNFILEEXT "Cannot determine the device type from the given filename extension."
END END

View file

@ -51,8 +51,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "後ろへシーク" IDS_TOOLTIP_SEEKBACK "後ろへシーク"
IDS_TOOLTIP_SEEKFORW "前へシーク" IDS_TOOLTIP_SEEKFORW "前へシーク"
IDS_TOOLTIP_FORWARD "前へスキップ" IDS_TOOLTIP_FORWARD "前へスキップ"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "ReactOS マルチメディア プレーヤー" IDS_APPTITLE "ReactOS マルチメディア プレーヤー"
IDS_PLAY "再生" IDS_PLAY "再生"
IDS_DEFAULTMCIERRMSG "No description is available for this error." IDS_DEFAULTMCIERRMSG "No description is available for this error."
IDS_UNKNOWNFILEEXT "Cannot determine the device type from the given filename extension."
END END

View file

@ -51,8 +51,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Terugspoelen" IDS_TOOLTIP_SEEKBACK "Terugspoelen"
IDS_TOOLTIP_SEEKFORW "Vooruitspoelen" IDS_TOOLTIP_SEEKFORW "Vooruitspoelen"
IDS_TOOLTIP_FORWARD "Volgende" IDS_TOOLTIP_FORWARD "Volgende"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "ReactOS Multimedia Player" IDS_APPTITLE "ReactOS Multimedia Player"
IDS_PLAY "Play" IDS_PLAY "Play"
IDS_DEFAULTMCIERRMSG "No description is available for this error." IDS_DEFAULTMCIERRMSG "No description is available for this error."
IDS_UNKNOWNFILEEXT "Cannot determine the device type from the given filename extension."
END END

View file

@ -51,8 +51,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Søke tilbake" IDS_TOOLTIP_SEEKBACK "Søke tilbake"
IDS_TOOLTIP_SEEKFORW "Søke fremover" IDS_TOOLTIP_SEEKFORW "Søke fremover"
IDS_TOOLTIP_FORWARD "Spole fremover" IDS_TOOLTIP_FORWARD "Spole fremover"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "ReactOS Multimedia avspiller" IDS_APPTITLE "ReactOS Multimedia avspiller"
IDS_PLAY "Spill" IDS_PLAY "Spill"
IDS_DEFAULTMCIERRMSG "No description is available for this error." IDS_DEFAULTMCIERRMSG "No description is available for this error."
IDS_UNKNOWNFILEEXT "Cannot determine the device type from the given filename extension."
END END

View file

@ -59,8 +59,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Przewiń do tyłu" IDS_TOOLTIP_SEEKBACK "Przewiń do tyłu"
IDS_TOOLTIP_SEEKFORW "Przewiń do przodu" IDS_TOOLTIP_SEEKFORW "Przewiń do przodu"
IDS_TOOLTIP_FORWARD "Przeskocz do przodu" IDS_TOOLTIP_FORWARD "Przeskocz do przodu"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "Odtwarzacz multimedialny ReactOS" IDS_APPTITLE "Odtwarzacz multimedialny ReactOS"
IDS_PLAY "Odtwórz" IDS_PLAY "Odtwórz"
IDS_DEFAULTMCIERRMSG "Brak dostępnego opisu dla tego błędu." IDS_DEFAULTMCIERRMSG "Brak dostępnego opisu dla tego błędu."
IDS_UNKNOWNFILEEXT "Nie można określić typu urządzenia z podanego rozszerzenia pliku."
END END

View file

@ -53,8 +53,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Procurar Anterior" IDS_TOOLTIP_SEEKBACK "Procurar Anterior"
IDS_TOOLTIP_SEEKFORW "Procurar Próximo" IDS_TOOLTIP_SEEKFORW "Procurar Próximo"
IDS_TOOLTIP_FORWARD "Pular Próxima" IDS_TOOLTIP_FORWARD "Pular Próxima"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "ReactOS Multimedia Player" IDS_APPTITLE "ReactOS Multimedia Player"
IDS_PLAY "Executar" IDS_PLAY "Executar"
IDS_DEFAULTMCIERRMSG "No description is available for this error." IDS_DEFAULTMCIERRMSG "No description is available for this error."
IDS_UNKNOWNFILEEXT "Cannot determine the device type from the given filename extension."
END END

View file

@ -57,8 +57,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Derulează înapoi" IDS_TOOLTIP_SEEKBACK "Derulează înapoi"
IDS_TOOLTIP_SEEKFORW "Derulează înainte" IDS_TOOLTIP_SEEKFORW "Derulează înainte"
IDS_TOOLTIP_FORWARD "Salt la următor" IDS_TOOLTIP_FORWARD "Salt la următor"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "Lector multimedia" IDS_APPTITLE "Lector multimedia"
IDS_PLAY "Lecturare" IDS_PLAY "Lecturare"
IDS_DEFAULTMCIERRMSG "Nu există descriere pentru această eroare." IDS_DEFAULTMCIERRMSG "Nu există descriere pentru această eroare."
IDS_UNKNOWNFILEEXT "Nu se poate determina tipul dispozitivului din extensia fișierului."
END END

View file

@ -51,8 +51,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Перемотка назад" IDS_TOOLTIP_SEEKBACK "Перемотка назад"
IDS_TOOLTIP_SEEKFORW "Перемотка вперед" IDS_TOOLTIP_SEEKFORW "Перемотка вперед"
IDS_TOOLTIP_FORWARD "Вперед" IDS_TOOLTIP_FORWARD "Вперед"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "Проигрыватель ReactOS" IDS_APPTITLE "Проигрыватель ReactOS"
IDS_PLAY "Воспроизвести" IDS_PLAY "Воспроизвести"
IDS_DEFAULTMCIERRMSG "Неизвестная ошибка." IDS_DEFAULTMCIERRMSG "Неизвестная ошибка."
IDS_UNKNOWNFILEEXT "Невозможно определить тип устройства мультимедиа для заданного расширения файла."
END END

View file

@ -56,8 +56,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Vyhľadať dozadu" IDS_TOOLTIP_SEEKBACK "Vyhľadať dozadu"
IDS_TOOLTIP_SEEKFORW "Vyhľadať dopredu" IDS_TOOLTIP_SEEKFORW "Vyhľadať dopredu"
IDS_TOOLTIP_FORWARD "Preskočiť dopredu" IDS_TOOLTIP_FORWARD "Preskočiť dopredu"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "Multimediálny prehrávač systému ReactOS" IDS_APPTITLE "Multimediálny prehrávač systému ReactOS"
IDS_PLAY "Prehrať" IDS_PLAY "Prehrať"
IDS_DEFAULTMCIERRMSG "No description is available for this error." IDS_DEFAULTMCIERRMSG "No description is available for this error."
IDS_UNKNOWNFILEEXT "Cannot determine the device type from the given filename extension."
END END

View file

@ -55,8 +55,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Kërko mbrapa" IDS_TOOLTIP_SEEKBACK "Kërko mbrapa"
IDS_TOOLTIP_SEEKFORW "Kërko përpara" IDS_TOOLTIP_SEEKFORW "Kërko përpara"
IDS_TOOLTIP_FORWARD "Kalo para" IDS_TOOLTIP_FORWARD "Kalo para"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "Programi muzikor i ReactOS" IDS_APPTITLE "Programi muzikor i ReactOS"
IDS_PLAY "Fillo" IDS_PLAY "Fillo"
IDS_DEFAULTMCIERRMSG "No description is available for this error." IDS_DEFAULTMCIERRMSG "No description is available for this error."
IDS_UNKNOWNFILEEXT "Cannot determine the device type from the given filename extension."
END END

View file

@ -58,8 +58,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Sök bakåt" IDS_TOOLTIP_SEEKBACK "Sök bakåt"
IDS_TOOLTIP_SEEKFORW "Sök framåt" IDS_TOOLTIP_SEEKFORW "Sök framåt"
IDS_TOOLTIP_FORWARD "Spola fremåt" IDS_TOOLTIP_FORWARD "Spola fremåt"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "ReactOS Multimediaspelare" IDS_APPTITLE "ReactOS Multimediaspelare"
IDS_PLAY "Play" IDS_PLAY "Play"
IDS_DEFAULTMCIERRMSG "No description is available for this error." IDS_DEFAULTMCIERRMSG "No description is available for this error."
IDS_UNKNOWNFILEEXT "Cannot determine the device type from the given filename extension."
END END

View file

@ -53,8 +53,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Geri Sar" IDS_TOOLTIP_SEEKBACK "Geri Sar"
IDS_TOOLTIP_SEEKFORW "İleri Sar" IDS_TOOLTIP_SEEKFORW "İleri Sar"
IDS_TOOLTIP_FORWARD "Bir Sonrakine Geç" IDS_TOOLTIP_FORWARD "Bir Sonrakine Geç"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "Çoklu Ortam Oynatıcısı" IDS_APPTITLE "Çoklu Ortam Oynatıcısı"
IDS_PLAY "Çal" IDS_PLAY "Çal"
IDS_DEFAULTMCIERRMSG "Bu yanlışlığın tanımı yoktur." IDS_DEFAULTMCIERRMSG "Bu yanlışlığın tanımı yoktur."
IDS_UNKNOWNFILEEXT "Verilen kütük türünden aygıt türü belirlenemiyor."
END END

View file

@ -59,8 +59,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "Перемотування назад" IDS_TOOLTIP_SEEKBACK "Перемотування назад"
IDS_TOOLTIP_SEEKFORW "Перемотування вперед" IDS_TOOLTIP_SEEKFORW "Перемотування вперед"
IDS_TOOLTIP_FORWARD "Вперед" IDS_TOOLTIP_FORWARD "Вперед"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "Програвач ReactOS" IDS_APPTITLE "Програвач ReactOS"
IDS_PLAY "Відтворити" IDS_PLAY "Відтворити"
IDS_DEFAULTMCIERRMSG "No description is available for this error." IDS_DEFAULTMCIERRMSG "No description is available for this error."
IDS_UNKNOWNFILEEXT "Cannot determine the device type from the given filename extension."
END END

View file

@ -53,8 +53,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "快退" IDS_TOOLTIP_SEEKBACK "快退"
IDS_TOOLTIP_SEEKFORW "快进" IDS_TOOLTIP_SEEKFORW "快进"
IDS_TOOLTIP_FORWARD "向前跳过" IDS_TOOLTIP_FORWARD "向前跳过"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "ReactOS 多媒体播放器" IDS_APPTITLE "ReactOS 多媒体播放器"
IDS_PLAY "播放" IDS_PLAY "播放"
IDS_DEFAULTMCIERRMSG "该错误没有可用的描述." IDS_DEFAULTMCIERRMSG "该错误没有可用的描述."
IDS_UNKNOWNFILEEXT "该设备类型从给定的文件扩展名无法断定."
END END

View file

@ -59,8 +59,8 @@ BEGIN
IDS_TOOLTIP_SEEKBACK "後退" IDS_TOOLTIP_SEEKBACK "後退"
IDS_TOOLTIP_SEEKFORW "前進" IDS_TOOLTIP_SEEKFORW "前進"
IDS_TOOLTIP_FORWARD "快轉" IDS_TOOLTIP_FORWARD "快轉"
IDS_TOOLTIP_PAUSE "Pause"
IDS_APPTITLE "ReactOS 多媒體播放器" IDS_APPTITLE "ReactOS 多媒體播放器"
IDS_PLAY "播放" IDS_PLAY "播放"
IDS_DEFAULTMCIERRMSG "No description is available for this error." IDS_DEFAULTMCIERRMSG "No description is available for this error."
IDS_UNKNOWNFILEEXT "Cannot determine the device type from the given filename extension."
END END

View file

@ -6,6 +6,8 @@
#include "mplay32.h" #include "mplay32.h"
#define IDT_PLAYTIMER 1000
#define MAIN_WINDOW_HEIGHT 125 #define MAIN_WINDOW_HEIGHT 125
#define MAIN_WINDOW_MIN_WIDTH 250 #define MAIN_WINDOW_MIN_WIDTH 250
#define MAX_MCISTR 256 #define MAX_MCISTR 256
@ -20,9 +22,7 @@ TCHAR szPrevFile[MAX_PATH] = _T("");
TCHAR szDefaultFilter[MAX_PATH] = _T(""); TCHAR szDefaultFilter[MAX_PATH] = _T("");
TCHAR *szFilter = NULL; TCHAR *szFilter = NULL;
WORD wDeviceId; WORD wDeviceId = 0;
BOOL bIsOpened = FALSE;
BOOL bIsPaused = FALSE;
BOOL bRepeat = FALSE; BOOL bRepeat = FALSE;
BOOL bIsSingleWindow = FALSE; BOOL bIsSingleWindow = FALSE;
UINT MaxFilePos = 0; UINT MaxFilePos = 0;
@ -39,7 +39,8 @@ static const TBBUTTON Buttons[] =
{TBICON_BACKWARD, IDC_BACKWARD, TBSTATE_ENABLED, BTNS_BUTTON, {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_SEEKBACK, IDC_SEEKBACK, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
{TBICON_SEEKFORW, IDC_SEEKFORW, 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} {TBICON_FORWARD, IDC_FORWARD, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0},
// {TBICON_PAUSE, IDC_PAUSE, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}
}; };
void EnableMenuItems(HWND hwnd) void EnableMenuItems(HWND hwnd)
@ -148,6 +149,10 @@ SetImageList(HWND hwnd)
LoadImage(hInstance, MAKEINTRESOURCE(IDB_FORWARDICON), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR), LoadImage(hInstance, MAKEINTRESOURCE(IDB_FORWARDICON), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR),
RGB(255, 255, 255)); RGB(255, 255, 255));
ImageList_AddMasked(hImageList,
LoadImage(hInstance, MAKEINTRESOURCE(IDB_PAUSEICON), IMAGE_BITMAP, 16, 16, LR_DEFAULTCOLOR),
RGB(255, 255, 255));
ImageList_Destroy((HIMAGELIST)SendMessage(hToolBar, ImageList_Destroy((HIMAGELIST)SendMessage(hToolBar,
TB_SETIMAGELIST, TB_SETIMAGELIST,
0, 0,
@ -160,9 +165,9 @@ ShowMCIError(HWND hwnd, MCIERROR mciError)
TCHAR szErrorMessage[MAX_MCISTR]; TCHAR szErrorMessage[MAX_MCISTR];
TCHAR szTempMessage[MAX_MCISTR + 44]; TCHAR szTempMessage[MAX_MCISTR + 44];
if (mciGetErrorString(mciError, szErrorMessage, sizeof(szErrorMessage) / sizeof(szErrorMessage[0])) == FALSE) if (mciGetErrorString(mciError, szErrorMessage, ARRAYSIZE(szErrorMessage)) == FALSE)
{ {
LoadString(hInstance, IDS_DEFAULTMCIERRMSG, szErrorMessage, sizeof(szErrorMessage) / sizeof(szErrorMessage[0])); LoadString(hInstance, IDS_DEFAULTMCIERRMSG, szErrorMessage, ARRAYSIZE(szErrorMessage));
} }
StringCbPrintf(szTempMessage, sizeof(szTempMessage), _T("MMSYS%lu: %s"), mciError, szErrorMessage); StringCbPrintf(szTempMessage, sizeof(szTempMessage), _T("MMSYS%lu: %s"), mciError, szErrorMessage);
@ -172,7 +177,7 @@ ShowMCIError(HWND hwnd, MCIERROR mciError)
static VOID static VOID
InitControls(HWND hwnd) InitControls(HWND hwnd)
{ {
INT NumButtons = sizeof(Buttons) / sizeof(Buttons[0]); INT NumButtons = ARRAYSIZE(Buttons);
InitCommonControls(); InitCommonControls();
@ -219,41 +224,6 @@ InitControls(HWND hwnd)
SendMessage(hToolBar, TB_ADDBUTTONS, NumButtons, (LPARAM)Buttons); SendMessage(hToolBar, TB_ADDBUTTONS, NumButtons, (LPARAM)Buttons);
} }
static BOOL
IsSupportedFileExtension(LPTSTR lpFileName, LPTSTR lpDeviceName, LPDWORD dwSize)
{
HKEY hKey;
DWORD dwType;
TCHAR *pathend;
pathend = _tcsrchr(lpFileName, '.');
if (pathend == NULL)
{
return FALSE;
}
pathend++;
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\MCI Extensions"), 0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
if (RegQueryValueEx(hKey, pathend, NULL, &dwType, (LPBYTE)lpDeviceName, dwSize) == ERROR_SUCCESS)
{
RegCloseKey(hKey);
if (dwType != REG_SZ)
{
return FALSE;
}
return TRUE;
}
RegCloseKey(hKey);
}
return FALSE;
}
static VOID static VOID
SwitchViewMode(HWND hwnd) SwitchViewMode(HWND hwnd)
{ {
@ -266,16 +236,12 @@ SwitchViewMode(HWND hwnd)
mciVideoWindow.hWnd = hwnd; mciVideoWindow.hWnd = hwnd;
mciError = mciSendCommand(wDeviceId, MCI_WINDOW, MCI_DGV_WINDOW_HWND | MCI_TEST, (DWORD_PTR)&mciVideoWindow); mciError = mciSendCommand(wDeviceId, MCI_WINDOW, MCI_DGV_WINDOW_HWND | MCI_TEST, (DWORD_PTR)&mciVideoWindow);
if (mciError) if (mciError != 0)
{
return; return;
}
mciError = mciSendCommand(wDeviceId, MCI_WHERE, MCI_DGV_WHERE_SOURCE | MCI_TEST, (DWORD_PTR)&mciVideoRect); mciError = mciSendCommand(wDeviceId, MCI_WHERE, MCI_DGV_WHERE_SOURCE | MCI_TEST, (DWORD_PTR)&mciVideoRect);
if (mciError) if (mciError != 0)
{
return; return;
}
if (!bIsSingleWindow) if (!bIsSingleWindow)
{ {
@ -284,7 +250,7 @@ SwitchViewMode(HWND hwnd)
SetParent(hTrackBar, hToolBar); SetParent(hTrackBar, hToolBar);
mciError = mciSendCommand(wDeviceId, MCI_WHERE, MCI_DGV_WHERE_SOURCE, (DWORD_PTR)&mciVideoRect); mciError = mciSendCommand(wDeviceId, MCI_WHERE, MCI_DGV_WHERE_SOURCE, (DWORD_PTR)&mciVideoRect);
if (mciError) if (mciError != 0)
{ {
ShowMCIError(hwnd, mciError); ShowMCIError(hwnd, mciError);
return; return;
@ -294,7 +260,7 @@ SwitchViewMode(HWND hwnd)
ResizeClientArea(hwnd, mciVideoRect.rc.right, mciVideoRect.rc.bottom + (rcToolbarRect.bottom - rcToolbarRect.top)); ResizeClientArea(hwnd, mciVideoRect.rc.right, mciVideoRect.rc.bottom + (rcToolbarRect.bottom - rcToolbarRect.top));
mciError = mciSendCommand(wDeviceId, MCI_WINDOW, MCI_DGV_WINDOW_HWND, (DWORD_PTR)&mciVideoWindow); mciError = mciSendCommand(wDeviceId, MCI_WINDOW, MCI_DGV_WINDOW_HWND, (DWORD_PTR)&mciVideoWindow);
if (mciError) if (mciError != 0)
{ {
ShowMCIError(hwnd, mciError); ShowMCIError(hwnd, mciError);
return; return;
@ -313,7 +279,7 @@ SwitchViewMode(HWND hwnd)
mciVideoWindow.hWnd = MCI_DGV_WINDOW_DEFAULT; mciVideoWindow.hWnd = MCI_DGV_WINDOW_DEFAULT;
mciError = mciSendCommand(wDeviceId, MCI_WINDOW, MCI_DGV_WINDOW_HWND, (DWORD_PTR)&mciVideoWindow); mciError = mciSendCommand(wDeviceId, MCI_WINDOW, MCI_DGV_WINDOW_HWND, (DWORD_PTR)&mciVideoWindow);
if (mciError) if (mciError != 0)
{ {
ShowMCIError(hwnd, mciError); ShowMCIError(hwnd, mciError);
return; return;
@ -371,10 +337,8 @@ GetDeviceFriendlyName(LPTSTR lpDeviceName, LPTSTR lpFriendlyName, DWORD dwFriend
mciOpen.lpstrAlias = NULL; mciOpen.lpstrAlias = NULL;
mciError = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_WAIT, (DWORD_PTR)&mciOpen); mciError = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_WAIT, (DWORD_PTR)&mciOpen);
if (mciError) if (mciError != 0)
{
return mciError; return mciError;
}
mciInfo.dwCallback = 0; mciInfo.dwCallback = 0;
mciInfo.lpstrReturn = lpFriendlyName; mciInfo.lpstrReturn = lpFriendlyName;
@ -388,17 +352,17 @@ GetDeviceFriendlyName(LPTSTR lpDeviceName, LPTSTR lpFriendlyName, DWORD dwFriend
return mciError; return mciError;
} }
static DWORD static MCIERROR
CloseMciDevice(VOID) CloseMciDevice(VOID)
{ {
MCIERROR mciError; MCIERROR mciError;
MCI_GENERIC_PARMS mciGeneric; MCI_GENERIC_PARMS mciGeneric;
if (bIsOpened) if (wDeviceId)
{ {
mciError = mciSendCommand(wDeviceId, MCI_CLOSE, MCI_WAIT, (DWORD_PTR)&mciGeneric); mciError = mciSendCommand(wDeviceId, MCI_CLOSE, MCI_WAIT, (DWORD_PTR)&mciGeneric);
if (mciError) return mciError; if (mciError != 0) return mciError;
bIsOpened = FALSE; wDeviceId = 0;
} }
DisableMenuItems(); DisableMenuItems();
@ -406,18 +370,17 @@ CloseMciDevice(VOID)
return 0; return 0;
} }
static DWORD static MCIERROR
OpenMciDevice(HWND hwnd, LPTSTR lpType, LPTSTR lpFileName) OpenMciDevice(HWND hwnd, LPTSTR lpType, LPTSTR lpFileName)
{ {
MCIERROR mciError; MCIERROR mciError;
MCI_STATUS_PARMS mciStatus; MCI_STATUS_PARMS mciStatus;
MCI_OPEN_PARMS mciOpen; MCI_OPEN_PARMS mciOpen;
TCHAR szNewTitle[MAX_PATH + 128]; DWORD dwFlags = MCI_OPEN_ELEMENT | MCI_WAIT;
TCHAR szNewTitle[MAX_PATH + 3 + 256];
if (bIsOpened) if (wDeviceId)
{
CloseMciDevice(); CloseMciDevice();
}
mciOpen.lpstrDeviceType = lpType; mciOpen.lpstrDeviceType = lpType;
mciOpen.lpstrElementName = lpFileName; mciOpen.lpstrElementName = lpFileName;
@ -425,19 +388,18 @@ OpenMciDevice(HWND hwnd, LPTSTR lpType, LPTSTR lpFileName)
mciOpen.wDeviceID = 0; mciOpen.wDeviceID = 0;
mciOpen.lpstrAlias = NULL; mciOpen.lpstrAlias = NULL;
mciError = mciSendCommand(0, MCI_OPEN, MCI_OPEN_TYPE | MCI_OPEN_ELEMENT | MCI_WAIT, (DWORD_PTR)&mciOpen); if (lpType)
dwFlags |= MCI_OPEN_TYPE;
mciError = mciSendCommand(0, MCI_OPEN, dwFlags, (DWORD_PTR)&mciOpen);
if (mciError != 0) if (mciError != 0)
{
return mciError; return mciError;
}
mciStatus.dwItem = MCI_STATUS_LENGTH; mciStatus.dwItem = MCI_STATUS_LENGTH;
mciError = mciSendCommand(mciOpen.wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD_PTR)&mciStatus); mciError = mciSendCommand(mciOpen.wDeviceID, MCI_STATUS, MCI_STATUS_ITEM | MCI_WAIT, (DWORD_PTR)&mciStatus);
if (mciError != 0) if (mciError != 0)
{
return mciError; return mciError;
}
SendMessage(hTrackBar, TBM_SETRANGEMIN, (WPARAM)TRUE, (LPARAM)1); SendMessage(hTrackBar, TBM_SETRANGEMIN, (WPARAM)TRUE, (LPARAM)1);
SendMessage(hTrackBar, TBM_SETRANGEMAX, (WPARAM)TRUE, (LPARAM)mciStatus.dwReturn); SendMessage(hTrackBar, TBM_SETRANGEMAX, (WPARAM)TRUE, (LPARAM)mciStatus.dwReturn);
@ -467,7 +429,6 @@ OpenMciDevice(HWND hwnd, LPTSTR lpType, LPTSTR lpFileName)
MaxFilePos = mciStatus.dwReturn; MaxFilePos = mciStatus.dwReturn;
wDeviceId = mciOpen.wDeviceID; wDeviceId = mciOpen.wDeviceID;
bIsOpened = TRUE;
StringCbCopy(szPrevFile, sizeof(szPrevFile), lpFileName); StringCbCopy(szPrevFile, sizeof(szPrevFile), lpFileName);
EnableMenuItems(hwnd); EnableMenuItems(hwnd);
@ -475,21 +436,52 @@ OpenMciDevice(HWND hwnd, LPTSTR lpType, LPTSTR lpFileName)
return 0; return 0;
} }
static DWORD
GetDeviceMode(HWND hwnd)
{
MCIERROR mciError;
MCI_STATUS_PARMS mciStatus;
mciStatus.dwItem = MCI_STATUS_MODE;
mciError = mciSendCommand(wDeviceId, MCI_STATUS, MCI_WAIT | MCI_STATUS_ITEM, (DWORD_PTR)&mciStatus);
if (mciError != 0)
{
ShowMCIError(hwnd, mciError);
return MCI_MODE_NOT_READY;
}
return mciStatus.dwReturn;
}
static VOID static VOID
StopPlayback(HWND hwnd) StopPlayback(HWND hwnd)
{ {
if (bIsOpened) MCIERROR mciError;
{ MCI_GENERIC_PARMS mciGeneric;
if (wDeviceId == 0) return;
SendMessage(hTrackBar, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)1); SendMessage(hTrackBar, TBM_SETPOS, (WPARAM)TRUE, (LPARAM)1);
KillTimer(hwnd, IDT_PLAYTIMER); KillTimer(hwnd, IDT_PLAYTIMER);
if (bIsSingleWindow) mciGeneric.dwCallback = (DWORD_PTR)hwnd;
mciError = mciSendCommand(wDeviceId, MCI_STOP, MCI_NOTIFY, (DWORD_PTR)&mciGeneric);
if (mciError != 0)
{ {
SwitchViewMode(hwnd); ShowMCIError(hwnd, mciError);
return;
} }
CloseMciDevice(); mciSendCommand(wDeviceId, MCI_SEEK, MCI_WAIT | MCI_SEEK_TO_START, 0);
}
SendMessage(hToolBar,
TB_SETCMDID,
0,
IDC_PLAY);
SendMessage(hToolBar,
TB_CHANGEBITMAP,
IDC_PLAY,
IDB_PLAYICON - IDB_PLAYICON);
} }
static VOID static VOID
@ -499,8 +491,8 @@ SeekPlayback(HWND hwnd, DWORD dwNewPos)
MCI_SEEK_PARMS mciSeek; MCI_SEEK_PARMS mciSeek;
MCI_PLAY_PARMS mciPlay; MCI_PLAY_PARMS mciPlay;
if (bIsOpened) if (wDeviceId == 0) return;
{
mciSeek.dwTo = (DWORD_PTR)dwNewPos; mciSeek.dwTo = (DWORD_PTR)dwNewPos;
mciError = mciSendCommand(wDeviceId, MCI_SEEK, MCI_WAIT | MCI_TO, (DWORD_PTR)&mciSeek); mciError = mciSendCommand(wDeviceId, MCI_SEEK, MCI_WAIT | MCI_TO, (DWORD_PTR)&mciSeek);
if (mciError != 0) if (mciError != 0)
@ -515,7 +507,6 @@ SeekPlayback(HWND hwnd, DWORD dwNewPos)
ShowMCIError(hwnd, mciError); ShowMCIError(hwnd, mciError);
} }
} }
}
static VOID static VOID
SeekBackPlayback(HWND hwnd) SeekBackPlayback(HWND hwnd)
@ -523,7 +514,7 @@ SeekBackPlayback(HWND hwnd)
MCI_STATUS_PARMS mciStatus; MCI_STATUS_PARMS mciStatus;
DWORD dwNewPos; DWORD dwNewPos;
if (!bIsOpened) return; if (wDeviceId == 0) return;
mciStatus.dwItem = MCI_STATUS_POSITION; mciStatus.dwItem = MCI_STATUS_POSITION;
mciSendCommand(wDeviceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&mciStatus); mciSendCommand(wDeviceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&mciStatus);
@ -546,7 +537,7 @@ SeekForwPlayback(HWND hwnd)
MCI_STATUS_PARMS mciStatus; MCI_STATUS_PARMS mciStatus;
DWORD dwNewPos; DWORD dwNewPos;
if (!bIsOpened) return; if (wDeviceId == 0) return;
mciStatus.dwItem = MCI_STATUS_POSITION; mciStatus.dwItem = MCI_STATUS_POSITION;
mciSendCommand(wDeviceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&mciStatus); mciSendCommand(wDeviceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&mciStatus);
@ -564,37 +555,46 @@ SeekForwPlayback(HWND hwnd)
} }
static VOID static VOID
PausePlayback(HWND hwnd) TogglePlaybackState(HWND hwnd)
{ {
MCIERROR mciError; MCIERROR mciError;
MCI_GENERIC_PARMS mciGeneric; MCI_GENERIC_PARMS mciGeneric;
DWORD dwMode;
ULONG idBmp = IDB_PLAYICON;
ULONG idCmd = IDC_PLAY;
if (bIsOpened) if (wDeviceId == 0) return;
dwMode = GetDeviceMode(hwnd);
if (dwMode == MCI_MODE_PLAY)
{ {
mciError = mciSendCommand(wDeviceId, MCI_PAUSE, MCI_WAIT, (DWORD_PTR)&mciGeneric); mciGeneric.dwCallback = (DWORD_PTR)hwnd;
mciError = mciSendCommand(wDeviceId, MCI_PAUSE, MCI_NOTIFY, (DWORD_PTR)&mciGeneric);
idBmp = IDB_PLAYICON;
idCmd = IDC_PLAY;
}
else if (dwMode == MCI_MODE_PAUSE)
{
mciGeneric.dwCallback = (DWORD_PTR)hwnd;
mciError = mciSendCommand(wDeviceId, MCI_RESUME, MCI_NOTIFY, (DWORD_PTR)&mciGeneric);
idBmp = IDB_PAUSEICON;
idCmd = IDC_PAUSE;
}
if (mciError != 0) if (mciError != 0)
{ {
ShowMCIError(hwnd, mciError); ShowMCIError(hwnd, mciError);
} return;
bIsPaused = TRUE;
}
} }
static VOID SendMessage(hToolBar,
ResumePlayback(HWND hwnd) TB_SETCMDID,
{ 0,
MCIERROR mciError; idCmd);
MCI_GENERIC_PARMS mciGeneric; SendMessage(hToolBar,
TB_CHANGEBITMAP,
if (bIsPaused) idCmd,
{ idBmp - IDB_PLAYICON);
mciError = mciSendCommand(wDeviceId, MCI_RESUME, MCI_WAIT, (DWORD_PTR)&mciGeneric);
if (mciError != 0)
{
ShowMCIError(hwnd, mciError);
}
bIsPaused = FALSE;
}
} }
static VOID static VOID
@ -617,7 +617,7 @@ PlayTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
MCI_PLAY_PARMS mciPlay; MCI_PLAY_PARMS mciPlay;
DWORD dwPos; DWORD dwPos;
if (!bIsOpened) KillTimer(hwnd, IDT_PLAYTIMER); if (wDeviceId == 0) KillTimer(hwnd, IDT_PLAYTIMER);
mciStatus.dwItem = MCI_STATUS_POSITION; mciStatus.dwItem = MCI_STATUS_POSITION;
mciSendCommand(wDeviceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&mciStatus); mciSendCommand(wDeviceId, MCI_STATUS, MCI_STATUS_ITEM, (DWORD_PTR)&mciStatus);
@ -643,13 +643,53 @@ PlayTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
} }
static VOID static VOID
PlayFile(HWND hwnd, LPTSTR lpFileName) StartPlayback(HWND hwnd)
{ {
MCI_PLAY_PARMS mciPlay;
TCHAR szLocalFileName[MAX_PATH];
TCHAR szDeviceName[MAX_PATH];
DWORD dwSize;
MCIERROR mciError; MCIERROR mciError;
MCI_PLAY_PARMS mciPlay;
SetTimer(hwnd, IDT_PLAYTIMER, 100, (TIMERPROC)PlayTimerProc);
mciSendCommand(wDeviceId, MCI_SEEK, MCI_WAIT | MCI_SEEK_TO_START, 0);
mciPlay.dwCallback = (DWORD_PTR)hwnd;
mciPlay.dwFrom = 0;
mciPlay.dwTo = MaxFilePos;
mciError = mciSendCommand(wDeviceId, MCI_PLAY, MCI_NOTIFY | MCI_FROM /*| MCI_TO*/, (DWORD_PTR)&mciPlay);
if (mciError != 0)
{
ShowMCIError(hwnd, mciError);
return;
}
SendMessage(hToolBar,
TB_SETCMDID,
0,
IDC_PAUSE);
SendMessage(hToolBar,
TB_CHANGEBITMAP,
IDC_PAUSE,
IDB_PAUSEICON - IDB_PLAYICON);
}
static VOID
CloseMediaFile(HWND hwnd)
{
StopPlayback(hwnd);
if (bIsSingleWindow)
SwitchViewMode(hwnd);
CloseMciDevice();
SetWindowText(hwnd, szAppTitle);
}
static VOID
OpenMediaFile(HWND hwnd, LPTSTR lpFileName)
{
MCIERROR mciError;
TCHAR szLocalFileName[MAX_PATH];
if (lpFileName == NULL) if (lpFileName == NULL)
{ {
@ -664,47 +704,19 @@ PlayFile(HWND hwnd, LPTSTR lpFileName)
} }
if (GetFileAttributes(szLocalFileName) == INVALID_FILE_ATTRIBUTES) if (GetFileAttributes(szLocalFileName) == INVALID_FILE_ATTRIBUTES)
{
return; return;
}
dwSize = sizeof(szDeviceName) - 2; if (wDeviceId)
_tcsnset(szDeviceName, _T('\0'), dwSize / sizeof(TCHAR)); CloseMediaFile(hwnd);
if (!IsSupportedFileExtension(szLocalFileName, szDeviceName, &dwSize)) mciError = OpenMciDevice(hwnd, NULL, szLocalFileName);
{
TCHAR szErrorMessage[256];
LoadString(hInstance, IDS_UNKNOWNFILEEXT, szErrorMessage, sizeof(szErrorMessage) / sizeof(szErrorMessage[0]));
MessageBox(hwnd, szErrorMessage, szAppTitle, MB_OK | MB_ICONEXCLAMATION);
return;
}
if (bIsOpened)
{
StopPlayback(hwnd);
}
mciError = OpenMciDevice(hwnd, szDeviceName, szLocalFileName);
if (mciError != 0) if (mciError != 0)
{ {
ShowMCIError(hwnd, mciError); ShowMCIError(hwnd, mciError);
return; return;
} }
SetTimer(hwnd, IDT_PLAYTIMER, 100, (TIMERPROC) PlayTimerProc); StartPlayback(hwnd);
mciSendCommand(wDeviceId, MCI_SEEK, MCI_WAIT | MCI_SEEK_TO_START, 0);
mciPlay.dwCallback = (DWORD_PTR)hwnd;
mciPlay.dwFrom = 0;
mciPlay.dwTo = MaxFilePos;
mciError = mciSendCommand(wDeviceId, MCI_PLAY, MCI_NOTIFY | MCI_FROM /*| MCI_TO*/, (DWORD_PTR)&mciPlay);
if (mciError != 0)
{
ShowMCIError(hwnd, mciError);
}
} }
static VOID static VOID
@ -733,7 +745,7 @@ BuildFileFilter(VOID)
HKEY hKey = NULL; HKEY hKey = NULL;
/* Always load the default (all files) filter */ /* Always load the default (all files) filter */
LoadString(hInstance, IDS_ALL_TYPES_FILTER, szDefaultFilter, sizeof(szDefaultFilter) / sizeof(szDefaultFilter[0])); LoadString(hInstance, IDS_ALL_TYPES_FILTER, szDefaultFilter, ARRAYSIZE(szDefaultFilter));
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\MCI Extensions"), 0, KEY_READ, &hKey) != ERROR_SUCCESS) if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\MCI Extensions"), 0, KEY_READ, &hKey) != ERROR_SUCCESS)
{ {
@ -749,9 +761,7 @@ BuildFileFilter(VOID)
szExtensionList = malloc(dwMaskLen * sizeof(TCHAR)); szExtensionList = malloc(dwMaskLen * sizeof(TCHAR));
if (!szExtensionList) if (!szExtensionList)
{
goto Failure; goto Failure;
}
dwNumDevices = GetNumDevices(); dwNumDevices = GetNumDevices();
@ -763,21 +773,15 @@ BuildFileFilter(VOID)
szFilter = malloc(dwFilterSize); szFilter = malloc(dwFilterSize);
if (!szFilter) if (!szFilter)
{
goto Failure; goto Failure;
}
szExtension = malloc((dwValueNameLen + 1) * sizeof(TCHAR)); szExtension = malloc((dwValueNameLen + 1) * sizeof(TCHAR));
if (!szExtension) if (!szExtension)
{
goto Failure; goto Failure;
}
szDevice = malloc(dwValueDataSize + sizeof(TCHAR)); szDevice = malloc(dwValueDataSize + sizeof(TCHAR));
if (!szDevice) if (!szDevice)
{
goto Failure; goto Failure;
}
ZeroMemory(szFilter, dwFilterSize); ZeroMemory(szFilter, dwFilterSize);
@ -813,7 +817,7 @@ BuildFileFilter(VOID)
if (RegEnumValue(hKey, i, szExtension, &dwExtensionLen, NULL, NULL, (LPBYTE)szDevice, &dwDeviceSize) == ERROR_SUCCESS) if (RegEnumValue(hKey, i, szExtension, &dwExtensionLen, NULL, NULL, (LPBYTE)szDevice, &dwDeviceSize) == ERROR_SUCCESS)
{ {
CharLowerBuff(szDevice, dwDeviceSize / sizeof(TCHAR)); CharLowerBuff(szDevice, dwDeviceSize / sizeof(TCHAR));
CharLowerBuff(szDeviceName, sizeof(szDeviceName) / sizeof(szDeviceName[0])); CharLowerBuff(szDeviceName, ARRAYSIZE(szDeviceName));
if (_tcscmp(szDeviceName, szDevice) == 0) if (_tcscmp(szDeviceName, szDevice) == 0)
{ {
CharLowerBuff(szExtension, dwExtensionLen); CharLowerBuff(szExtension, dwExtensionLen);
@ -916,7 +920,7 @@ OpenFileDialog(HWND hwnd)
ZeroMemory(&OpenFileName, sizeof(OpenFileName)); ZeroMemory(&OpenFileName, sizeof(OpenFileName));
if (!GetCurrentDirectory(sizeof(szCurrentDir) / sizeof(szCurrentDir[0]), szCurrentDir)) if (!GetCurrentDirectory(ARRAYSIZE(szCurrentDir), szCurrentDir))
{ {
StringCbCopy(szCurrentDir, sizeof(szCurrentDir), _T("c:\\")); StringCbCopy(szCurrentDir, sizeof(szCurrentDir), _T("c:\\"));
} }
@ -926,15 +930,15 @@ OpenFileDialog(HWND hwnd)
OpenFileName.hInstance = hInstance; OpenFileName.hInstance = hInstance;
OpenFileName.lpstrFilter = szFilter; OpenFileName.lpstrFilter = szFilter;
OpenFileName.lpstrFile = szFile; OpenFileName.lpstrFile = szFile;
OpenFileName.nMaxFile = sizeof(szFile) / sizeof(szFile[0]); OpenFileName.nMaxFile = ARRAYSIZE(szFile);
OpenFileName.lpstrInitialDir = szCurrentDir; OpenFileName.lpstrInitialDir = szCurrentDir;
OpenFileName.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_SHAREAWARE; OpenFileName.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_SHAREAWARE;
OpenFileName.lpstrDefExt = _T("\0"); OpenFileName.lpstrDefExt = _T("\0");
if (GetOpenFileName(&OpenFileName)) if (!GetOpenFileName(&OpenFileName))
{ return;
PlayFile(hwnd, OpenFileName.lpstrFile);
} OpenMediaFile(hwnd, OpenFileName.lpstrFile);
} }
LRESULT CALLBACK LRESULT CALLBACK
@ -955,9 +959,9 @@ MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
TCHAR droppedfile[MAX_PATH]; TCHAR droppedfile[MAX_PATH];
drophandle = (HDROP)wParam; drophandle = (HDROP)wParam;
DragQueryFile(drophandle, 0, droppedfile, sizeof(droppedfile) / sizeof(droppedfile[0])); DragQueryFile(drophandle, 0, droppedfile, ARRAYSIZE(droppedfile));
DragFinish(drophandle); DragFinish(drophandle);
PlayFile(hwnd, droppedfile); OpenMediaFile(hwnd, droppedfile);
break; break;
} }
@ -995,6 +999,9 @@ MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
case IDC_FORWARD: case IDC_FORWARD:
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_FORWARD); lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_FORWARD);
break; break;
case IDC_PAUSE:
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PAUSE);
break;
} }
break; break;
} }
@ -1056,7 +1063,7 @@ MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{ {
if (hTrackBar == (HWND)lParam) if (hTrackBar == (HWND)lParam)
{ {
if (bIsOpened) if (wDeviceId)
{ {
DWORD dwNewPos = (DWORD)SendMessage(hTrackBar, TBM_GETPOS, 0, 0); DWORD dwNewPos = (DWORD)SendMessage(hTrackBar, TBM_GETPOS, 0, 0);
SeekPlayback(hwnd, dwNewPos); SeekPlayback(hwnd, dwNewPos);
@ -1083,20 +1090,23 @@ MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
switch (LOWORD(wParam)) switch (LOWORD(wParam))
{ {
case IDC_PLAY: case IDC_PLAY:
case IDC_PAUSE:
{ {
if (bIsOpened) if (wDeviceId)
{ {
if (bIsPaused) DWORD dwMode = GetDeviceMode(hwnd);
ResumePlayback(hwnd);
else if ((dwMode == MCI_MODE_STOP) || (dwMode == MCI_MODE_OPEN))
PausePlayback(hwnd); StartPlayback(hwnd);
else if ((dwMode == MCI_MODE_PAUSE) || (dwMode = MCI_MODE_PLAY))
TogglePlaybackState(hwnd);
} }
else else
{ {
if (szPrevFile[0] == _T('\0')) if (szPrevFile[0] == _T('\0'))
OpenFileDialog(hwnd); OpenFileDialog(hwnd);
else else
PlayFile(hwnd, NULL); OpenMediaFile(hwnd, NULL);
} }
break; break;
} }
@ -1127,8 +1137,8 @@ MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
return 0; return 0;
case IDM_CLOSE_FILE: case IDM_CLOSE_FILE:
StopPlayback(hwnd);
szPrevFile[0] = _T('\0'); szPrevFile[0] = _T('\0');
CloseMediaFile(hwnd);
break; break;
case IDM_REPEAT: case IDM_REPEAT:
@ -1174,7 +1184,7 @@ MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
} }
case WM_DESTROY: case WM_DESTROY:
StopPlayback(hwnd); CloseMediaFile(hwnd);
PostQuitMessage(0); PostQuitMessage(0);
return 0; return 0;
} }
@ -1194,9 +1204,9 @@ _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdShow)
hInstance = hInst; hInstance = hInst;
LoadString(hInstance, IDS_APPTITLE, szAppTitle, sizeof(szAppTitle) / sizeof(szAppTitle[0])); LoadString(hInstance, IDS_APPTITLE, szAppTitle, ARRAYSIZE(szAppTitle));
WndClass.cbSize = sizeof(WNDCLASSEX); WndClass.cbSize = sizeof(WndClass);
WndClass.lpszClassName = szClassName; WndClass.lpszClassName = szClassName;
WndClass.lpfnWndProc = MainWndProc; WndClass.lpfnWndProc = MainWndProc;
WndClass.hInstance = hInstance; WndClass.hInstance = hInstance;
@ -1247,7 +1257,7 @@ _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, INT nCmdShow)
ShowWindow(hwnd, SW_SHOW); ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd); UpdateWindow(hwnd);
PlayFile(hwnd, lpCmdLine); OpenMediaFile(hwnd, lpCmdLine);
/* Message Loop */ /* Message Loop */
while (GetMessage(&msg, NULL, 0, 0)) while (GetMessage(&msg, NULL, 0, 0))

View file

@ -14,17 +14,3 @@
#include <strsafe.h> #include <strsafe.h>
#include "resource.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;

View file

@ -22,10 +22,10 @@
#define IDS_TOOLTIP_SEEKBACK 105 #define IDS_TOOLTIP_SEEKBACK 105
#define IDS_TOOLTIP_SEEKFORW 106 #define IDS_TOOLTIP_SEEKFORW 106
#define IDS_TOOLTIP_FORWARD 107 #define IDS_TOOLTIP_FORWARD 107
#define IDS_ALL_TYPES_FILTER 108 #define IDS_TOOLTIP_PAUSE 108
#define IDS_PLAY 109 #define IDS_ALL_TYPES_FILTER 109
#define IDS_DEFAULTMCIERRMSG 110 #define IDS_PLAY 110
#define IDS_UNKNOWNFILEEXT 111 #define IDS_DEFAULTMCIERRMSG 111
/* Menu */ /* Menu */
#define IDR_MAINMENU 500 #define IDR_MAINMENU 500
@ -60,3 +60,4 @@
#define IDC_SEEKBACK 1504 #define IDC_SEEKBACK 1504
#define IDC_SEEKFORW 1505 #define IDC_SEEKFORW 1505
#define IDC_FORWARD 1506 #define IDC_FORWARD 1506
#define IDC_PAUSE 1507