Jump to content

WINMM.DLL Media Player


CYCho
 Share

Recommended Posts

I recently bumped into winmm.dll and found that it was the resource file of Sound.au3 UDF for all of its audio functions. I was interested in learning its video funtions as well to find if it could replace WMPlayer.OCX in my zPlayer. I have been a bit dissatisfied with WMPlayer object because it required a resizing process for a simple toggle between play and pause. This made the video to flicker and it was annoying. That was the reason for going back to the earlier version of zPlayer, knowing that WMPlayer object embedded in IE may not be supported by Windows in the near future.

Edit: Attached is a media player based on wimm.dll. Much of the time I spent to make this player was on video playback. I foresee that this player will ultimately be the future version of my  zPlayer. I had a lot of fun working on this. And I have to say thank you to many of forum members for helping me out when I had difficulties. If an error is found, I would expect that you would kindly let me know. If you download the latest version, hopefully the error would have been corrected already.
 

(File updated on August 15, 2023) ==> Please visit here for the latest update.

WINMM.DLL Media Player.zip

Edited by CYCho
Link to comment
Share on other sites

I ran into an issue where it could not play the file due to a codec issue, however instead of exting the program, rather return back to the main gui.

Else
                        $sMsg = $sFile & @CRLF & @CRLF
                        $sMsg &= "This file cannot be loaded by this player. Please check if proper codec is installed." & @CRLF & @CRLF
                        $sMsg &= "Do you want to try again?"
                        Local $iRes = MsgBox(4, "Load error", $sMsg)
                        If $iRes = 7 Then
                            GUICtrlSetState($idFolder, $GUI_Enable)
                            Return _WinAPI_SetWindowPos($vcGUI, $HWND_BOTTOM, Default, Default, Default, Default, BitOR($SWP_NOACTIVATE, $SWP_SHOWWINDOW, $SWP_NOMOVE, $SWP_NOSIZE ))
                        Else
                            GUICtrlSetState($idFile, $GUI_Enable)
                            GUICtrlSetState($idFolder, $GUI_Enable)
                            Return
                        EndIf
                    EndIf

To me, when the program asks to try again, it will do so on the same file, when you state No, you telling it you want to load a different file.

Kind Regards
Skeletor

"Coffee: my defense against going postal."

Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI

Link to comment
Share on other sites

Also maybe you want to center the GUI

 

Global $hGUI, $guiWidth = 320, $guiHeight = 60, $guiMsg, $idTitle, $idStreamed, $idSlider, $idLength, $idRandom, $idPlay
Global $idPrevious, $idRepeat, $idNext, $idUp, $idDown, $idFile, $idFolder, $idNotes
$hGUI = GUICreate("WINMM.DLL Media Player", $guiWidth, $guiHeight, (@DesktopWidth - $guiWidth) /2, (@DesktopHeight - $guiHeight) /2)   ; Main GUI

 

Edited by Skeletor

Kind Regards
Skeletor

"Coffee: my defense against going postal."

Microsoft Office Splash Screen | Basic Notepad Program (Beginner) | Transparent Splash Screen | Full Screen UI

Link to comment
Share on other sites

I found that, in a long movie, the _Fullscreen() function needs some wait time between mciSendString("seek myMedia to " & $iPos) and mciSendString("play myMedia fullscreen"). Otherwise the fullscreen mode would start playing from position 0. 

Local $iPos = mciSendString("status myMedia position")
mciSendString("stop myMedia")
mciSendString("seek myMedia to " & $iPos)
Sleep(100)
mciSendString("play myMedia fullscreen")

 

Edited by CYCho
Link to comment
Share on other sites

  • 2 weeks later...

Recently @ioa747 showed us how to make a fullscreen GUI here. I asked myself if I could apply the code to my winmm.dll player. I found that, in order to do it, the video window should be opened in popup style to start with and make it a child of my own GUI so that I could resize and move the video window around. It was done and it works fine. But there is one difference between fullscreen mode offered by winmm.dll and the popup style fullscreen mode: the dll method keeps the aspect ratio of image, but the popup style ignores aspect ratio when in fullscreen. winmm.dll surrounds the image with black bars to keep the aspect ratio if the screen resolution is not exactly the same as the source's aspect ratio. I know that some people like it and some others don't. Anyway, I made a simple player with fullscreen mode in popup style and uploaded it in the first post of this topic.

This version does not have a GUI except for the video and totally depends on hotkeys for basic operation. The script is amply commented, so I hope it is pretty easy to read.

Edit: This feature was integrated into the original code.

Edited by CYCho
Link to comment
Share on other sites

I just uploaded, in the first post of this topic, a revised version of this player. A lot of improvements were made in maximized and fullscreen mode of video window and in graphical controls overlayed on video window. I also corrected the error in calculation of total and streamed lengths: I found that some files have number of frames instead of milliseconds as the length. I had to forcefully  set the timer format to milliseconds before obtaining the length.

Link to comment
Share on other sites

