MediaElement Enhancements

In the process of digging into a native exception when disposing the MediaElementRenderer on iOS I came across the closest thing I would get to the source of the problem.

Do not subclass AVPlayerViewController

Because the resulting stacktrace contains redacted elements there was no hope of fixing the issue, so in the end I decided to rewrite the renderer again using the original (non-FastRenderer) approach. The control now behaves correctly and can be created/disposed repeatedly without causing any unexpected problems. I can’t say you can notice any performance hit in not using a fast renderer for this. Though this may be more of a problem if you’re trying to use multiple instances of the control or have some frequently changing screen layout.

I was also able to fix a small issue on Android where depending on the aspect ratio of the video and the size allocated to the control the content may appear left-aligned rather than centered. The result is the latest version of the package on NuGet. At some point I may need to roll these changes into the Xamarin Forms Pull-Request although this seems to have lost all traction after 18-months and is now the second oldest open pull request in the Xamarin Forms project. For the foreseeable future it looks like I’ll be maintaining the standalone control.

One thought on “MediaElement Enhancements

Comments are closed.