CYCho Posted October 31 Share Posted October 31 I recently stumbled upon a 4k(3840 x 2160) mp4 video file and tried to play it with my zPlayer and I couldn't. I could hear the audio, but I coudn't see the video. I thought that I couldn't play it because my monitor was 2k(1920 x 1080). Then I found that VLC and and Media Player played it flawlessly. Windows Media Player Legacy also played it, but the video stuttered and lagged frequently, with very high memory usage. I tried WMPlayer.ocx and it was about the same as WMP Legacy. So I conjecture that, even if I had a 4k monitor, winmm.dll or WMPlayer.ocx would not be fit to playback a 4k video. Microsoft says that MCI is a legacy feature and has been superseded by MediaPlayer. Maybe MediaPlayer class is the way to go. But how? It would be very much appreciated if someone could guide me to implement MediaPlayer with AutoIt. Thanks in advance. My desktop configuration is as follows: CPU: AMD Ryzen 5 3400G with Radeon Vega Graphics 3.70 GHz RAM: 8.00GB OS: Windows 11 Monitor: 1920 x 1080 zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
MattyD Posted October 31 Share Posted October 31 Hey mate, MediaPlayer is a winRT object (very early WinRT libraries here) , but it seems to work with a control used for UWP apps. So I'd say its unlikely this will work but I'll have a crack. We can certainly generate the MediaPlayer object, and the activation factory for the control: #include "..\Include\WinRT.au3" #include "..\Include\NameSpaces\Windows.Media.Playback.au3" #include "..\Include\NameSpaces\Windows.UI.Xaml.Controls.au3" _WinRT_Startup() Local $pCtrlFactory = _WinRT_GetActivationFactory("Windows.UI.Xaml.Controls.MediaPlayerElement", "{77E525C3-EB17-4B8D-889D-1EA8ABDBD4EF}") ConsoleWrite("Ctrl Factory: " & $pCtrlFactory & @CRLF & @CRLF) Local $pPlayer = _WinRT_ActivateInstance("Windows.Media.Playback.MediaPlayer") _WinRT_DisplayInterfaces($pPlayer) _WinRT_Shutdown() The console output: Ctrl Factory: 0x000002B7F0205958 (13,0) Supported Interfaces: Class: Windows.Media.Playback.MediaPlayer {381A83CB-6FFF-499B-8D64-2885DFC1249E} - IMediaPlayer {3C841218-2123-4FC5-9082-2F883F77BDF5} - IMediaPlayer2 {EE0660DA-031B-4FEB-BD9B-92E0A0A8D299} - IMediaPlayer3 {BD4F8897-1423-4C3E-82C5-0FB1AF94F715} - IMediaPlayerSource {82449B9F-7322-4C0B-B03B-3E69A48260C5} - IMediaPlayerSource2 {85A1DEDA-CAB6-4CC0-8BE3-6035F4DE2591} - IMediaPlayerEffects {FA419A79-1BBE-46C5-AE1F-8EE69FB3C2C7} - IMediaPlayerEffects2 {30D5A829-7FA4-4026-83BB-D75BAE4EA99E} - IClosable {00000038-0000-0000-C000-000000000046} {80035DB0-7448-4770-AFCF-2A57450914C5} - IMediaPlayer4 {CFE537FD-F86A-4446-BF4D-C8E792B7B4B3} - IMediaPlayer5 {E0CAA086-AE65-414C-B010-8BC55F00E692} - IMediaPlayer6 {5D1DC478-4500-4531-B3F4-777A71491F7F} - IMediaPlayer7 {FA993888-4383-415A-A930-DD472A8CF6F7} I haven't created libraries for Windows.UI.Xaml.Controls.X objects as of yet - (the generator skips over anything that doesn't directly extend "system.object"). I'll have a play over the weekend and report back if it yields anything. CYCho, KaFu and Gianni 1 2 Link to comment Share on other sites More sharing options...
CYCho Posted November 1 Author Share Posted November 1 (edited) 17 hours ago, MattyD said: Local $pPlayer = _WinRT_ActivateInstance("Windows.Media.Playback.MediaPlayer") It seems that I need to instantiate a Windows.Media.Core.MediaSource class and use CreateFromStorageFile() method to be able to play a file with your $pPlayer. As I don't have any knowledge of Windows.Media Namespace, I could not make it work. I tried to immitate what you did in vain. Edited November 1 by CYCho zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
MattyD Posted November 1 Share Posted November 1 (edited) Ok so a couple of things. Usually you need to use _WinRT_GetActivationFactory, which exposes the statics interface. Then using functions attached to that you either instantiate the object, or do whatever else you need to do. _WinRT_ActivateInstance is a dll call, but to my understanding it works by calling IActivationFactory::ActivateInstance on the object. This interface exists on winRT factories, but is not usually supported - It usually returns E_NOTIMPL. doing this: #include "..\Include\NameSpaces\Windows.Media.Core.au3" _WinRT_Startup() Local $pSourceFact = _WinRT_GetActivationFactory("Windows.Media.Core.MediaSource", $sIID_IUnknown) _WinRT_DisplayInterfaces($pSourceFact) _WinRT_Shutdown() returns this: (22,0) Supported Interfaces: {00000035-0000-0000-C000-000000000046} - IActivationFactory {F77D6FA4-4652-410E-B1D8-E9A5E245A45C} {EEE161A4-7F13-4896-B8CB-DF0DE5BCB9F1} {453A30D6-2BEA-4122-9F73-EACE04526E35} {281B3BFC-E50A-4428-A500-9C4ED918D3F0} - IMediaSourceStatics4 The guids with the names against it are the ones that we have libraries for. So funny thing is that the metadata file only specifies IMediaSourceStatics4 as the statics interface of the object, but we can see the object actually supports IMediaSourceStatics, IMediaSourceStatics2, IMediaSourceStatics3 and IMediaSourceStatics4. So this is why we have no library for the other 3 guids. I'll have to dig further into the metadata to see if we can link the missing interfaces when generating the libraries. Otherwise I might have to loop through the metadata file and just link classes to interfaces via the naming convention (which I was trying to avoid!). anyway, CreateFromStorageFile lives on IMediaSourceStatics, or "{F77D6FA4-4652-410E-B1D8-E9A5E245A45C}" so you can: Local $pSourceFact = _WinRT_GetActivationFactory("Windows.Media.Core.MediaSource", "{F77D6FA4-4652-410E-B1D8-E9A5E245A45C}") and if you need to flip between interfaces, you can use query interface: Local $pSourceFact = _WinRT_GetActivationFactory("Windows.Media.Core.MediaSource", $sIID_IMediaSourceStatics4) $pSourceFact_Statics1 = IUnknown_QueryInterface($pSourceFact, $sIID_IMediaSourceStatics) ;$sIID_IMediaSourceStatics would be "{F77D6FA4-4652-410E-B1D8-E9A5E245A45C}" if we had a library for it!!! So ideally we would to do this if we had a library! Local $pSourceFact = _WinRT_GetActivationFactory("Windows.Media.Core.MediaSource", $sIID_IMediaSourceStatics) $retval = IMediaSourceStatics_CreateFromStorageFile($pSourceFact, params....) Edited November 1 by MattyD Link to comment Share on other sites More sharing options...
MattyD Posted November 1 Share Posted November 1 (edited) Also, this as an option too if you'd rather not wait for me.. Note that the first few functions need to be the IInspectable methods! Global Const $sIID_IMediaSourceStatics = "{F77D6FA4-4652-410E-B1D8-E9A5E245A45C}" Local $pSourceFact = _WinRT_GetActivationFactory("Windows.Media.Core.MediaSource", $sIID_IMediaSourceStatics) $oStatics = ObjCreateInterface($pSourceFact, $sIID_IMediaSourceStatics, $tagIMediaSourceStatics) ; we need to define $tagIMediaSourceStatics! Edited November 1 by MattyD fixed syntax error Link to comment Share on other sites More sharing options...
CYCho Posted November 1 Author Share Posted November 1 54 minutes ago, MattyD said: Also, this as an option too if you'd rather not wait for me. I would rather wait for you. Many thanks for your attention. MattyD 1 zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
Shark007 Posted November 2 Share Posted November 2 (edited) my two cents are not worth much since I previously discussed this with you when you 1st began using winmm.dll; your issues are codec related. I personally use winmm.dll (and also WMP Legacy) to playback 4K video including bitstreamed or decoded 7.1 Audio content flawlessly. If you wish to test my claims, MCI Player is found on the Misc TAB of my Application which can be downloaded HERE. Pressing F1 -during playback- will bring up a list of controls for the included MCI Player based solely on winmm.dll. Only to inform, installing LAV Filters will NOT solve the issues presented with the use of winmm.dll Edited November 2 by Shark007 CYCho 1 Link to comment Share on other sites More sharing options...
CYCho Posted November 2 Author Share Posted November 2 1 hour ago, Shark007 said: your issues are codec related First of all, thank you for coming back to remind of the issues I have. I installed your codecs, but still I cannot play 4k video with winmm.dll. Are there some configurations I should change to make it happen? zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
Shark007 Posted November 2 Share Posted November 2 Upon 1st use of my Codecs GUI, everything is set to use LAV Filters. These Filters are not good for winmm.dll usage. When selecting to use [MCI Video Player] from the Misc TAB, My GUI automatically sets splitters and decoders to MPC-BE Filters according to the files extension. So to make it easy, 1st play your MP4 4K file using my GUI/Player. Close my player and then try your player. Link to comment Share on other sites More sharing options...
CYCho Posted November 3 Author Share Posted November 3 I had a goal when I started the zPlayer project: make a simple and easy to use media player without a 3rd party dependency, except for the codecs. I've been trying to use Windows' components and pure AutoIt include files only. So far I've been successful and probably I'll continue to keep that way even if I won't be able to implement certain features of a decent media player without a 3rd party dependency. zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
MattyD Posted November 7 Share Posted November 7 Hey, apologies for the wait - I've skipped over the control part for now as it was giving me a headache! but here's a start with the player object. We've already exceeded the include limit of 995 files with this example, so that's obviously something I'll need to address going forward.. I'll keep chipping away at it, but FYI I'm fairly busy over next couple of weeks. So just expect things to be a bit slow going for a while! Anyway hope this helps... MediaPlayer.zip ioa747 and CYCho 1 1 Link to comment Share on other sites More sharing options...
CYCho Posted November 7 Author Share Posted November 7 (edited) On 11/7/2024 at 1:11 PM, MattyD said: I've skipped over the control part for now as it was giving me a headache! but here's a start with the player object. I cannot fathom the magnitude of your headache to orchestrate the whole WinRT project. You have all the respect I can give to anyone. Your MediaPlayer.au3 is very good for a start. I will look for the possibility of bringing all the functions used in your script into the main au3 file so that I won't have to "include" so many files. At this time, I don't have any idea of how long that file will end up to be, but I have the feeling that it won't be too long. Keept up the good work! Thank you for your time and effort to develop the WinRT librararies. Edited November 8 by CYCho MattyD 1 zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment Link to comment Share on other sites More sharing options...
CYCho Posted November 8 Author Share Posted November 8 (edited) On 11/7/2024 at 9:20 PM, CYCho said: I have the feeling that it won't be too long As expected, it is not so long. It will get longer as @MattyD keeps adding functions, but it will be a worthwhile effort. expandcollapse popup#Region ; #include files in standard AutoIt installation #include <APIErrorsConstants.au3> #include <WinAPIConstants.au3> #include <StructureConstants.au3> #include <AutoItConstants.au3> #EndRegion ; #include files in standard AutoIt installation #Region ; WinRT global variables Global $__g_mIIDs[], $__g_hDLLComBase, $__g_hDLLOle32, $__g_hDLLRoMetaData, $__g_hDLLWinTypes Global Const $sIID_IStorageFileStatics = "{5984C710-DAF2-43C8-8BB4-A4D3EACFD03F}" Global Const $sIID_IAsyncInfo = "{00000036-0000-0000-C000-000000000046}" Global Const $sIID_IAsyncAction = "{5A648006-843A-4DA9-865B-9D26E5DFAD7B}" Global Const $sIID_IMediaSourceStatics = "{F77D6FA4-4652-410E-B1D8-E9A5E245A45C}" Global Const $sIID_IMediaPlayerSource = "{BD4F8897-1423-4C3E-82C5-0FB1AF94F715}" Global Const $sIID_IClosable = "{30D5A829-7FA4-4026-83BB-D75BAE4EA99E}" Global Const $sIID_IMediaPlayer3 = "{EE0660DA-031B-4FEB-BD9B-92E0A0A8D299}" Global $mMediaPlayerState[] $mMediaPlayerState["Closed"] = 0x00000000 $mMediaPlayerState["Opening"] = 0x00000001 $mMediaPlayerState["Buffering"] = 0x00000002 $mMediaPlayerState["Playing"] = 0x00000003 $mMediaPlayerState["Paused"] = 0x00000004 $mMediaPlayerState["Stopped"] = 0x00000005 __WinRT_AddReverseMappings($mMediaPlayerState) Global $mAsyncStatus[] $mAsyncStatus["Canceled"] = 0x00000002 $mAsyncStatus["Completed"] = 0x00000001 $mAsyncStatus["Error"] = 0x00000003 $mAsyncStatus["Started"] = 0x00000000 #EndRegion ; WinRT global variables _WinRT_Startup() Local $pFileFact = _WinRT_GetActivationFactory("Windows.Storage.StorageFile", $sIID_IStorageFileStatics) Local $pAsync = IStorageFileStatics_GetFileFromPathAsync($pFileFact, "C:\Windows\Media\Windows Logon.wav") Local $pFile = _WinRT_WaitForAsync($pAsync, "ptr*") Local $pMediaSrcFact = _WinRT_GetActivationFactory("Windows.Media.Core.MediaSource", $sIID_IMediaSourceStatics) Local $pMediaSrc = IMediaSourceStatics_CreateFromStorageFile($pMediaSrcFact, $pFile) Local $pPlayer = _WinRT_ActivateInstance("Windows.Media.Playback.MediaPlayer") Local $pPlayer_Src = IUnknown_QueryInterface($pPlayer, $sIID_IMediaPlayerSource) IMediaPlayerSource_SetMediaSource($pPlayer_Src, $pMediaSrc) IUnknown_Release($pPlayer_Src) Local $pPlayer_Close = IUnknown_QueryInterface($pPlayer, $sIID_IClosable) Local $pPlayer_3 = IUnknown_QueryInterface($pPlayer, $sIID_IMediaPlayer3) $pPlayer_Session = IMediaPlayer3_GetPlaybackSession($pPlayer_3) IMediaPlayer_Play($pPlayer) Local $iDuration, $sState Do Sleep(10) $sState = _WinRT_GetEnum($mMediaPlayerState, IMediaPlayer_GetCurrentState($pPlayer)) Until $sState = "Playing" $iDuration = IMediaPlayer_GetNaturalDuration($pPlayer) Local $iPos Do $iPos = IMediaPlaybackSession_GetPosition($pPlayer_Session) _DispTime($iPos, $iDuration) Sleep(1000) $sState = _WinRT_GetEnum($mMediaPlayerState, IMediaPlayer_GetCurrentState($pPlayer)) Until $sState = "Paused" IClosable_Close($pPlayer_Close) _WinRT_Shutdown() Func _DispTime($iPos, $iTotal) Local $iTicksPerHour, $iTicksPerMin, $iTicksPerSec Local $iPosHour, $iPosMin, $iPosSec Local $iTotHour, $iTotMin, $iTotSec $iTicksPerSec = 10000000 $iTicksPerMin = 600000000 $iTicksPerHour = 36000000000 $iPosSec = Mod(Round($iPos / $iTicksPerSec), 60) $iPosMin = Mod(Round($iPos / $iTicksPerMin), 60) $iPosHour = Round($iPos / $iTicksPerHour) $iTotSec = Mod(Round($iTotal / $iTicksPerSec), 60) $iTotMin = Mod(Round($iTotal / $iTicksPerMin), 60) $iTotHour = Round($iTotal / $iTicksPerHour) ConsoleWrite(StringFormat("%d:%02d:%02d/%d:%02d:%02d\r\n", $iPosHour, $iPosMin, $iPosSec, $iTotHour, $iTotMin, $iTotSec)) EndFunc #Region ; Functions defined in WinRT.au3 Func _WinRT_WaitForAsync(ByRef $pAsync, $sDataType, $iTimeout = 500) Local $pAsyncInfo = IUnknown_QueryInterface($pAsync, $sIID_IAsyncInfo) If @error Then Return SetError(@error, @extended, -1) Local $hTimer = TimerInit() Local $iStatus, $iError, $vResult = Null Do $iStatus = IAsyncInfo_GetStatus($pAsyncInfo) If TimerDiff($hTimer) > $iTimeout Then ExitLoop Sleep(10) Until $iStatus <> _WinRT_GetEnum($mAsyncStatus, "Started") Switch $iStatus Case _WinRT_GetEnum($mAsyncStatus, "Started") $iStatus = -1 $iError = $WAIT_TIMEOUT Case Else $iError = IAsyncInfo_GetErrorCode($pAsyncInfo) EndSwitch If $iStatus = _WinRT_GetEnum($mAsyncStatus, "Completed") Then IUnknown_QueryInterface($pAsync, $sIID_IAsyncAction) If Not @error Then $vResult = ($iError = $S_OK) Else $vResult = IAsyncOperation_GetResults($pAsync, $sDataType) If @error Then $iError = @error EndIf EndIf _WinRT_DeleteObject($pAsync) Return SetError($iError, $iStatus, $vResult) EndFunc #EndRegion ; Functions defined in WinRT.au3 #Region ; Fuctions defined in WinRTCore.au3 Func _WinRT_ActivateInstance($sClassID) Local $aCall, $hsClassID, $iError $hsClassID = _WinRT_CreateHString($sClassID) If @error Then Return SetError(@error, @extended, Ptr(0)) $aCall = DllCall($__g_hDLLComBase, "long", "RoActivateInstance", "handle", $hsClassID, "ptr*", 0) $iError = @error _WinRT_DeleteHString($hsClassID) If $iError Then Return SetError(__WinRT_GetDllError($iError), 0, Ptr(0)) Return SetError($aCall[0], 0, $aCall[2]) EndFunc ;==>_WinRT_ActivateInstance Func _WinRT_GetActivationFactory($sClassID, $sIID) Local $aCall, $hsClassID, $tIID, $iError $tIID = __WinRT_CreateGUID($sIID) If Not @error Then $hsClassID = _WinRT_CreateHString($sClassID) If @error Then Return SetError(@error, @extended, Ptr(0)) $aCall = DllCall($__g_hDLLComBase, "long", "RoGetActivationFactory", "handle", $hsClassID, "ptr", DllStructGetPtr($tIID), "ptr*", 0) $iError = @error _WinRT_DeleteHString($hsClassID) If $iError Then Return SetError(__WinRT_GetDllError($iError), 0, Ptr(0)) Return SetError($aCall[0], 0, $aCall[3]) EndFunc ;==>_WinRT_GetActivationFactory Func _WinRT_CreateHString($sString) Local $aCall = DllCall($__g_hDLLComBase, "long", "WindowsCreateString", "wstr", $sString, "uint", StringLen($sString), "ptr*", 0) If @error Then Return SetError(__WinRT_GetDllError(), 0, Ptr(0)) Return SetError($aCall[0], 0, $aCall[3]) EndFunc ;==>_WinRT_CreateHString Func _WinRT_DeleteHString(ByRef $hString) Local $aCall = DllCall($__g_hDLLComBase, "long", "WindowsDeleteString", "ptr", $hString) If @error Then Return SetError(__WinRT_GetDllError(), 0, Ptr(0)) $hString = 0 Return SetError($aCall[0], 0, $aCall[0] = 0) EndFunc ;==>_WinRT_DeleteHString Func _WinRT_DeleteObject(ByRef $pObject) Local $iRefCount Do $iRefCount = IUnknown_Release($pObject) If @error Then Return SetError(@error, @extended, False) Until $iRefCount = 0 If Not $iRefCount Then $pObject = Ptr(0) Return ($iRefCount = 0) EndFunc Func _WinRT_GetEnum($mMap, $vKey) If Not IsMap($mMap) Then Return Return $mMap[String($vKey)] EndFunc Func _WinRT_Shutdown() DllClose($__g_hDLLComBase) DllClose($__g_hDLLOle32) DllClose($__g_hDLLRoMetaData) DllClose($__g_hDLLWinTypes) EndFunc ;==>_WinRT_Shutdown Func _WinRT_Startup() $__g_hDLLComBase = DllOpen("Combase.dll") $__g_hDLLOle32 = DllOpen("Ole32.dll") $__g_hDLLRoMetaData = DllOpen("RoMetaData.dll") $__g_hDLLWinTypes = DllOpen("WinTypes.dll") __WinRT_AddReverseMappings($__g_mIIDs) EndFunc ;==>_WinRT_Startup Func __WinRT_AddReverseMappings(ByRef $mMap) If Not IsMap($mMap) Then Return Local $aKeys = MapKeys($mMap), $vKey For $i = 0 To UBound($aKeys) - 1 $vKey = $aKeys[$i] $mMap[String($mMap[$vKey])] = $vKey Next EndFunc ;==>__WinRT_AddReverseMappings Func __WinRT_CreateGUID($sGUID = "{00000000-0000-0000-0000-000000000000}") Local $tGUID = DllStructCreate($tagGUID) Local $aGUID = StringSplit(StringRegExpReplace($sGUID, "[{}]", ""), "-", 2) If UBound($aGUID) <> 5 Then Return SetError($ERROR_INVALID_PARAMETER, 0, False) DllStructSetData($tGUID, 1, Dec($aGUID[0])) DllStructSetData($tGUID, 2, Dec($aGUID[1])) DllStructSetData($tGUID, 3, Dec($aGUID[2])) DllStructSetData($tGUID, 4, Binary("0x" & $aGUID[3] & $aGUID[4])) Return $tGUID EndFunc ;==>__WinRT_CreateGUID Func __WinRT_GetDllError($iError = @error) Switch $iError Case 0 $iError = $ERROR_SUCCESS Case 1 $iError = $ERROR_DLL_INIT_FAILED Case Else $iError = $ERROR_INVALID_PARAMETER EndSwitch Return $iError EndFunc ;==>__WinRT_GetDllError Func __WinRT_GetFuncAddress($pThis, $iIndex) Local Const $PTR_LEN = @AutoItX64 ? 8 : 4 $iIndex -= 1 If IsInt($pThis) Then $pThis = Ptr($pThis) If (Not $pThis) Or (Not IsPtr($pThis)) Then Return SetError($ERROR_INVALID_PARAMETER, 0, Ptr(0)) If ($iIndex < 0) Or (Not IsInt($iIndex)) Then Return SetError($ERROR_INVALID_PARAMETER, 0, Ptr(0)) Local $pVTable = __WinRT_GetPtrAt($pThis) Return __WinRT_GetPtrAt($pVTable + ($iIndex * $PTR_LEN)) EndFunc ;==>__WinRT_GetFuncAddress Func __WinRT_GetProperty_Number($pThis, $iVTableIdx, $sDataType) Local $vFailVal = 0 Switch $sDataType Case "int", "long", "float" $vFailVal = 0 Case "uint", "ulong", "dword" $vFailVal = -1 Case "int64", "double" $vFailVal = Int(0, $NUMBER_64BIT) Case "uint64" $vFailVal = Int(-1, $NUMBER_64BIT) Case "ptr", "handle", "hwnd" $vFailVal = Ptr(0) Case "bool" $vFailVal = Null Case Else Return SetError($ERROR_INVALID_PARAMETER, 0, $vFailVal) EndSwitch Local $pFunc = __WinRT_GetFuncAddress($pThis, $iVTableIdx) If @error Then Return SetError(@error, @extended, $vFailVal) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, $sDataType & "*", 0) If @error Then Return SetError(__WinRT_GetDllError(), 0, $vFailVal) Return SetError($aCall[0], 0, $aCall[2]) EndFunc ;==>__WinRT_GetProperty_Number Func __WinRT_GetProperty_Ptr($pThis, $iVTableIdx) Local $vFailVal = Ptr(0) Local $pFunc = __WinRT_GetFuncAddress($pThis, $iVTableIdx) If @error Then Return SetError(@error, @extended, $vFailVal) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "ptr*", 0) If @error Then Return SetError(__WinRT_GetDllError(), 0, $vFailVal) Return SetError($aCall[0], 0, $aCall[2]) EndFunc ;==>__WinRT_GetProperty_Ptr Func __WinRT_GetPtrAt($pPtr) If (Not $pPtr) Or (Not IsPtr($pPtr)) Then Return SetError($ERROR_INVALID_PARAMETER, 0, Ptr(0)) Local $tPtr = DllStructCreate("ptr", $pPtr) Return DllStructGetData($tPtr, 1) EndFunc ;==>__WinRT_GetPtrAt #EndRegion ; Fuctions defined in WinRTCore.au3 #Region ; Functions defined in IUnknown.au3 Func IUnknown_QueryInterface($pThis, $sIID) Local $vFailVal = Ptr(0) Local $pFunc = __WinRT_GetFuncAddress($pThis, 1) If @error Then Return SetError(@error, @extended, $vFailVal) Local $tIID = __WinRT_CreateGUID($sIID) If @error Then Return SetError(@error, @extended, $vFailVal) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "struct*", $tIID, "ptr*", 0) If @error Then Return SetError(__WinRT_GetDllError(), 0, $vFailVal) Return SetError($aCall[0], 0, $aCall[3]) EndFunc ;==>IUnknown_QueryInterface Func IUnknown_Release($pThis) Local $vFailVal = -1 Local $pFunc = __WinRT_GetFuncAddress($pThis, 3) If @error Then Return SetError(@error, @extended, $vFailVal) Local $aCall = DllCallAddress("ulong", $pFunc, "ptr", $pThis) If @error Then Return SetError(__WinRT_GetDllError(), 0, $vFailVal) Return $aCall[0] EndFunc ;==>IUnknown_RemoveRef #EndRegion ; Functions defined in IUnknown.au3 #Region ; Functions defined in Windows.Foundation.IAsyncInfo.au3 Func IAsyncInfo_GetStatus($pThis) Local $vValue = __WinRT_GetProperty_Number($pThis, 8, "ulong") Return SetError(@error, @extended, $vValue) EndFunc Func IAsyncInfo_GetErrorCode($pThis) Local $vValue = __WinRT_GetProperty_Number($pThis, 9, "long") Return SetError(@error, @extended, $vValue) EndFunc #EndRegion ; Functions defined in Windows.Foundation.IAsyncInfo.au3 #Region ; Functions defined in Windows.Foundation.IAsyncOperation.au3 Func IAsyncOperation_GetResults($pThis, $sDataType, $pData = Ptr(0)) Local $vFailVal = Null Local $pFunc = __WinRT_GetFuncAddress($pThis, 9) If @error Then Return SetError(@error, @extended, $vFailVal) If $sDataType = "ptr" And (Not $pData) Then Return SetError($ERROR_INVALID_PARAMETER, 0, $vFailVal) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, $sDataType, $pData) If @error Then Return SetError(__WinRT_GetDllError(), 0, $vFailVal) Return SetError($aCall[0], 0, $aCall[2]) EndFunc ;==>IAsyncOperation_GetResults #EndRegion ; Functions defined in Windows.Foundation.IAsyncOperation.au3 #Region ; Functions defined in Windows.Foundation.IClosable.au3 Func IClosable_Close($pThis) Local $vFailVal = False Local $pFunc = __WinRT_GetFuncAddress($pThis, 7) If @error Then Return SetError(@error, @extended, $vFailVal) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis) If @error Then Return SetError(__WinRT_GetDllError(), 0, $vFailVal) Return SetError($aCall[0], 0, ($aCall[0] = $S_OK)) EndFunc #EndRegion ; Functions defined in Windows.Foundation.IClosable.au3 #Region ; Functions defined in Windows.Media.Playback.IMediaPlayer.au3 Func IMediaPlayer_Play($pThis) Local $vFailVal = False Local $pFunc = __WinRT_GetFuncAddress($pThis, 46) If @error Then Return SetError(@error, @extended, $vFailVal) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis) If @error Then Return SetError(__WinRT_GetDllError(), 0, $vFailVal) Return SetError($aCall[0], 0, ($aCall[0] = $S_OK)) EndFunc Func IMediaPlayer_Pause($pThis) Local $vFailVal = False Local $pFunc = __WinRT_GetFuncAddress($pThis, 47) If @error Then Return SetError(@error, @extended, $vFailVal) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis) If @error Then Return SetError(__WinRT_GetDllError(), 0, $vFailVal) Return SetError($aCall[0], 0, ($aCall[0] = $S_OK)) EndFunc Func IMediaPlayer_GetCurrentState($pThis) Local $vValue = __WinRT_GetProperty_Number($pThis, 13, "ulong") Return SetError(@error, @extended, $vValue) EndFunc Func IMediaPlayer_GetNaturalDuration($pThis) Local $vValue = __WinRT_GetProperty_Number($pThis, 9, "int64") Return SetError(@error, @extended, $vValue) EndFunc #EndRegion ; Functions defined in Windows.Media.Playback.IMediaPlayer.au3 #Region ; Functions defined in Windows.Media.Playback.IMediaPlayer3.au3 Func IMediaPlayer3_GetPlaybackSession($pThis) Local $vValue = __WinRT_GetProperty_Ptr($pThis, 25) Return SetError(@error, @extended, $vValue) EndFunc #EndRegion ; Functions defined in Windows.Media.Playback.IMediaPlayer3.au3 #Region ; Functions defined in Windows.Media.Playback.IMediaPlaybackSession.au3 Func IMediaPlaybackSession_GetPosition($pThis) Local $vValue = __WinRT_GetProperty_Number($pThis, 29, "int64") Return SetError(@error, @extended, $vValue) EndFunc #EndRegion ; Functions defined in Windows.Media.Playback.IMediaPlaybackSession.au3 #Region ; Functions defined in Windows.Media.Playback.IMediaPlayerSource.au3 Func IMediaPlayerSource_SetMediaSource($pThis, $pSource) Local $vFailVal = False Local $pFunc = __WinRT_GetFuncAddress($pThis, 11) If @error Then Return SetError(@error, @extended, $vFailVal) If $pSource And IsInt($pSource) Then $pSource = Ptr($pSource) If $pSource And (Not IsPtr($pSource)) Then Return SetError($ERROR_INVALID_PARAMETER, 0, $vFailVal) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "ptr", $pSource) If @error Then Return SetError(__WinRT_GetDllError(), 0, $vFailVal) Return SetError($aCall[0], 0, ($aCall[0] = $S_OK)) EndFunc #EndRegion ; Functions defined in Windows.Media.Playback.IMediaPlayerSource.au3 #Region ; Functions defined in Windows.Media.Core.IMediaSourceStatics.au3 Func IMediaSourceStatics_CreateFromStorageFile($pThis, $pFile) Local $vFailVal = Ptr(0) Local $pFunc = __WinRT_GetFuncAddress($pThis, 11) If @error Then Return SetError(@error, @extended, $vFailVal) If $pFile And IsInt($pFile) Then $pFile = Ptr($pFile) If $pFile And (Not IsPtr($pFile)) Then Return SetError($ERROR_INVALID_PARAMETER, 0, $vFailVal) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "ptr", $pFile, "ptr*", 0) If @error Then Return SetError(__WinRT_GetDllError(), 0, $vFailVal) Return SetError($aCall[0], 0, $aCall[3]) EndFunc #EndRegion ; Functions defined in Windows.Media.Core.IMediaSourceStatics.au3 #Region ; Functions defined in Windows.Storage.IStorageFileStatics.au3 Func IStorageFileStatics_GetFileFromPathAsync($pThis, $sPath) Local $vFailVal = Ptr(0) Local $pFunc = __WinRT_GetFuncAddress($pThis, 7) If @error Then Return SetError(@error, @extended, $vFailVal) If ($sPath) And (Not IsString($sPath)) Then Return SetError($ERROR_INVALID_PARAMETER, 0, $vFailVal) Local $hPath = _WinRT_CreateHString($sPath) Local $aCall = DllCallAddress("long", $pFunc, "ptr", $pThis, "handle", $hPath, "ptr*", 0) Local $iError = @error _WinRT_DeleteHString($hPath) If $iError Then Return SetError(__WinRT_GetDllError($iError), 0, $vFailVal) Return SetError($aCall[0], 0, $aCall[3]) EndFunc #EndRegion ; Functions defined in Windows.Storage.IStorageFileStatics.au3 Edited November 8 by CYCho Gianni 1 zPlayer - A Small Audio and Video Player Time Sync + SystemTimeAdjustment 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