0

We have YouTube trailers that we want to run on our Xamarin Forms (PCL) project.

We have try'd everything but somehow there is not a good Youtube player out there :(

So now we are loading the Youtube trailers in a WebView so that it runs on the Android + iOS.

This is how we load the trailers in our WebView component:

var apiRequest = "https://www.youtube.com/embed/GYmm9qNwd_s?html5=1&autoplay=1&loop=1&rel=0&showinfo=0&controls=1";

var webView = new WebView();
webView.Source = apiRequest;
webView.MinimumWidthRequest = 200;
webView.MinimumHeightRequest = 200;
webView.HorizontalOptions = LayoutOptions.FillAndExpand;
webView.VerticalOptions = LayoutOptions.FillAndExpand;

var stackLayout = new StackLayout();

stackLayout.Children.Add(webView);

stackLayout.HorizontalOptions = LayoutOptions.FillAndExpand;
stackLayout.VerticalOptions = LayoutOptions.FillAndExpand;

grid.Children.Add(stackLayout);

this.Content = grid; 

But somehow the Trailer is running on iOS and Android but the Autoplay is not working and the related movies still show up!

Screenshot1-ShowingControls

Screenshot2-RelMoviesStillShow

So my question is :

  1. Is there a way to set the Autoplay on the Xamarin Forms platforms?
  2. Why does the autoplay function won't work?

1 Answer 1

0

Autoplay on most mobile platforms (Android, iOS) gets blocked to avoid poor user experiences - video should only play following a user action. Like in Andriod, Auto-play is disabled since Android SDK 17. You can check this question to get more information Android webview html5 video autoplay not working on android 4.0.3

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.