Armag3ddon Posted April 22, 2008 Posted April 22, 2008 (edited) Hi,I'm trying to embed the Windows Media Player in a GUI. I searched long for a solution but couldn't figure out how it is possible to show the video output of the player.I tried this:$oMP = ObjCreate("WMPlayer.OCX") With $oMP .Settings.autoStart = True EndWith $mediaplayer = GUICtrlCreateObj($oMP, 470, 110, 300, 300)When I load a file ($oMP.url = "...") I hear the sound but the object in the GUI remains to be a black box.I already looked up the Microsoft Developer Network and in the OLE/COM Object Viewer for any possible option but found no solution.Anyone know what to do? Edited April 24, 2008 by Armag3ddon
James Posted April 22, 2008 Posted April 22, 2008 Firstly, wrong forum, this is for the AutoItX control. A quick forum search should help you Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
Armag3ddon Posted April 22, 2008 Author Posted April 22, 2008 (edited) Ah, sorry. Thought this forum was for COM scripting in general. Maybe a mod could switch this thread to the right forum please? A "quick" search gave me this solution: http://www.autoitscript.com/forum/index.ph...&hl=WMMediaI copied the code but it doesn't work:$firstfile = GUICtrlRead($pathf); this is definitely an existing file $handle = _VidOpen($firstfile, "dbViewer", $window, 470, 110, 300, 300) _VidPlay($handle)Same effect: sound but no video output Edited April 22, 2008 by Armag3ddon
James Posted April 22, 2008 Posted April 22, 2008 (edited) Well I am on a short college trip tomorrow but when I get back around 2ish GMT I shall give you a quick demo ;)Actually this might be the right forum Edited April 22, 2008 by JamesB Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ
kjactive Posted April 23, 2008 Posted April 23, 2008 do a search and http://www.autoitscript.com/forum/index.ph...st&p=397363Maybe this would dokjactive Au3PP 4.1 - Autoit3 preprocessor, optimize speed, performance to scripts and do executes....[/url]Au3Calibur - Create libraries of commonly used code excerptsWords manipulate UDF, functions that is lent from the rexx language, topics and index file includedCustomDialog UDF to include custom made dialogs like a extended colorpick requester to scripts...[url="ftp://fritidshjemmet.com/Autoit3/SysColor.zip"]SysColor UDF a low level color library to manipulate RGB and Hex values...Shell32 UDF to Automate Windows® operating tasks from native dialog and Wizards browsers... Optimized the CodeWicard with options to generate browser code etc...
Armag3ddon Posted April 23, 2008 Author Posted April 23, 2008 That's maybe a step more towards success.$oMP = ObjCreate("WMPlayer.OCX") $mediaplayer = GUICtrlCreateObj($oMP, 470, 110, 300, 300) With $oMP .fullScreen = True .windowlessVideo = True .stretchToFit = True .enableContextMenu = True .enabled = True .uiMode = "full"; none / mini full .settings.autostart = True .settings.mute = False .settings.volume = 100; 0 - 100 .settings.Balance = 0; -100 to 100 EndWithThis is my code. When I start my gui, there are the media player controls (.uiMode = "full"). The size of the control is smaller than 300x300But after loading a video file:With $oMP .URL = GUICtrlRead($pathf); $pathf is an existing file EndWith...the control resizes itself (to 300x300) and becomes black if it's a DivX formatted ".avi" file. I also tested a ".mpg" file. Then the control resizes itself as well but the control bar remains (the progress slider does his work too)!But still no visual output of the file
Squirrely1 Posted April 24, 2008 Posted April 24, 2008 (edited) But still no visual output of the fileIn your code, make this change: .windowlessVideo = False But I couldn't get the .stretchToFit = True part to work in that code. But I made a UDF for you, it will only work to play one file or playlist, but it has many options that all work: CODE#include-once #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <IE.au3> #Region Test Opt('MustDeclareVars', 1); no required _IEErrorHandlerRegister (); optional error handler Global $movie = FileOpenDialog("Open a movie or playlist", @MyDocumentsDir, "Movies (*.wpl;*.mpg;*.mpeg;*.wmv;*.avi)", 3) Global $MyGUI = GUICreate("WMPlayer Control", 330, 250) Global $oIE = _GUICtrl_CreateWMPlayer($movie, 5, 5, 320, 240) GUISetState (@SW_SHOW, $MyGUI) Global $playerOBJ = _IEGetObjById($oIE, "objWMPlayer") While 1 Sleep(40) If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop Wend $oIE = "" #EndRegion Test ;=================================================================================================== ; Function: _GUICtrl_CreateWMPlayer ; Purpose: Embed Windows Media Player and play one file or one playlist only. ; Notes: PARAM NAME="url" is ReadOnly ; Authors: squirrely1 ; borderless IE embed example: GaryFrost ; Kudos - Kåre Johansson, CFire ; References: ; http://msdn2.microsoft.com/en-us/library/ms930698.aspx ; http://www.w3schools.com/media/media_playerref.asp ; clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6 - wmplayer latest installed version ; clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95 - wmp 6.4 ;=================================================================================================== Func _GUICtrl_CreateWMPlayer($movieURL, $playerLeft, $playerTop, $playerWidth, $playerHeight, _ $insetBorders = 0, $fullscreenMode = False, $showControls = False, $enableContextMenu = True, _ $LoopMode = True, $playCount = 1, $playVolume = 100, $playBalance = 0, $enableFullScreenControls = True) If $fullscreenMode Then $fullscreenMode = "true" Else $fullscreenMode = "false" EndIf If $showControls Then $showControls = "true" Else $showControls = "false" EndIf If $enableContextMenu Then $enableContextMenu = "true" Else $enableContextMenu = "false" EndIf If $LoopMode Then $playCount = 999 EndIf If $enableFullScreenControls Then $enableFullScreenControls = "true" Else $enableFullScreenControls = "false" EndIf Local $myIE_Obj = _IECreateEmbedded () Local $GUIActiveX = GUICtrlCreateObj($myIE_Obj, $playerLeft, $playerTop, $playerWidth, $playerHeight) _IENavigate($myIE_Obj, "about:blank") Local $htmlWMP $htmlWMP = '' _ & @CR & '<body style="margin:0;padding:0">' _ & @CR & '<OBJECT' _ & @CR & 'ID="objWMPlayer"' _ & @CR & 'STYLE="margin:0;padding:0"' _ & @CR & 'HSPACE="0"' _ & @CR & 'VSPACE="0"' _ & @CR & 'BORDER="0"' _ & @CR & 'WIDTH="' & $playerWidth & '"' _ & @CR & 'HEIGHT="' & $playerHeight & '"' _ & @CR & 'CLASSID="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6"' _ & @CR & 'STANDBY="Loading Windows Media Player components..."' _ & @CR & 'TYPE="application/x-oleobject">' _ & @CR & '<PARAM NAME="allowHideControls" VALUE="true">' _ & @CR & '<PARAM NAME="autoStart" VALUE="true">' _ & @CR & '<PARAM NAME="audioStream" VALUE="false">' _ & @CR & '<PARAM NAME="autoSize" VALUE="true">' _ & @CR & '<PARAM NAME="balance" VALUE="' & $playBalance & '"><!-- -100 to 100 -->' _ & @CR & '<!-- <PARAM NAME="bufferingTime" VALUE="5"><!-- seconds -->' _ & @CR & '<PARAM NAME="clickToPlay" VALUE="false"><!-- has no effect -->' _ & @CR & '<PARAM NAME="currentPosition" VALUE="0"><!-- start position within video, in seconds -->' _ & @CR & '<PARAM NAME="enableContextMenu" VALUE="' & $enableContextMenu & '">' _ & @CR & '<PARAM NAME="enableFullScreenControls" VALUE="' & $enableFullScreenControls & '">' _ & @CR & '<PARAM NAME="enabled" VALUE="true"><!-- whether controls are enabled -->' _ & @CR & '<PARAM NAME="fullScreen" VALUE="' & $fullscreenMode & '">' _ & @CR & '<PARAM NAME="mute" VALUE="false">' _ & @CR & '<PARAM NAME="playCount" VALUE="' & $playCount & '">' _ & @CR & '<!-- <PARAM NAME="previewMode" VALUE="true"> -->' _ & @CR & '<PARAM NAME="rate" VALUE="1"><!-- play speed of -.5 to 2 increments of .1 -->' _ & @CR & '<PARAM NAME="sendPlayStateChangeEvents" VALUE="false">' _ & @CR & '<PARAM NAME="showCaptioning" VALUE="false">' _ & @CR & '<PARAM NAME="showControls" VALUE="' & $showControls & '">' _ & @CR & '<PARAM NAME="showGotoBar" VALUE="false">' _ & @CR & '<PARAM NAME="showPositionControls" VALUE="true"><!-- uiMode must = "full" -->' _ & @CR & '<PARAM NAME="showStatusBar" VALUE="false"><!-- has no effect -->' _ & @CR & '<PARAM NAME="showDisplay" VALUE="true"><!-- has no effect - reportedly shows filename -->' _ & @CR & '<PARAM NAME="stretchToFit" VALUE="true">' _ & @CR & '<PARAM NAME="uiMode" VALUE="none"><!-- invisible, none, mini, full -->' _ & @CR & '<PARAM NAME="url" VALUE="' & $movieURL & '">' _ & @CR & '<!-- <PARAM NAME="videoBorderWidth" VALUE="0"> -->' _ & @CR & '<PARAM NAME="volume" VALUE="' & $playVolume & '"><!-- volume percent setting of wmplayer.exe -->' _ & @CR & '<PARAM NAME="windowlessVideo" VALUE="false"><!-- must be the default (false) for function to work in wmp 9.0, otherwise might renders video directly in the client area -->' _ & @CR & '</OBJECT>' _ & @CR & '</body>' _IEDocWriteHTML ($myIE_Obj, $htmlWMP) _IEAction ($myIE_Obj, "refresh") $myIE_Obj.document.body.scroll = "no" $myIE_Obj.document.body.style.border = $insetBorders Return $myIE_Obj EndFunc ;==>_GUICtrl_CreateWMPlayerEdit 2: Well I found out that, in my code above, if you exclude the line: & @CR & '<PARAM NAME="url" VALUE="' & $movieURL & '">' _ then the object.url is not readonly and you can change it, using the object as returned by this line: Global $playerOBJ = _IEGetObjById($oIE, "objWMPlayer") so you can load file after file by chaning the value assigned to $playerOBJ.url Edited April 24, 2008 by Squirrely1 Das Häschen benutzt Radar
Armag3ddon Posted April 24, 2008 Author Posted April 24, 2008 Wee Finally I see the video! .windowlessVideo = False did it.According to MSDN .stretchToFit maintains the original aspect ratio. But that's okay for me.IE.au3 doesn't work proper on this PC (--> IE.au3 V2.3-1 Warning from function _IEGetObjById, $_IEStatus_NoMatch) due to my IE security settings I think.I'll test your UDF tomorrow on the right PC.But so far .windowlessVideo is sufficient.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now