WildByDesign Posted Thursday at 05:25 PM Posted Thursday at 05:25 PM (edited) 2 hours ago, MattyD said: By the latest do you mean that sourceforge link a few posts up with the MediaPlayerUDF.au3 file in it (there is only 1 of those!)? My versioning is an absolute mess with this WinRT stuff atm! The one from a few posts up where you put it all together in the two UDF scripts. I'm going to try to copy/paste the funcs (and rename to avoid double func names) from the original to see if they work. EDIT: The functions and values are identical between the old version and the current UDF. Therefore the issue must be something on my end so I will dig into it some more until I have some more information. Edit 2: I was able to reproduce it. I put together one example that works and one example that crashes so that it will be easy to compare. I am away from my PC at the moment but will tidy up the examples a bit and should be able to share them here within a few hours. Edited Thursday at 06:30 PM by WildByDesign
WildByDesign Posted Thursday at 08:40 PM Posted Thursday at 08:40 PM I put together the examples with one script being successful in enabling IsFullWindow and the other script crashes when trying to enable it. Both scripts use your new MediaPlayerUDF.au3 and MediaPlayerUDF_Core.au3 UDF files. Here is the first example script which is successful and uses your older style of initializing MediaPlayerElement: expandcollapse popup#Autoit3Wrapper_Res_Compatibility=win10 #include <MediaPlayerUDF.au3> Global $sTestFile = @ScriptDir & "\bloom.mp4" _MediaPlayer_Init() ; original example ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ;Startup XAML Host Local $pXamlMgr_Fact = _WinRT_GetActivationFactory("Windows.UI.Xaml.Hosting.WindowsXamlManager", $sIID_IWindowsXamlManagerStatics) Local $pWindowsXamlManager = IWindowsXamlManagerStatics_InitializeForCurrentThread($pXamlMgr_Fact) ;Create Container Local $pDesktopWinXamlSrc_Fact = _WinRT_GetActivationFactory("Windows.UI.Xaml.Hosting.DesktopWindowXamlSource", $sIID_IDesktopWindowXamlSourceFactory) Local $pInnerInterface $pDesktopWinXamlSrc = IDesktopWindowXamlSourceFactory_CreateInstance($pDesktopWinXamlSrc_Fact, 0, $pInnerInterface) ;Create XAML control Local $pMediaPlayerElement_Fact = _WinRT_GetActivationFactory("Windows.UI.Xaml.Controls.MediaPlayerElement", $sIID_IMediaPlayerElementFactory) Local $pMediaPlayerElement = IMediaPlayerElementFactory_CreateInstance($pMediaPlayerElement_Fact, 0, $pInnerInterface) IDesktopWindowXamlSource_SetContent($pDesktopWinXamlSrc, $pMediaPlayerElement) ;Attach control to the container. ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Local $hGUI = GUICreate("GUI 1", 400, 225) GUISetState() ; original example ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ;Attach the container to our GUI. Local $pDesktopWinXamlSrcNative = IUnknown_QueryInterface($pDesktopWinXamlSrc, $sIID_IDesktopWindowXamlSourceNative) IDesktopWindowXamlSourceNative_AttachToWindow($pDesktopWinXamlSrcNative, $hGUI) ;Position and show the island - (by default, the width and hight are 0) Local $hIsland = IDesktopWindowXamlSourceNative_GetWindowHandle($pDesktopWinXamlSrcNative) IUnknown_Release($pDesktopWinXamlSrcNative) _WinAPI_SetWindowPos($hIsland, $HWND_TOP, -1, -1, 400, 225, $SWP_SHOWWINDOW) ;Prepare our test video. Local $pFileFact = _WinRT_GetActivationFactory("Windows.Storage.StorageFile", $sIID_IStorageFileStatics) Local $pAsync = IStorageFileStatics_GetFileFromPathAsync($pFileFact, $sTestFile) Local $pFile = _WinRT_WaitForAsync($pAsync, "ptr*") Local $pMediaSrcFact = _WinRT_GetActivationFactory("Windows.Media.Core.MediaSource", $sIID_IMediaSourceStatics) Local $pMediaSrc = IMediaSourceStatics_CreateFromStorageFile($pMediaSrcFact, $pFile) ;Setup the player obj, load the test file 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) ;Attach the player obj to the XAML control. IMediaPlayerElement_SetMediaPlayer($pMediaPlayerElement, $pPlayer) ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; IsFullWindow testing ConsoleWrite("IMediaPlayerElement_GetIsFullWindow: " & IMediaPlayerElement_GetIsFullWindow($pPlayer) & @CRLF) Sleep(200) IMediaPlayerElement_SetIsFullWindow($pPlayer, True) Sleep(200) ConsoleWrite("IMediaPlayerElement_GetIsFullWindow: " & IMediaPlayerElement_GetIsFullWindow($pPlayer) & @CRLF) ; original example ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ;Initiate AutoPlay ;IMediaPlayer_SetAutoPlay($pPlayer, True) IMediaPlayer_Play($pPlayer) ;Allow video to repeat/loop IMediaPlayer_SetIsLoopingEnabled($pPlayer, True) ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Do Until GUIGetMsg() = -3 Here is the second example (crashes) which uses your more recent style for initializing MediaPlayerElement with your more simple UDF functions such _MediaPlayer_Create() and the other _MediaPlayer_* functions. I assume the issue must be something to do with _MediaPlayer_Create() or _MediaPlayer_LoadFromStorage() functions. #Autoit3Wrapper_Res_Compatibility=win10 #include <MediaPlayerUDF.au3> Global $sTestFile = @ScriptDir & "\bloom.mp4" _MediaPlayer_Init() Local $hGUI = GUICreate("GUI 1", 400, 225) GUISetState() Local $hPlayer = _MediaPlayer_Create($hGUI, 0, 0, 400, 225) _MediaPlayer_LoadFromStorage($hPlayer, $sTestFile) _MediaPlayer_EnableTransport($hPlayer, True) _MediaPlayer_SetIsCompact($hPlayer, True) ; IsFullWindow testing ConsoleWrite("IMediaPlayerElement_GetIsFullWindow: " & IMediaPlayerElement_GetIsFullWindow($hPlayer) & @CRLF) Sleep(200) IMediaPlayerElement_SetIsFullWindow($hPlayer, True) Sleep(200) ConsoleWrite("IMediaPlayerElement_GetIsFullWindow: " & IMediaPlayerElement_GetIsFullWindow($hPlayer) & @CRLF) _MediaPlayer_SetIsLooping($hPlayer, True) _MediaPlayer_Play($hPlayer) Do Until GUIGetMsg() = -3
MattyD Posted Thursday at 09:50 PM Author Posted Thursday at 09:50 PM (edited) Ah ok, In the second example, and $hPlayer isn't an object pointer - its a psuedo handle. Basically I've dumped the associated objects of a "player" into an arrays, and hplayer is simply an index. ;from _MediaPlayer_Create, $hPlayer is $iMPIdx! Local $iMPIdx = UBound($__g_apXamlSources) ReDim $__g_apXamlSources[$iMPIdx + 1] ReDim $__g_apMPElements[$iMPIdx + 1] ReDim $__g_apPlayers[$iMPIdx + 1] Try these ones! - Edit 31/10: Corrected error as discussed below. Func _MediaPlayer_SetIsFullWindow($iMPIdx, $bState) If $iMPIdx < 1 Or $iMPIdx >= UBound($__g_apPlayers) Then Return False _WinRT_SwitchInterface($__g_apMPElements[$iMPIdx], $sIID_IMediaPlayerElement) If Not @error Then IMediaPlayerElement_SetIsFullWindow($__g_apMPElements[$iMPIdx], $bState) Return @error = $S_OK EndFunc Func _MediaPlayer_GetIsFullWindow($iMPIdx) If $iMPIdx < 1 Or $iMPIdx >= UBound($__g_apPlayers) Then Return False _WinRT_SwitchInterface($__g_apMPElements[$iMPIdx], $sIID_IMediaPlayerElement) If Not @error Then $bState = IMediaPlayerElement_GetIsFullWindow($__g_apMPElements[$iMPIdx]) Return SetError(@error, @extended, $bState) EndFunc Then for the transport button - not that it achieves anything!. expandcollapse popupFunc _MediaPlayer_SetIsFullScreenVisible($iMPIdx, $bState) Local $iErr If $iMPIdx < 1 Or $iMPIdx >= UBound($__g_apPlayers) Then Return False Local $pTransport = __MediaPlayer_GetTransport($iMPIdx) If @error Then Return SetError(@error, @extended, False) IMediaTransportControls_SetIsFullWindowButtonVisible($pTransport, $bState) $iErr = @error IUnknown_Release($pTransport) Return $iErr = $S_OK EndFunc Func _MediaPlayer_SetIsFullScreenEnabled($iMPIdx, $bState) Local $iErr If $iMPIdx < 1 Or $iMPIdx >= UBound($__g_apPlayers) Then Return False Local $pTransport = __MediaPlayer_GetTransport($iMPIdx) If @error Then Return SetError(@error, @extended, False) IMediaTransportControls_SetIsFullWindowEnabled($pTransport, $bState) $iErr = @error IUnknown_Release($pTransport) Return $iErr = $S_OK EndFunc Func _MediaPlayer_GetIsFullScreenVisible($iMPIdx) Local $iErr, $iExt, $bState = False If $iMPIdx < 1 Or $iMPIdx >= UBound($__g_apPlayers) Then Return False Local $pTransport = __MediaPlayer_GetTransport($iMPIdx) If @error Then Return SetError(@error, @extended, False) $bState = IMediaTransportControls_GetIsFullWindowButtonVisible($pTransport) $iErr = @error $iExt = @extended IUnknown_Release($pTransport) Return $iErr = $S_OK EndFunc Func _MediaPlayer_GetIsFullScreenEnabled($iMPIdx) Local $iErr, $iExt, $bState = False If $iMPIdx < 1 Or $iMPIdx >= UBound($__g_apPlayers) Then Return False Local $pTransport = __MediaPlayer_GetTransport($iMPIdx) If @error Then Return SetError(@error, @extended, False) $bState = IMediaTransportControls_GetIsFullWindowEnabled($pTransport) $iErr = @error $iExt = @extended IUnknown_Release($pTransport) Return SetError($iErr, $iExt, $bState) EndFunc Edited Thursday at 11:06 PM by MattyD WildByDesign 1
WildByDesign Posted Thursday at 10:14 PM Posted Thursday at 10:14 PM 22 minutes ago, MattyD said: Try these ones! Thanks for the quick reply and the insight. Assuming the I run the function like this: _MediaPlayer_SetIsFullWindow($hPlayer, True) It is crashing like this still. Am I supposed to use something other than $hPlayer?
WildByDesign Posted Thursday at 10:44 PM Posted Thursday at 10:44 PM Sorry I have to correct myself, the _MediaPlayer_SetIsFullWindow() is actually working. It's the _MediaPlayer_GetIsFullWindow() that is crashing. Since I was running it first, I never made it to the Set function. Not sure why _MediaPlayer_GetIsFullWindow() is crashing yet _MediaPlayer_SetIsFullWindow() is not crashing.
WildByDesign Posted Thursday at 10:49 PM Posted Thursday at 10:49 PM Actually I can run: _MediaPlayer_SetIsFullWindow($hPlayer, True) _MediaPlayer_GetIsFullWindow($hPlayer) But the following crashes: _MediaPlayer_GetIsFullWindow($hPlayer) _MediaPlayer_SetIsFullWindow($hPlayer, True) _MediaPlayer_GetIsFullWindow($hPlayer) So I have to Set it before I can Get it. Weird, but I'll take it. It does what I need it to do so that is all that matters. In the previous version it did let me Get, Set, Get. But that was really only checking the before and after. So it's not a big deal if I can't check it first. I can set it successfully to IsFullWindow and that is the goal. Thank you so much for helping with this.
MattyD Posted Thursday at 10:55 PM Author Posted Thursday at 10:55 PM (edited) Ah apologies... so we've all stuffed up well here! - I haven't re-tested, but from looking at things... In the first one, we are: IMediaPlayerElement_GetIsFullWindow($pPlayer) But. $pPlayer is the mediaplayer object. not the mediaplayerelement object! So we think we're calling function #19 in the IMediaPlayerElement vtable. but we're actually calling function #19 in IMediaPlayer. which is IMediaPlayer::GetIsMuted My last demo I'm also using the wrong obj in both the getter and setter. Func _MediaPlayer_SetIsFullWindow($iMPIdx, $bState) If $iMPIdx < 1 Or $iMPIdx >= UBound($__g_apPlayers) Then Return False _WinRT_SwitchInterface($__g_apMPElements[$iMPIdx], $sIID_IMediaPlayerElement) If Not @error Then IMediaPlayerElement_SetIsFullWindow($__g_apPlayers[$iMPIdx], $bState) Return @error = $S_OK EndFunc $__g_apPlayers[$iMPIdx] should be $__g_apMPElements[$iMPIdx]. Edited Thursday at 10:56 PM by MattyD WildByDesign 1
WildByDesign Posted Thursday at 11:40 PM Posted Thursday at 11:40 PM 39 minutes ago, MattyD said: But. $pPlayer is the mediaplayer object. not the mediaplayerelement object! So we think we're calling function #19 in the IMediaPlayerElement vtable. but we're actually calling function #19 in IMediaPlayer. which is IMediaPlayer::GetIsMuted Thanks for getting to the bottom of this. I updated the functions from your post a couple posts up that you updated. The functions work which is great. But unfortunately the video just shows black and will not play. I'll have to do some more research into how to get this to work. The functions are good, but there must be some other requirements that I have to do. MattyD and CYCho 2
WildByDesign Posted 21 hours ago Posted 21 hours ago I noticed that the video would still continue to play when IsFullWindow is set despite only seeing black in the GUI. So I looked through some more MS docs and found this: Quote If a MediaPlayerElement hosted in a Popup is switched to full-window mode, the Popup is rendered on top of the MediaPlayerElement. If you must use a MediaPlayerElement in a Popup, you should collapse the Popup when the MediaPlayerElement enters full-window mode, and restore the Popup when the MediaPlayerElement exits full-window mode. This is now certainly outside of the scope of your UDF, but I did find it interesting and likely explains why I see the black background of the GUI as soon as _MediaPlayer_SetIsFullWindow() is called. For what it's worth, I tried briefly using _WinAPI_ShowWindow, _WinAPI_BringWindowToTop and _WinAPI_SetWindowPos as various ways to shuffle around the Z order of the various windows within the GUI that is playing the video. But unfortunately I didn't have any luck yet. I'll probably try some more today.
MattyD Posted 20 hours ago Author Posted 20 hours ago I'd say that's more to do with the UWP popup class - so its probably not relevant to our win32 apps. TBH I wouldn't hold my breath given that full screen is explicitly not supported in xaml islands. But happy to be proven wrong though! WildByDesign 1
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