2

I want to Autoplay youtube video in wp8 webbrowser control using IFrame my code is.

string ss = "<!doctype html>" +
    "<html><head><meta bgcolor=\"black\" name=\"viewport\" content=\"width=1080, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0\" /><title></title></head><body style=background-color:black;>" +
    "<iframe \"background-color:black\" id=\"ytplayer\" type=\"text/html\" width=\"1080\" height=\"700\" src=\"https://www.youtube.com/embed/?rel=0&autoplay=1&loop=1&modestbranding=1&playlist=" + youtubeIDS + "&playsinline=1&controls=0\" frameborder=\"0\" allowfullscreen>" +
    "</body></html>";

webbrowser.NavigatetoString(ss);

but not able to Autoplay the Video.

Quality Catalyst
  • 6,531
  • 8
  • 38
  • 62

2 Answers2

1

This is not a question related to C#, but HTML. There's heaps of clutter in your YouTube source link. Try this puristic link to activate the auto-play function and then add your other link attributes if needed:

string ss = "<!doctype html>" +
    "<html><head></head><body>" +
    "<iframe id=\"ytplayer\" type=\"text/html\" width=\"1080\" height=\"700\" src=\"https://www.youtube.com/embed/" + youtubeIDS + "?autoplay=1\">" +
    "</body></html>";
webbrowser.NavigatetoString(ss);

Apparently, the rel=0 attribute causes issues for some hence this full version may work (just removed rel=0):

string ss = "<!doctype html>" +
    "<html><head><meta bgcolor=\"black\" name=\"viewport\" content=\"width=1080, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0\" /><title></title></head><body style=background-color:black;>" +
    "<iframe \"background-color:black\" id=\"ytplayer\" type=\"text/html\" width=\"1080\" height=\"700\" src=\"https://www.youtube.com/embed/?autoplay=1&loop=1&modestbranding=1&playlist=" + youtubeIDS + "&playsinline=1&controls=0\" frameborder=\"0\" allowfullscreen>" +
    "</body></html>";
webbrowser.NavigatetoString(ss);

If everything fails try this link, they discuss a very similar topic: How to make an embedded Youtube video automatically start playing?

UPDATE: If even that doesn't help eliminate all potential influences that may be of a problem, e. g. create an HTML file locally and add the minimal HTML command, then open this file with a couple of Web browsers to check the YouTube auto-play feature. Example that should work:

<html>
    <head>
        <title>Minimal YouTube Autoplay Example</title>
    </head>
    <body>
        <iframe width="560" height="315" src="http://www.youtube.com/embed/xV7Ha3VDbzE?autoplay=1" frameborder="0"></iframe>
    </body>
</html>

Then go from there. If this doesn't work though you have no programming issue to solve ;-)

Community
  • 1
  • 1
Quality Catalyst
  • 6,531
  • 8
  • 38
  • 62
0

Impossible on Mobile device.

This is what Google said:

Due to this restriction, functions and parameters such as autoplay, playVideo(), loadVideoById() won't work in all mobile environments.

https://developers.google.com/youtube/iframe_api_reference

DzungPV
  • 1,561
  • 3
  • 18
  • 24