Thanks for sharing!

Using the script in the 1st post tagged with, (Updated at 07:30 of May 31, 2023 UTC)

 In this release, I have not added any GUI scaling at all. I opted to just do some subtle changes to the main GUI only to make it more presentable with all Windows Display Scaling presentations. I tested it with 100 % all the way through to 225 % scaling. @CYCho, I suggest you review the subtle changes I have made in this release and consider adopting them into your own.

Attachment removed.

 

Edited by Shark007
updated to sync with 1st post.
Link to comment
Share on other sites

I am just a user of video files and do not have any expertise on how they are made or how they work. I found that some video files would not change their aspect ratios when I change the dimensions. According to my limited experience, mp4, webm and flv files usually stretch to whatever dimension I dictate, but mkv and avi files stick to their original aspect ratios and fill the remaining spaces with black or white background colors. Sometimes they fill the extra spaces with parts of their own images. The behaviour was unpredictable, causing an unexpected result when I maximize the window or turn it into a fullscreen.

Now I found a solution. As you can see in my code, the video window($hVideo) is created by winmm.dll in popup style and I dock the video to my own GUI($hVideoGUI). When I change the positions of $hVideoGUI, the code changes the positions of $hVideo so that the $hVideo fills the entire client area of $hVideoGUI. By moving $hVideo to a 0-width and 0-height window before moving it to a desired size, I could unequivocally fill the extra spaces with black background.

Edited by CYCho
Link to comment
Share on other sites

 

On 5/24/2023 at 7:26 AM, CYCho said:

I am just a user of video files <snip>

The issues that you are currently experiencing, such as mciSendString("play myMedia fullscreen"), are caused by the codecs you have installed on your system for playback. Klite is only useful if you also use their included player for all of your playback. If you want to use a Windows supplied player, you'll need to use a codec package specifically designed for Windows players. If you have used Klites GUI to select the 64bit WMP as default, have a look at the file wmsetup.log found inside the Windows temp folder.  That file is loaded with errors caused by Klite. My software leaves that file clean and error free. I distribute a portable codec package (no installer) with a highly configurable GUI written in AutoIt that defaults to using LAV filters and the 64bit WMP but I also include very useful alternative codecs produced by the MPC-BE Dev Team (extremely active development) because their codecs do not cause any issues for WMP or for winmm.dll.

Just search my username and get the ADVANCED package. Use Launcher64.exe to get it set up. It will auto-remove Klite for you if it is still installed. Next, use the AutoUpdate feature found on the Help TAB because I have several unpublished updates specifically for use with winmm.dll that will be installed by the update feature.  After AutoUpdate completes and no further updates are available, go have a look on the Misc TAB and checkout the checkbox [x] Windows MCI player. That checkbox uses winmm.dl. Hover that checkbox for up to date info!

Plenty of tooltips to help you learn the GUI and of particular interest, hover the WMP suggested settings checkbox for pertinent information.

I rarely promote my own software in public forums but you needed my help.

32bit7.jpg

Edited by Shark007
editted for clarity
Link to comment
Share on other sites

It was my intention to make the main GUI as small as possible. One problem with it is that the slider is very short, too. A short slider is OK for most of audio files, but the movement of shuttlecock is too slow for a long video. So I made the video control in the video window as wide as the video image.

Edited by CYCho
Link to comment
Share on other sites

On 5/17/2023 at 6:23 PM, Shark007 said:

@CYCho, I suggest you review the subtle changes I have made in this release and consider adopting them into your own.

Thank you for your testing the code and making a valuable suggestion. I adopted your suggestion and uploaded the revised code. I also made relevant changes in _Play(), _Pause(), _Previous() and _Next() functions. Thanks again for sparing time on this.

Edited by CYCho
Link to comment
Share on other sites

some code to share with you.

Disable sleep during playback

_WinAPI_SetThreadExecutionState(BitOR($ES_DISPLAY_REQUIRED, $ES_CONTINUOUS, $ES_SYSTEM_REQUIRED, $ES_AWAYMODE_REQUIRED))

re-enable user sleep settings

_WinAPI_SetThreadExecutionState($ES_CONTINUOUS)

 

Edited by Shark007
Link to comment
Share on other sites

46 minutes ago, Shark007 said:

Disable sleep during playback

I never knew this function existed and it never was a problem for me because I have no screen saver nor system sleep set. Now that you mentioned it, I think it would be good idea to incorporate these codes. Thanks.

Edit: @Shark007, Would it be OK to use
 

_WinAPI_SetThreadExecutionState(BitOR($ES_DISPLAY_REQUIRED, $ES_CONTINUOUS, $ES_SYSTEM_REQUIRED, $ES_AWAYMODE_REQUIRED))

everytime starting to play a new file and use
 

_WinAPI_SetThreadExecutionState($ES_CONTINUOUS)

when exiting the program? Or, would this latter code be recommended when the payback is paused as well?

Edited by CYCho
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...