mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 09:13:01 +00:00
[MPLAY32]: Some improvements to TogglePlaybackState(). By Ricardo Hanke.
CORE-9378 #resolve #comment Committed, thanks! svn path=/trunk/; revision=66744
This commit is contained in:
parent
83b0fdb098
commit
287b968fc1
1 changed files with 75 additions and 64 deletions
|
@ -27,7 +27,6 @@ BOOL bIsSingleWindow = FALSE;
|
||||||
UINT MaxFilePos = 0;
|
UINT MaxFilePos = 0;
|
||||||
RECT PrevWindowPos;
|
RECT PrevWindowPos;
|
||||||
|
|
||||||
|
|
||||||
/* ToolBar Buttons */
|
/* ToolBar Buttons */
|
||||||
static const TBBUTTON Buttons[] =
|
static const TBBUTTON Buttons[] =
|
||||||
{ /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
|
{ /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
|
||||||
|
@ -552,62 +551,6 @@ SeekForwPlayback(HWND hwnd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID
|
|
||||||
TogglePlaybackState(HWND hwnd)
|
|
||||||
{
|
|
||||||
MCIERROR mciError;
|
|
||||||
MCI_GENERIC_PARMS mciGeneric;
|
|
||||||
DWORD dwMode;
|
|
||||||
ULONG idBmp = IDB_PLAYICON;
|
|
||||||
ULONG idCmd = IDC_PLAY;
|
|
||||||
|
|
||||||
if (wDeviceId == 0) return;
|
|
||||||
|
|
||||||
dwMode = GetDeviceMode(hwnd);
|
|
||||||
if (dwMode == MCI_MODE_PLAY)
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
ShowMCIError(hwnd, mciError);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SendMessage(hToolBar,
|
|
||||||
TB_SETCMDID,
|
|
||||||
0,
|
|
||||||
idCmd);
|
|
||||||
SendMessage(hToolBar,
|
|
||||||
TB_CHANGEBITMAP,
|
|
||||||
idCmd,
|
|
||||||
idBmp - IDB_PLAYICON);
|
|
||||||
}
|
|
||||||
|
|
||||||
static VOID
|
|
||||||
ShowDeviceProperties(HWND hwnd)
|
|
||||||
{
|
|
||||||
MCIERROR mciError;
|
|
||||||
MCI_GENERIC_PARMS mciGeneric;
|
|
||||||
|
|
||||||
mciError = mciSendCommand(wDeviceId, MCI_CONFIGURE, MCI_WAIT, (DWORD_PTR)&mciGeneric);
|
|
||||||
if (mciError != 0)
|
|
||||||
{
|
|
||||||
ShowMCIError(hwnd, mciError);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID CALLBACK
|
VOID CALLBACK
|
||||||
PlayTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
|
PlayTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
|
||||||
{
|
{
|
||||||
|
@ -671,6 +614,78 @@ StartPlayback(HWND hwnd)
|
||||||
IDB_PAUSEICON - IDB_PLAYICON);
|
IDB_PAUSEICON - IDB_PLAYICON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VOID
|
||||||
|
TogglePlaybackState(HWND hwnd)
|
||||||
|
{
|
||||||
|
MCIERROR mciError;
|
||||||
|
MCI_GENERIC_PARMS mciGeneric;
|
||||||
|
ULONG idBmp = IDB_PLAYICON;
|
||||||
|
ULONG idCmd = IDC_PLAY;
|
||||||
|
|
||||||
|
if (wDeviceId == 0) return;
|
||||||
|
|
||||||
|
switch (GetDeviceMode(hwnd))
|
||||||
|
{
|
||||||
|
case MCI_MODE_OPEN:
|
||||||
|
case MCI_MODE_STOP:
|
||||||
|
{
|
||||||
|
StartPlayback(hwnd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
case MCI_MODE_PLAY:
|
||||||
|
{
|
||||||
|
mciGeneric.dwCallback = (DWORD_PTR)hwnd;
|
||||||
|
mciError = mciSendCommand(wDeviceId, MCI_PAUSE, MCI_NOTIFY, (DWORD_PTR)&mciGeneric);
|
||||||
|
idBmp = IDB_PLAYICON;
|
||||||
|
idCmd = IDC_PLAY;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case MCI_MODE_PAUSE:
|
||||||
|
{
|
||||||
|
mciGeneric.dwCallback = (DWORD_PTR)hwnd;
|
||||||
|
mciError = mciSendCommand(wDeviceId, MCI_RESUME, MCI_NOTIFY, (DWORD_PTR)&mciGeneric);
|
||||||
|
idBmp = IDB_PAUSEICON;
|
||||||
|
idCmd = IDC_PAUSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mciError != 0)
|
||||||
|
{
|
||||||
|
ShowMCIError(hwnd, mciError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SendMessage(hToolBar,
|
||||||
|
TB_SETCMDID,
|
||||||
|
0,
|
||||||
|
idCmd);
|
||||||
|
SendMessage(hToolBar,
|
||||||
|
TB_CHANGEBITMAP,
|
||||||
|
idCmd,
|
||||||
|
idBmp - IDB_PLAYICON);
|
||||||
|
}
|
||||||
|
|
||||||
|
static VOID
|
||||||
|
ShowDeviceProperties(HWND hwnd)
|
||||||
|
{
|
||||||
|
MCIERROR mciError;
|
||||||
|
MCI_GENERIC_PARMS mciGeneric;
|
||||||
|
|
||||||
|
mciError = mciSendCommand(wDeviceId, MCI_CONFIGURE, MCI_WAIT, (DWORD_PTR)&mciGeneric);
|
||||||
|
if (mciError != 0)
|
||||||
|
{
|
||||||
|
ShowMCIError(hwnd, mciError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
CloseMediaFile(HWND hwnd)
|
CloseMediaFile(HWND hwnd)
|
||||||
{
|
{
|
||||||
|
@ -1012,7 +1027,6 @@ MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
{
|
{
|
||||||
RECT Rect;
|
RECT Rect;
|
||||||
UINT Size;
|
|
||||||
RECT ToolbarRect;
|
RECT ToolbarRect;
|
||||||
MCI_DGV_PUT_PARMS mciPut;
|
MCI_DGV_PUT_PARMS mciPut;
|
||||||
|
|
||||||
|
@ -1023,6 +1037,8 @@ MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
if (!bIsSingleWindow)
|
if (!bIsSingleWindow)
|
||||||
{
|
{
|
||||||
|
UINT Size;
|
||||||
|
|
||||||
Size = GetSystemMetrics(SM_CYMENU) + Rect.bottom;
|
Size = GetSystemMetrics(SM_CYMENU) + Rect.bottom;
|
||||||
MoveWindow(hTrackBar, 0, 0, LOWORD(lParam), HIWORD(lParam) - Size, TRUE);
|
MoveWindow(hTrackBar, 0, 0, LOWORD(lParam), HIWORD(lParam) - Size, TRUE);
|
||||||
}
|
}
|
||||||
|
@ -1079,12 +1095,7 @@ MainWndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
if (wDeviceId)
|
if (wDeviceId)
|
||||||
{
|
{
|
||||||
DWORD dwMode = GetDeviceMode(hwnd);
|
TogglePlaybackState(hwnd);
|
||||||
|
|
||||||
if ((dwMode == MCI_MODE_STOP) || (dwMode == MCI_MODE_OPEN))
|
|
||||||
StartPlayback(hwnd);
|
|
||||||
else if ((dwMode == MCI_MODE_PAUSE) || (dwMode = MCI_MODE_PLAY))
|
|
||||||
TogglePlaybackState(hwnd);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue