Jump to content
Sign in to follow this  

Resize WMPlayer.ocx

Recommended Posts

Hi all

I have the commission to create a small program in AutoIt.

Among other things, this script should be able to run movies in a GUI.

This is not a problem. I decided to take the ActiveX Object from the Windows Media Player to play movies in my GUI. This because the Media Player is installed on all of our computers.

My short test-script (see below) is working nearly perfect, but I can't resize the movie during playing!

How can I achieve that I can resize the GUI during running the movie and the movie is also resizing?

How can I do this?

Or can I embed the Media Player in an other way, to use this functionality?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)

Global $hGUI1, $oWMP1, $hWMP1, $sURL

$sURL = FileOpenDialog("Please choose a movie", @HomeDrive, "Movies (*.mpg;*.mpeg;*.mp4; *.avi)", 1)
If @error Or Not $sURL Then _Exit()

$hGUI1 = GUICreate("Test", 300, 200, -1, -1, $WS_SIZEBOX)
GUISetOnEvent($GUI_EVENT_RESIZED, "_Resize")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")

$oWMP1 = ObjCreate("WMPlayer.OCX")
If Not IsObj($oWMP1) Then Exit
$hWMP1 = GUICtrlCreateObj($oWMP1, 0, 0, 300, 200)

With $oWMP1
    .URL = $sURL
    Local $iEmergencyTimer = TimerInit()
    While .playState() = 9 ;Wait while playState = Transitioning (Preparing new media item)
        If TimerDiff($iEmergencyTimer) > 2000 Then ExitLoop
    .settings.autoStart = False
    .controls.stop() ;Stop, to ensure, that they are at the beginning!
    .fullscreen = False
    .stretchToFit = True
    .settings.setMode('loop', True)
    .settings.playCount = 1000000
    .settings.rate = 1
    .uiMode = 'none'
    .settings.volume = 100
    .settings.mute = False
    .enableContextMenu = True


While True

Func _Resize()
    Local $aSize = WinGetPos($hGUI1)
    ConsoleWrite("Resize: " & GUICtrlSetPos($hWMP1, 0, 0, $aSize[2], $aSize[3]) & @CRLF)
EndFunc ;==>_Resize

Func _Exit()
EndFunc ;==>_Exit

Many thanks, Veronesi

Share this post

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...