Skip to content

Commit

Permalink
1.0.0.2
Browse files Browse the repository at this point in the history
- Clicking middle logo now toggles between play/pause (for audio playback).
- Removed double click option on main window.
- Moved F11 fullscreen toggle to accelerator table instead of WM_KEYDOWN.
- Fix menu activation not working when pressing Alt key + menu key (IsDialogMessage was the culprit).
- Fix for stepping past duration of media file with play speed increase and step 10.
- Fix for SeekBar position still showing after end of media when play speed is increased.
- Added EN, DE, FR, PL, IT languages using google translate (any mistakes let me know, or requests for languages).
- Added language menu item on menu bar and loading menus based on language selection.
- Made language specific versions of main menu.
- Moved context menu to language specific versions.
- Language setting saved in ini file, and applied when starting MediaPlayer.
- Moved strings (tooltips etc) to string table resource for language change processing.
  • Loading branch information
mrfearless committed Sep 4, 2024
1 parent 4198720 commit 9962953
Show file tree
Hide file tree
Showing 75 changed files with 6,529 additions and 1,015 deletions.
184 changes: 120 additions & 64 deletions MediaPlayer-x64/MediaPlayer.asm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ MP_PATTERN_BACKGROUND EQU 1 ; comment out to allow pattern backgrounds

include MediaPlayer.inc

include MediaPlayerStrings.asm ; language strings
include MediaPlayerIni.asm ; ini file settings
include MediaPlayerAbout.asm ; About dialog box

Expand Down Expand Up @@ -90,7 +91,7 @@ WinMain PROC FRAME hInst:HINSTANCE, hPrev:HINSTANCE, CmdLine:LPSTR, iShow:DWORD
LOCAL wcex:WNDCLASSEX

