Jump to content

zPlayer - My own little audio/video player


Go to solution Solved by TheXman,

Recommended Posts

Posted

I recently found that Microsoft had inserted some new items in Windows 11 file property collection. Formerly, I could get a video frame width with $oDir.GetDetailsOf($oFile, 316). But now the column number for frame width was pushed back to 322, 6 items having been inserted before 311. I confirmed that there was no change in Windows 10. Since I now know that the column numbers can change any time, I had to find a way to get the property values without using their column numbers. @ioa747 suggested using ExtendedProperty() method. That solved problems for video properties. But that method failed in some of the music file properties. For example, ExtendedProperty("System.Music.Artist") produced an empty string while GetDetailsOf($oFile, 13) produced a valid result. However, I was relieved to find that the first 30 or so column numbers, which cover most of properties of music files, have not changed since Win_Vista. So I decided to use ExtendedProperty() for video file properties ony. I incorporated this method in the latest version of zPlayer.

  • 2 months later...
Posted (edited)

I liked the way YouTube video is paused and played by clicking on the image. How can I implement this in my zPlayer?

_WinAPI_WindowFromPoint() was the answer. In the main loop of zPlayer I put a line of code calling the following function and it works beautifully.
 

Func _VideoClicked()
    $aPos = MouseGetPos()
    Local $tStruct = DllStructCreate($tagPOINT)
    DllStructSetData($tStruct, "x", $aPos[0])
    DllStructSetData($tStruct, "y", $aPos[1])
    Local $hWnd = _WinAPI_WindowFromPoint($tStruct)
    If WinGetTitle($hWnd) = "ActiveMovie Window" Then
        If _IsPressed("01") Then
            _Pause()
            Sleep(200)
        EndIf
    EndIf
EndFunc

 

Edited by CYCho
Posted

You dont need the struct if you use _WinAPI_GetMousePos() instead of MouseGetPos().

Func _VideoClicked()
    If WinGetTitle(_WinAPI_WindowFromPoint(_WinAPI_GetMousePos())) = "ActiveMovie Window" Then
        If _IsPressed("01") Then
            _Pause()
            Sleep(200)
        EndIf
    EndIf
EndFunc

 

Some guy's script + some other guy's script = my script!

Posted
50 minutes ago, Werty said:
Func _VideoClicked()
    If WinGetTitle(_WinAPI_WindowFromPoint(_WinAPI_GetMousePos())) = "ActiveMovie Window" Then
        If _IsPressed("01") Then
            _Pause()
            Sleep(200)
        EndIf
    EndIf
EndFunc

I  changed this to:
 

Func _VideoClicked()    ; Click on video image to pause or play the video
    Local $tPoint = _WinAPI_GetMousePos()
    If WinGetTitle(_WinAPI_WindowFromPoint($tPoint)) = "ActiveMovie Window" Then
        If _IsPressed("01") Then
            _Pause()
            Sleep(200)
        EndIf
    EndIf
EndFunc     ;==>_VideoClicked

and it worked. Thanks for your suggestion.

Posted (edited)

@Werty, I noticed that, in VLC, a double-click on video image turns fullscreen mode on or off. I am trying to implement it in zPlayer, but I can't. GUIRegisterMessage(0 is not applicable because the video window($hVideo) is not my GUI. It is created by winmm.dll and the top-most window we actually click or double-click is its child window whose title is "ActiveMovie Window". Do you have any suggestion to tackle this? Thank you for your attention.

Edited by CYCho
Posted (edited)

How are you going to fullscreen the GUI?

Shouldnt you hide the GUI parent window and only fullscreen the childwindow?

I have no experience with doubleclicking.

Edited by Werty

Some guy's script + some other guy's script = my script!

Posted (edited)

Video popup is created by winmm.dll as a child of my own GUI. In fullscreen mode, the whole screen becomes the client area of my GUI, and then the video popup is resized to the maximum keeping its original aspect ratio and centered in GUI. I set the background color of GUI black so that any spaces not filled by video, usually top and bottom, remain black. Currently, F11 hotkey turns fullscreen mode on or off and it works pretty well. A double-click for fullscreen may be redundant. I am just thinking about the possibility of imitating VLC. YouTube also uses double-click for fullscreen. Browsers and file explorer use F11 for fullscreen. zPlayer's F11 works only when the center point of video window is visible on top.

Edit: Utilizing _WinAPI_WindowFromPoint() and GetDoubleClickTime() function suggested by @Andreik, fullscreen via double-click was implemented. Now a single click on video image pauses or plays the video and both double-click and F11 turn fullscreen on or off. Esc also turns fullscreen off.

Edited by CYCho
Posted (edited)

I changed the code as follows and it seems to work for now. I will have to proof-test it for a while. One drawback is that the response  to a single click can be somewhat draggy depending on double-click speed set in Windows Settings.
 

Func _VideoClicked()    ; Single click on video image to pause or play the video, double-click to turn fullscreen on or off
    Local $tPoint = _WinAPI_GetMousePos()
    If WinGetTitle(_WinAPI_WindowFromPoint($tPoint)) = "ActiveMovie Window" Then
        Local $user32DLL = DllOpen("user32.dll"), $hTime, $doubleclicked, $doubleclickSpeed
        If _IsPressed("01", $user32DLL) Then
            $hTime = TimerInit()
            While _IsPressed("01", $user32DLL)
                Sleep(10)
            WEnd
            $doubleclickSpeed = DllCall($user32DLL, 'uint', 'GetDoubleClickTime')[0]
            While TimerDiff($hTime) <= $doubleclickSpeed
                If _IsPressed("01", $user32DLL) Then
                    While _IsPressed("01", $user32DLL)
                        Sleep(10)
                    WEnd
                    $doubleclicked = 1
                    ExitLoop
                EndIf
                Sleep(10)
            WEnd
            If $doubleclicked Then
                _FullScreen()
            Else
                _Pause()
            EndIf
        EndIf
        DllClose($user32DLL)
    EndIf
