Closed lisardggY closed 6 years ago
Additional data:
I didn't test it in Xamarin Forms yet (and I don't know how Xamarin Forms rendering works). The VLC media element control uses a SwapChainPanel for D3D11 rendering. Perhaps it is not compatible with Xamarin Forms, I will try to look at it quickly.
The Xamarin.Forms controls are basically placeholders, and the CustomRenderers are per-platform code that is generated in the actual app - so regardless of Xamarin, this is still simply a UWP app, but perhaps structured a bit differently.
Additionally, I've tried compiling the control from sources and referencing it directly (rather than from NuGet) and I'm getting more specific errors now . Specifically, it seems there's a FileNotFoundException thrown here:
at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD) at libVLCX.Instance..ctor(IList`1 argv, SwapChainPanel panel) at VLC.MediaElement.
d178.MoveNext() in c:\projects\VLC.MediaElement\VLCMediaElement\MediaElement.cs:line 465 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at VLC.MediaElement.<>cDisplayClass166_0.< b__3>d.MoveNext() in c:\projects\VLC.MediaElement\VLCMediaElement\MediaElement.cs:line 371
Since the only thing in the InitAsync that seems to care about files is the --keystore-file
parameter, I'll try to see if the result of ApplicationData.Current.LocalFolder.Path and KeyStoreFilename are null for some reason.
And indeed, the file VLC_MediaElement_KeyStore
doesn't exist under the LocalFolder.Path. Is it supposed to be generated by something?
Ok, that appears to have been a false lead. I had a broken reference to the C++ Runtime components. Now that I fixed it, I get the same "could not created swapChain" error again.
keystore
is the a path where keys (like username, password, ...) will be stored if needed. It will not be used in your case.
As you guessed, you need the the libVLCX NuGet package and the Microsoft Visual C++ 2013 Runtime Package for Windows Universal
extension. It is automatically added by the NuGet package.
OK, I understood the problem. In Xamarin Forms, the ViewRenderer has no size when is added to the visual tree. But the SwapChainPanel must have a width and height when InitAsync is called. If I deffer the call of InitAsync method in UpdateSizeAsync, it works great.
Ah, wonderful. Once you push the changes, I'll pull and see if it fixes it on my end as well.
The version 0.9.21 should fix the problem.
And we have video! Fantastic. Thanks for the quick fix!
Hi, @lisardggY. I'm also trying to use VLC.MediaElement in a Xamarin.Forms UWP app, but the mediaElement.MediaPlayer property stays null (likely, it never gets initialized).
Do you have any pointers on how to set up the MediaElement correctly?
[Update] Found a solution.
Deferred calling the Xamarin LoadApplication method as an event handler after Load
finishes.
I'm trying to initialize a MediaElement in a Xamarin Forms app, as a custom renderer for a custom control on UWP. I create the instance and set a source, but when it comes down to rendering, I get the following unhandled COMException:
Has it been tested as a Xamarin Forms app?