mov wcex.cbSize, sizeof WNDCLASSEX
mov wcex.style, CS_DBLCLKS or CS_HREDRAW or CS_VREDRAW
mov wcex.style, CS_HREDRAW or CS_VREDRAW ;CS_DBLCLKS or
lea rax, WndProc
mov wcex.lpfnWndProc, rax
mov wcex.cbClsExtra, 0
Expand Down Expand Up @@ -119,11 +120,11 @@ WinMain PROC FRAME hInst:HINSTANCE, hPrev:HINSTANCE, CmdLine:LPSTR, iShow:DWORD
.BREAK .IF (!rax)
Invoke TranslateAccelerator, hWnd, hAcc, addr msg
.IF rax == 0
Invoke IsDialogMessage, hWnd, addr msg
.IF rax == 0
;Invoke IsDialogMessage, hWnd, addr msg
;.IF rax == 0
Invoke TranslateMessage, addr msg
Invoke DispatchMessage, addr msg
.ENDIF
;.ENDIF
.ENDIF
.ENDW
Expand All @@ -138,75 +139,73 @@ WndProc PROC FRAME hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
mov eax, uMsg
.IF eax == WM_INITDIALOG
push hWin
pop hWnd
Invoke GUIInit, hWin
.ELSEIF eax == WM_COMMAND
mov rax, wParam
and rax, 0FFFFh
.IF eax == IDM_FILE_EXIT
.IF eax == IDM_FILE_Exit || eax == ACC_FILE_EXIT
Invoke SendMessage, hWin, WM_CLOSE, 0, 0
.ELSEIF eax == IDM_HELP_ABOUT
.ELSEIF eax == IDM_HELP_About
Invoke DialogBoxParam, hInstance, IDD_AboutDlg, hWin, Addr MediaPlayerAboutDlgProc, NULL
.ELSEIF eax == IDM_FILE_OPEN || eax == IDM_CM_Open || eax == ACC_FILE_OPEN
.ELSEIF eax == IDM_FILE_Open || eax == ACC_FILE_OPEN
Invoke MediaPlayerBrowseForFile, hMainWindow
.IF eax == TRUE
Invoke MediaPlayerOpenFile, hMainWindow, lpszMediaFileName
.ENDIF
.ELSEIF eax == IDM_CM_Stop || eax == IDM_MC_STOP || eax == ACC_MC_STOP
.ELSEIF eax == IDM_MC_Stop || eax == ACC_MC_STOP
.IF pMI != 0
Invoke MFPMediaPlayer_Stop, pMP
.ENDIF
.ELSEIF eax == IDM_CM_Pause || eax == IDM_MC_PAUSE
.ELSEIF eax == IDM_MC_Pause
.IF pMI != 0
Invoke MFPMediaPlayer_Pause, pMP
Invoke SetFocus, hMediaPlayerWindow
.ENDIF
.ELSEIF eax == IDM_CM_Play || eax == IDM_MC_PLAY || eax == ACC_MC_PLAY
.ELSEIF eax == IDM_MC_Play || eax == ACC_MC_PLAY
.IF pMI != 0
Invoke MFPMediaPlayer_Play, pMP
.ENDIF
.ELSEIF eax == IDM_CM_Step || eax == IDM_MC_STEP
.ELSEIF eax == IDM_MC_Step
.IF pMI != 0
Invoke MFPMediaPlayer_Step, pMP
.ENDIF
.ELSEIF eax == IDM_CM_Fullscreen || eax == IDM_MC_FULLSCREEN
.ELSEIF eax == IDM_MC_Fullscreen || eax == ACC_MC_FULLSCREEN
Invoke GUIToggleFullscreen, hMainWindow
.ELSEIF eax == IDM_CM_Exit || eax == ACC_FILE_EXIT
Invoke SendMessage, hWin, WM_CLOSE, 0, 0
;----------------------------------------------------------------------
; Set Aspect Ratio
;----------------------------------------------------------------------
.ELSEIF eax == IDM_AM_STRETCH
.ELSEIF eax == IDM_MC_VA_Stretch
.IF pMP != 0
Invoke MFPMediaPlayer_SetAspectRatioMode, pMP, MFVideoARMode_None
.IF rax == TRUE
Invoke MFPMediaPlayer_UpdateVideo, pMP
Invoke UpdateWindow, hMediaPlayerWindow
Invoke SendMessage, hMPC_ToolbarScreen, TB_CHANGEBITMAP, IDC_MPC_Aspect, TBID_MPC_A_STRETCH
;Invoke SendMessage, hMPC_ToolbarScreen, TB_CHANGEBITMAP, IDC_MPC_Aspect, TBID_MPC_A_STRETCH
.ELSE
IFDEF DEBUG64
PrintText 'MFVideoARMode_None failed'
ENDIF
.ENDIF
.ENDIF
.ELSEIF eax == IDM_AM_NORMAL
.ELSEIF eax == IDM_MC_VA_Normal
.IF pMP != 0
Invoke MFPMediaPlayer_SetAspectRatioMode, pMP, (MFVideoARMode_PreservePixel or MFVideoARMode_PreservePicture)
.IF rax == TRUE
Invoke MFPMediaPlayer_UpdateVideo, pMP
Invoke UpdateWindow, hMediaPlayerWindow
Invoke SendMessage, hMPC_ToolbarScreen, TB_CHANGEBITMAP, IDC_MPC_Aspect, TBID_MPC_A_NORMAL
;Invoke SendMessage, hMPC_ToolbarScreen, TB_CHANGEBITMAP, IDC_MPC_Aspect, TBID_MPC_A_NORMAL
.ELSE
IFDEF DEBUG64
PrintText 'MFVideoARMode_PreservePixel or MFVideoARMode_PreservePicture failed'
Expand All @@ -217,28 +216,67 @@ WndProc PROC FRAME hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
;----------------------------------------------------------------------
; Step 10 Seconds & Playback Speed
;----------------------------------------------------------------------
.ELSEIF eax == IDM_MC_STEP10B || eax == IDM_CM_Step10B || eax == ACC_MC_STEP10B
.ELSEIF eax == IDM_MC_Step10B || eax == ACC_MC_STEP10B
Invoke MPSBStepPosition, hMediaPlayerSeekBar, 10, FALSE
.ELSEIF eax == IDM_MC_STEP10F || eax == IDM_CM_Step10F || eax == ACC_MC_STEP10F
.ELSEIF eax == IDM_MC_Step10F || eax == ACC_MC_STEP10F
Invoke MPSBStepPosition, hMediaPlayerSeekBar, 10, TRUE
.ELSEIF eax == IDM_MC_SLOWER || eax == IDM_SM_Slower || eax == ACC_MC_SLOWER
.ELSEIF eax == IDM_MC_PS_Slower || eax == ACC_MC_SLOWER
.IF pMI != 0
xor rax, rax
mov eax, dwCurrentRate
shr eax, 1 ; /2
Invoke MFPMediaPlayer_SetRate, pMP, eax
.ENDIF
.ELSEIF eax == IDM_MC_FASTER || eax == IDM_SM_Faster || eax == ACC_MC_FASTER
.ELSEIF eax == IDM_MC_PS_Faster || eax == ACC_MC_FASTER
.IF pMI != 0
xor rax, rax
mov eax, dwCurrentRate
shl eax, 1 ; x2
Invoke MFPMediaPlayer_SetRate, pMP, eax
.ENDIF
;----------------------------------------------------------------------
; Language Menu
;----------------------------------------------------------------------
.ELSEIF eax == IDM_LANG_Default
.IF g_LangID != IDLANG_DEFAULT
mov g_LangID, IDLANG_DEFAULT
Invoke GUILanguageChange, hWin
.ENDIF
.ELSEIF eax == IDM_LANG_English
.IF g_LangID != IDLANG_ENGLISH
mov g_LangID, IDLANG_ENGLISH
Invoke GUILanguageChange, hWin
.ENDIF
.ELSEIF eax == IDM_LANG_French
.IF g_LangID != IDLANG_FRENCH
mov g_LangID, IDLANG_FRENCH
Invoke GUILanguageChange, hWin
.ENDIF
.ELSEIF eax == IDM_LANG_German
.IF g_LangID != IDLANG_GERMAN
mov g_LangID, IDLANG_GERMAN
Invoke GUILanguageChange, hWin
.ENDIF
.ELSEIF eax == IDM_LANG_Polish
.IF g_LangID != IDLANG_POLISH
mov g_LangID, IDLANG_POLISH
Invoke GUILanguageChange, hWin
.ENDIF
.ELSEIF eax == IDM_LANG_Italian
.IF g_LangID != IDLANG_ITALIAN
mov g_LangID, IDLANG_ITALIAN
Invoke GUILanguageChange, hWin
.ENDIF
;----------------------------------------------------------------------
; Most Recently Used (MRU) File On The File Menu
;----------------------------------------------------------------------
Expand All @@ -252,7 +290,7 @@ WndProc PROC FRAME hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.ENDIF
.ELSEIF eax == IDM_MRU_CLEAR
Invoke IniMRUClearListFromMenu, hWin, Addr MediaPlayerIniFile, IDM_FILE_EXIT
Invoke IniMRUClearListFromMenu, hWin, Addr MediaPlayerIniFile, IDM_FILE_Exit
.ENDIF