EndFunc     ;==>_VideoClicked

Edit: Incorporated this code in the latest version(6.1.2.1) of zPlayer.

Edited by CYCho
  • 5 weeks later...
  • 2 months later...
Posted

On my Celeron notebook....slow

On my 10900k pc.....fast

Really depends on the hardware involved, cpu speed, disk speed, ram speed.

Some guy's script + some other guy's script = my script!

Posted

Dear @duckhunt, Welcome to AutoIt Forum! I wish you a Happy New Year and happy coding.
I confirmed that zPlayer works in Windows 10 and 11. I couldn't test earlier versions of Windows, but I would believe that it would work in Windows 7 and upward. If you have any trouble using it in your system, please let me know.

Posted
15 hours ago, CYCho said:

, but I would believe that it would work in Windows 7 and upward. If you have any trouble using it in your system, please let me know.

coding, only for office function scripts. the rest is automation, such as install. for the control panel, i might have broken it

Posted (edited)

Making and maintaining a custom playlist has become a lot easier.  You can create it by following these simple steps. It may be saved in any folder, but it is a good idea to save it in an empty one. Afterwards, you can load this folder the same way you would load others with media files.
    • Click the ‘Load Files’ button located in the main window.
    • Select one or more of your favorite files from a folder and load them.
    • While your files are playing, go to the playlist window.
    • Click the ‘Save List’ button.
    • You will be prompted for the full path to the folder where you want to save the playlist.
        • If the folder does not exist, it will be created.
        • If the folder does exist, the playlist will be overwritten.
    • If you click the 'OK' button, the playlist files will be created in that folder.
    • Click the ‘Add Files’ button in the playlist window to add files from other folders.

The latest version can be downloaded here.

Edited by CYCho
Posted (edited)

How can I create a smoothly scrolling, infinite marquee? in zPlayer, if the length of media title is longer than the display control, the title moves like a marquee. But it stutters because it moves one character at a time. The following code makes the scroll really smooth, because it moves one pixel at a time. It's not perfect, but it looks good enough. I'm working on this to adapt it to zPlayer.

#include <Math.au3>

Local $sTitle = "Beethoven - Symphony No.9 in D minor, Op.125 - 'Choral' - 4. Presto Allegro assai.flac"
Local $guiWidth = 400, $idLabel, $labelWidth, $labelPos = 5, $marqueeInterval = 40

$hGUI = GUICreate("", $guiWidth, 100)
GUISetFont(10, 400, 0, "Arial")
$idLabel = GUICtrlCreateLabel($sTitle, $labelPos, 10, -1, 18)
$labelWidth = _Max(ControlGetPos($hGUI, "", $idLabel)[2], $guiWidth-$labelPos)
GUISetState()

If $labelPos + $labelWidth - 6 > $guiWidth Then
    If $labelPos + $labelWidth - 10 <= $guiWidth Then
        ControlMove($hGUI, "", $idLabel, $labelPos-$labelPos/2, 10)
    Else
        ControlMove($hGUI, "", $idLabel, $labelPos, 10, $labelWidth*2+30)
        GUICtrlSetData($idLabel, $sTitle & "     " & $sTitle)
        ;ConsoleWrite("Character Width: " & $labelWidth & "/" & StringLen($sTitle) & "=" & $labelWidth/StringLen($sTitle) & @CRLF)
        AdlibRegister("_Marquee", $marqueeInterval)
    EndIf
EndIf

Do
    Sleep(10)
Until GUIGetMsg() = -3
AdlibUnRegister()

Func _Marquee()
    Local Static $x, $i
    $i += 1
    If $i < 3000/$marqueeInterval Then Return
    $x -= 1
    ControlMove($hGUI, "", $idLabel, $x, 10)
    If $x < -$labelWidth-5 Then
        $x = 5
        $i = 0
    EndIf
EndFunc

 

Edited by CYCho
Posted

 

#include <WindowsConstants.au3>

Local $sTitle = "Beethoven - Symphony No.9 in D minor, Op.125 - 'Choral' - 4. Presto Allegro assai.flac"
Local $guiWidth = 400, $idLabel, $labelWidth, $labelPos = $guiWidth, $iMarquee, $marqueeInterval = 40

$hGUI = GUICreate("", $guiWidth, 100)
GUISetStyle(-1, BitOR($WS_EX_COMPOSITED, $WS_EX_TOPMOST)) ; $WS_EX_COMPOSITED $WS_EX_TOPMOST
GUISetFont(10, 400, 0, "Arial")
$idLabel = GUICtrlCreateLabel($sTitle, $labelPos, 10, -1, 18)
$labelWidth = ControlGetPos($hGUI, "", $idLabel)[2]
GUICtrlSetData($idLabel, $sTitle & "     " & $sTitle)
GUISetState()

; Check if the label width exceeds the GUI width
If $labelWidth > $guiWidth Then
    ; Start the marquee
    AdlibRegister("_Marquee", $marqueeInterval)
EndIf

Do
    Sleep(10)
Until GUIGetMsg() = -3
;~ AdlibUnRegister()

Func _Marquee()
    $labelPos -= 1 ; Move the label left by 1 pixel
    ControlMove($hGUI, "", $idLabel, $labelPos, 10)

    ; Reset position when the label is completely off-screen
    If $labelPos < -$labelWidth Then
        $labelPos = $guiWidth
    EndIf
EndFunc

 

I know that I know nothing

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
×
×
  • Create New...