Popular Post MattyD Posted March 15, 2022 Popular Post Share Posted March 15, 2022 Hi all, Not to encroach on CYCho's zPlayer - I've just gove to upload this and found another example at the top. (looks good by the way!) Mine is just a proof of concept anyhow. The main problem here is that when you load a video with the WMP control, there is no obvoius way to scale the video down from its native resoultion. After a lot of searching I found you can use SetObjectRects fuction on the IOleInPlaceObj interface - but in AutoIt we first need to create this. $oWMP = ObjCreate("WMPlayer.OCX") GUICtrlCreateObj($oWMP, 0, 0, 400, 400) $oIInPlaceObj = _CreateInPlaceObjInterface($oWMP) $oIInPlaceObj.SetObjectRects($pRect1, $pRect2) ;Resizes the control Func _CreateInPlaceObjInterface($oObject) Local $oIInPlaceObj, $tagIOleInPlaceObj $tagIOleInPlaceObj = _ "ContextSensitiveHelp none(int); " & _ "GetWindow none(ptr); " & _ "InPlaceDeactivate none(); " & _ "ReactivateAndUndo none(); " & _ "SetObjectRects none(ptr; ptr;); " & _ "UIDeactivate none();" $oIInPlaceObj = ObjCreateInterface($oObject, "{00000113-0000-0000-C000-000000000046}", $tagIOleInPlaceObj) If Not IsObj($oIInPlaceObj) Then Return SetError(1, False) Return $oIInPlaceObj EndFunc Hope this saves someone a bit of pain! Just for completeness, it looks like some people have solved the resizing problem by embedding the player in HTML. I haven't really looked at this method but it does seem to work! Anyway, here's a bare bones build-your-own media player example. (use the WMP_v1.au3 like a UDF) Function List: expandcollapse popupLimitations onEventMode is forced. only one instance of the player is supported. WMP ActiveX Control... _MP_Create($ix, $iy, $iw, $ih) _MP_Resize($ix, $iy, $iw, $ih) load a single media item _MP_LoadMedia($sPath) playlist _MP_PlaylistSelItem($iIndex) _MP_PlaylistAdd($sPath) GUI Controls.... _MP_CtrlCreatePlayPause($ix, $iy, $iw, $ih) _MP_CtrlCreateStop($ix, $iy, $iw, $ih) _MP_CtrlCreateRewind($ix, $iy, $iw, $ih) _MP_CtrlCreateFastFwd($ix, $iy, $iw, $ih) _MP_CtrlCreatePrevious($ix, $iy, $iw, $ih) _MP_CtrlCreateNext($ix, $iy, $iw, $ih) _MP_CtrlCreateShuffle($ix, $iy, $iw, $ih) _MP_CtrlCreateLoop($ix, $iy, $iw, $ih) _MP_CtrlCreateMute($ix, $iy, $iw, $ih) _MP_CtrlCreateVolume($ix, $iy, $iw, $ih) _MP_CtrlCreateFullScreen($ix, $iy, $iw, $ih) _MP_CtrlCreateTransport($ix, $iy, $iw, $ih) _MP_CtrlCreatePlayList($ix, $iy, $iw, $ih) Otherwise just call these... _MP_PlayPause() _MP_Stop() _MP_Rewind() _MP_FastFwd() _MP_Previous() _MP_Next() _MP_Shuffle() _MP_Loop() _MP_Mute() _MP_FullScreen() Demo.au3 WMP_v1.au3 Skeletor, iamkoshr, CYCho and 2 others 3 2 Link to comment Share on other sites More sharing options...
Nine Posted March 15, 2022 Share Posted March 15, 2022 Nice finding. I was looking for something similar but unsuccessfully. Good job. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
MattyD Posted March 16, 2022 Author Share Posted March 16, 2022 Thank you Nine! (Which of course is the best number ) Link to comment Share on other sites More sharing options...
Belini Posted March 16, 2022 Share Posted March 16, 2022 (edited) @MattyD excellent script, if Media Player could change the tune of the song I would even use it in my karaoke project. Edited March 16, 2022 by Belini My Codes: Virtual Key Code UDF: http://www.autoitscript.com/forum/topic/138246-virtual-key-code-udf/ GuiSplashTextOn.au3: http://www.autoitscript.com/forum/topic/143542-guisplashtexton-udf/ Menu versions of Autoit: http://www.autoitscript.com/forum/topic/137435-menu-versions-of-autoit/#entry962011 Selects first folder of letters: ]http://www.autoitscript.com/forum/topic/144780-select-folders-by-letter/#entry1021708/spoiler] List files and folders with long addresses.: http://www.autoitscript.com/forum/topic/144910-list-files-and-folders-with-long-addresses/#entry102 2926 Program JUKEBOX made in Autoit:some functions:http://www.youtube.com/watch?v=WJ2tC2fD5Qs Navigation to search:http://www.youtube.com/watch?v=lblwOFIbgtQ Link to comment Share on other sites More sharing options...
Nine Posted March 16, 2022 Share Posted March 16, 2022 Here my take on your great find. Hope you don't mind. Thanks again. expandcollapse popup#include <Constants.au3> #include <GUIConstantsEx.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", True) Example() Func Example() Local $oPlayer = ObjCreate("WMPlayer.OCX") GUICreate("Embedded Web control Test", 600, 200) GUICtrlCreateObj($oPlayer, 0, 0, 400, 100) $oPlayer.Settings.Volume = 100 $oPlayer.uiMode = "none" $oPlayer.stretchToFit = True Local $sFullPath = "C:\Applications\AutoIt\WASApi\Don Henley - The Boys of Summer.mp3" $oPlayer.URL = $sFullPath While $oPlayer.playState = 9 Sleep(50) WEnd If $oPlayer.playState <> 3 Then Exit MsgBox($MB_SYSTEMMODAL, "Error", $sFullPath & " cannot be played") ResizeOCX($oPlayer, 0, 0, 400, 100) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch If $oPlayer.playState <> 3 Then ExitLoop WEnd EndFunc ;==>Example Func ResizeOCX($oObject, $iLeft, $iTop, $iRight, $iBottom) Local Const $tagIOleInPlaceObj = _ "ContextSensitiveHelp none(int); " & _ "GetWindow none(ptr); " & _ "InPlaceDeactivate none(); " & _ "ReactivateAndUndo none(); " & _ "SetObjectRects none(ptr; ptr;); " & _ "UIDeactivate none();" Local Static $oIInPlace = ObjCreateInterface($oObject, "{00000113-0000-0000-C000-000000000046}", $tagIOleInPlaceObj) Local $tRect = DllStructCreate($tagRECT) $tRect.Left = $iLeft $tRect.Top = $iTop $tRect.Right = $iRight $tRect.Bottom = $iBottom Local $pRect = DllStructGetPtr($tRect) $oIInPlace.SetObjectRects($pRect, $pRect) EndFunc ;==>ResizeOCX Skeletor 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
CYCho Posted March 16, 2022 Share Posted March 16, 2022 Thanks for sharing this excellent find. I will have to use this to extend the life of my zPlayer beyond 2029. zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
MattyD Posted March 17, 2022 Author Share Posted March 17, 2022 My pleasure, thanks all for the kind words.And needless to say that's a good demo of yours Nine hey CYCho - if we're talking 2030s, I'd bet WMP will get the axe at some point for an app from the MS Store. Maybe we should be all looking at libvlc or something in the long term! Link to comment Share on other sites More sharing options...
mutleey Posted September 10, 2022 Share Posted September 10, 2022 (edited) Excellent UDF, I just couldn't incorporate a method to remove an item from the playlist, opposite of the _MP_PlaylistAdd($sPath) function... can any of your friends help? Edited September 10, 2022 by mutleey Link to comment Share on other sites More sharing options...
KaFu Posted September 11, 2022 Share Posted September 11, 2022 Maybe something like this (untested). Func _MP_PlaylistRemoveItem($iIndex) ; https://docs.microsoft.com/de-de/windows/win32/wmp/wmplibiwmpplaylist-iwmpplaylist-removeitem--vb-and-c Local $oWMP = $aPlayerReg[$PREG_PLROBJ] Local $oPlaylist = $oWMP.CurrentPlaylist $oWMP.CurrentPlayList.RemoveItem($oPlaylist.Item($iIndex)) EndFunc ;==>_MP_PlaylistRemoveItem mutleey and MattyD 2 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
mutleey Posted September 11, 2022 Share Posted September 11, 2022 Thanks for the answer Kafu, I had tried something similar but I was not successful... I tested your code and it didn't delete either, I believe that when sending the parameters of the function I didn't send the right parameter. Link to comment Share on other sites More sharing options...
CYCho Posted September 12, 2022 Share Posted September 12, 2022 13 hours ago, KaFu said: Maybe something like this (untested). Func _MP_PlaylistRemoveItem($iIndex) ; https://docs.microsoft.com/de-de/windows/win32/wmp/wmplibiwmpplaylist-iwmpplaylist-removeitem--vb-and-c Local $oWMP = $aPlayerReg[$PREG_PLROBJ] Local $oPlaylist = $oWMP.CurrentPlaylist $oWMP.CurrentPlayList.RemoveItem($oPlaylist.Item($iIndex)) EndFunc ;==>_MP_PlaylistRemoveItem This works for me. mutleey 1 zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
mutleey Posted September 12, 2022 Share Posted September 12, 2022 15 hours ago, CYCho said: This works for me. What parameter is being sent in the variable $iIndex? Link to comment Share on other sites More sharing options...
CYCho Posted September 12, 2022 Share Posted September 12, 2022 1 hour ago, mutleey said: What parameter is being sent in the variable $iIndex? The playlist seems to have 0-based index numbers. In order to remove the first item, I passed 0 to _MP_PlaylistRemoveItem() function. KaFu and mutleey 2 zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
mutleey Posted September 12, 2022 Share Posted September 12, 2022 It worked now, thanks to friends Kafu and CYCho for their help. KaFu 1 Link to comment Share on other sites More sharing options...
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