Expand All @@ -279,7 +317,7 @@ WndProc PROC FRAME hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
Invoke GUIIsClickInArea, hWin, MP_AREA_LOGO, lParam
.IF rax == TRUE
.IF pMI != 0
Invoke MFPMediaPlayer_Play, pMP
Invoke MFPMediaPlayer_Toggle, pMP
.ELSE
Invoke MediaPlayerBrowseForFile, hMainWindow
.IF rax == TRUE
Expand All @@ -294,42 +332,43 @@ WndProc PROC FRAME hWin:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
;--------------------------------------------------------------------------
; Quick way to open a file is to double click background
;--------------------------------------------------------------------------
.ELSEIF eax == WM_LBUTTONDBLCLK
Invoke GUIIsClickInArea, hWin, MP_AREA_PLAYER, lParam
.IF rax == TRUE
Invoke MediaPlayerBrowseForFile, hMainWindow
.IF rax == TRUE
Invoke MediaPlayerOpenFile, hMainWindow, lpszMediaFileName
.ENDIF
Invoke SetFocus, hMediaPlayerWindow
.ENDIF
mov rax, 0
ret
; .ELSEIF eax == WM_LBUTTONDBLCLK
; Invoke GUIIsClickInArea, hWin, MP_AREA_PLAYER, lParam
; .IF rax == TRUE
; Invoke MediaPlayerBrowseForFile, hMainWindow
; .IF rax == TRUE
; Invoke MediaPlayerOpenFile, hMainWindow, lpszMediaFileName
; .ENDIF
; Invoke SetFocus, hMediaPlayerWindow
; .ENDIF
; mov rax, 0
; ret
;--------------------------------------------------------------------------
; Toggle Fullscreen
;--------------------------------------------------------------------------
.ELSEIF eax == WM_GETDLGCODE
mov rax, DLGC_WANTALLKEYS or DLGC_WANTARROWS
ret

