Xamarin Forms MediaElement

Some time ago I created a MediaElement control for Xamarin Forms for displaying video (and audio) content across the main mobile platforms and it’s been steadily improving and has been used in a number of projects.

After some discussions on GitHub I started the process of integrating the control into Xamarin Forms itself with a Pull request opened last week. There will be some API changes in the transition and I’ll be sure to keep the current control available until its fully integrated into a stable Xamarin Forms release.

Things are progressing well with some reviews and code changes, partly to fit the Xamarin coding style and partly having fresh eyes looking at the code pointing out some improvements. I’ve already created a new renderer for WPF which supports the basics (The WPF MediaElement doesn’t have built-in transport controls so this isn’t supported yet). It highlighted something as I was testing on iOS where the video just wouldn’t work. I later remembered that unless you explicitly request it in your info.plist the app will block any http resources. But you’ll not get an error, the video will simply be stuck in the ReadyToPlay state. Switching to an https target fixed the issue immediately. This lead me to create the following table showing supported URI types and how they map on each platform. These apply to both the InTheHand.Forms version and the Xamarin.Forms control although only the latter has WPF support:-

 

Uri Scheme Android iOS UWP WPF
HTTP/HTTPS Yes HTTPS only or set NSAppTransportSecurity in info.plist Yes Yes
file Yes Yes Yes Yes
ms-appx Yes. Items must have the build action AndroidResource and be located in the Resources/raw folder of the project Yes. Items must have the build action BundleResource Yes Maps to pack://application:,,,{localpath}
ms-appdata Yes (Local+Temp) Yes (Local+Temp) Yes (Local, Temp and Roaming) Yes (Local+Temp)

One thought on “Xamarin Forms MediaElement

  1. Fantastic!

    Please work with Microsoft and make sure that aes encryption and all azure media services encrypted video can play.

    Bug deal is having header setting ability for Android.

    (obviously WPF can’t do encrypted video sadly, but UWP can and should just work with some. Mechanism for setting headers or whatever else to get aes, play ready and fair play working.

    Thanks!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s