What is the preferred way for playback of a web video in Xamarin Forms?

1.2k Views Asked by At

I want to:

  • play videos in my Xamarin Forms app (iOS + Android + UWP)
  • follow best practices and use maintained code
  • be able to secure my content (subscription based access)
  • if possible, style the transport controls to have a the same look and feel as my app

I found multiple ways that are possible, but not sure what is to be advised given my scenario:

  1. Azure Media player

I found this talk that implied that it is best to use Azure Media Services to transcode your video to different qualities / formats so you can do Adaptive Bitrate Streaming, which means that depending on the quality of the connection and the device type, you will always have the "best possible" video on every type of device with the lowest bandwith usage. According to this talk this requires a "smart player" with the logic to do the switching between quality levels. In the talk the azure media player is mentioned as the go-to video player because it has support for Adaptive Bitrate Streaming (ABS) from azure media services. It does not mention other players with ABS compatibility. The transcoded video in the sample is played with Azure Media Player, which is hosted in a WebView. And since this talk was from 2018 and in a very recent release of Xamarin Forms (5.0) they have removed support for UIWebView and replaced it with WKWebView and I'm not sure if the WebView (and thus the video player) used in the sample is still supported / advised.

  1. Custom Renderer

The Xamarin Forms documentation has a section "implementing a video player" where they give you a sample video player in the form of a custom renderer. I like that they allow you to style the transport controls yourself. It is not mentioned if this video player has the same "smart switching" like the azure media player.

  1. Use vimeo

With a paid subscription you can apperently secure the access your content. The styling of the player is limited, but maybe enough for my purposes. They do the content encoding / smart switching in the player for you. You pay a monthly fee, and have a limit on how many video minutes you can add each month, but no other bandwith / storage costs (as far as I can see).

  1. Quick and dirty (naive?)

I can upload an mp4 to azure blob storage and use the customer renderer sample to playback the video directly from the blob. This however would mean that there is no dynamic switching of video quality on the client and they would always consume "full bandwidth".

I am new to video transcoding / streaming. Am I missing something in my analysis?

1

There are 1 best solutions below

6
On

I would definitely go with option 2 because:

  1. It's recommended by Xamarin and Microsoft.
  2. It's free!
  3. Taking adventage of the native implementation, you would be using the full potential of each platform and you can display videos from any source, local videos from the phone or the project or from YouTube, Vimeo, etc (as long as they are public videos).
  4. Easy to use.
  5. It's easy to customize because you handle the native code, that means you are in charge and not some WebView or someone else library.

I would discard the other options because:

  • Option 1 might be a good option, but you're consuming Azure and eventually it will cost you or your client money and use a WebView to display a video it's not very friendly from the UX point of view.
  • Options 3: I would definitely discard a paid solution if I have other options, specially if the other options are free.
  • Option 4 as same as before, you would be consuming Azure time and process, that lead you to lose money, if you want to upload a public video always upload to YouTube or some similar service, but as you said, consume the video from a native video player is the best option.

And by last, check this official sample, is more updated than the docs.

P.D: it's, custom renderer, not customer renderer ;-)