.ELSEIF eax == WM_KEYDOWN
.IF wParam == VK_F11
Invoke GUIToggleFullscreen, hMainWindow
mov rax, 0
ret
.ELSEIF wParam == VK_ESCAPE
.IF g_Fullscreen == TRUE
Invoke GUIFullscreenExit, hMainWindow
mov rax, 0
ret
.ELSE
Invoke DefWindowProc, hWin, uMsg, wParam, lParam
ret
.ENDIF
.ELSE
Invoke DefWindowProc, hWin, uMsg, wParam, lParam
ret
.ENDIF
; .ELSEIF eax == WM_GETDLGCODE
; mov rax, DLGC_WANTALLKEYS or DLGC_WANTARROWS
; ret
;
; .ELSEIF eax == WM_KEYDOWN
; .IF wParam == VK_F11
; Invoke GUIToggleFullscreen, hMainWindow
; mov rax, 0
; ret
; .ELSEIF wParam == VK_ESCAPE
; .IF g_Fullscreen == TRUE
; Invoke GUIFullscreenExit, hMainWindow
; mov rax, 0
; ret
; .ELSE
; Invoke DefWindowProc, hWin, uMsg, wParam, lParam
; ret
; .ENDIF
; .ELSE
; Invoke DefWindowProc, hWin, uMsg, wParam, lParam
; ret
; .ENDIF

;--------------------------------------------------------------------------
; Draw the background frame and logo
Expand Down Expand Up @@ -555,7 +594,7 @@ GUIInit PROC FRAME hWin:QWORD
mov hMainWindow, rax
Invoke IniFilenameCreate, Addr MediaPlayerIniFile, NULL
Invoke IniInit
Invoke IniInit, hWin, Addr MediaPlayerIniFile
Invoke GetWindowLongPtr, hWin, GWL_STYLE
mov g_PrevStyle, rax
Expand Down Expand Up @@ -586,11 +625,16 @@ GUIInit PROC FRAME hWin:QWORD
mov hPatternBrush, rax
ENDIF
;--------------------------------------------------------------------------
; Load language strings
;--------------------------------------------------------------------------
Invoke MPStringsInit
;--------------------------------------------------------------------------
; Menus
;--------------------------------------------------------------------------
Invoke GetMenu, hWin
mov hMediaPlayerMainMenu, rax
;Invoke GetMenu, hWin
;mov hMediaPlayerMainMenu, rax
Invoke MPMainMenuInit, hWin
Invoke MPContextMenuInit, hWin
Expand All @@ -601,7 +645,7 @@ GUIInit PROC FRAME hWin:QWORD
Invoke LoadImage, hInstance, BMP_FILE_MRU_CLEAR, IMAGE_BITMAP, 0, 0, LR_SHARED or LR_DEFAULTCOLOR
mov hBmpFileMRUClear, rax
Invoke IniMRULoadListToMenu, hWin, Addr MediaPlayerIniFile, IDM_FILE_EXIT, hBmpFileMRU, hBmpFileMRUClear
Invoke IniMRULoadListToMenu, hWin, Addr MediaPlayerIniFile, IDM_FILE_Exit, hBmpFileMRU, hBmpFileMRUClear
;--------------------------------------------------------------------------
; Set Fonts
Expand Down Expand Up @@ -1100,6 +1144,18 @@ GUIIsClickInArea PROC FRAME USES rbx hWin:QWORD, qwArea:QWORD, lParam:QWORD
ret
GUIIsClickInArea ENDP

;------------------------------------------------------------------------------
; GUILanguageChange - Updates menus and strings when language changes
;------------------------------------------------------------------------------
GUILanguageChange PROC FRAME hWin:QWORD
Invoke MPMainMenuInit, hWin
Invoke MPContextMenuInit, hWin
Invoke MPStringsInit
Invoke IniMRULoadListToMenu, hWin, Addr MediaPlayerIniFile, IDM_FILE_Exit, hBmpFileMRU, hBmpFileMRUClear
Invoke IniSetLanguage, hWin, Addr MediaPlayerIniFile
ret
GUILanguageChange ENDP

;------------------------------------------------------------------------------
; MediaPlayerBrowseForFile
;------------------------------------------------------------------------------
Expand Down Expand Up @@ -1146,7 +1202,7 @@ MediaPlayerOpenFile PROC FRAME hWin:QWORD, lpszMediaFile:QWORD
; Update MRU
Invoke IniMRUEntrySaveFilename, hWin, lpszMediaFile, Addr MediaPlayerIniFile
Invoke IniMRUReloadListToMenu, hWin, Addr MediaPlayerIniFile, IDM_FILE_EXIT, hBmpFileMRU, hBmpFileMRUClear
Invoke IniMRUReloadListToMenu, hWin, Addr MediaPlayerIniFile, IDM_FILE_Exit, hBmpFileMRU, hBmpFileMRUClear
.ELSE
Invoke GUISetTitleMediaLoaded, hWin, 0
Expand Down
Binary file modified MediaPlayer-x64/MediaPlayer.exe
Binary file not shown.
12 changes: 11 additions & 1 deletion MediaPlayer-x64/MediaPlayer.inc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ RGB MACRO red:REQ, green:REQ, blue:REQ
EXITM < red or green shl 8 or blue shl 16 >
ENDM

MAKELANGID MACRO usPrimaryLanguage:REQ, usSubLanguage:REQ
EXITM < (usSubLanguage SHL 10) OR (usPrimaryLanguage) >
ENDM

;------------------------------------------------------------------------------
; MediaPlayer Prototypes
;------------------------------------------------------------------------------
Expand All @@ -53,13 +57,17 @@ GUIAllowDragDrop PROTO bAllow:QWORD

GUISetDurationTime PROTO dwMilliseconds:DWORD
GUISetPositionTime PROTO dwMilliseconds:DWORD
GUIPositionUpdate PROTO dwPositionMS:DWORD, lParam:QWORD
GUISetTitleMediaLoaded PROTO hWin:QWORD, lpszMediaLoaded:QWORD

GUIToggleFullscreen PROTO hWin:QWORD
GUIFullscreenEnter PROTO hWin:QWORD
GUIFullscreenExit PROTO hWin:QWORD
GUIPositionUpdate PROTO dwPositionMS:DWORD, lParam:QWORD

GUIIsClickInArea PROTO hWin:QWORD, qwArea:QWORD, lParam:QWORD

GUILanguageChange PROTO hWin:QWORD

MediaPlayerBrowseForFile PROTO hWin:QWORD
MediaPlayerOpenFile PROTO hWin:QWORD, lpszMediaFile:QWORD
MediaPlayerContextMenu PROTO hWin:QWORD, wParam:WPARAM, lParam:LPARAM
Expand Down Expand Up @@ -180,6 +188,7 @@ ACC_MC_STEP10F EQU 905
ACC_MC_STEP10B EQU 906
ACC_MC_SLOWER EQU 907
ACC_MC_FASTER EQU 908
ACC_MC_FULLSCREEN EQU 909

MFPLAYER_LEFT EQU 10 ;9;14
MFPLAYER_TOP EQU 10 ;15;20
Expand Down Expand Up @@ -255,6 +264,7 @@ dwSlowestRate DD 0
dwFastestRate DD 0
dwCurrentRate DD 0

g_LangID DD 0
g_Playing DQ FALSE
g_Fullscreen DQ FALSE
g_wpPrev WINDOWPLACEMENT <>
Expand Down
Loading

0 comments on commit 9962953

Please sign in to comment.