Reputation: 3027
I am working on an WP8 app that pulls in arbitrary HTML and renders it using a WebBrowser control and NavigateToString()
. Sometimes the HTML contains embedded videos, such as YouTube videos, eg.
<iframe height="380" src="http://www.youtube.com/embed/50m3v1deoid" width="689"></iframe>
And the video does not load, it instead displays an error message: The Adobe Flash Player or an HTML5 supported browser is required for video playback.
If an external webpage containing the same HTML is navigated to using Navigate()
the video loads as expected. IsScriptEnabled
is set to True, but I am guessing it is a quirk with iframes loaded from strings.
Is this intended? Is there a way around this?
Short of an obvious solution I am missing, an idea I had was to spawn a small and basic webserver using sockets, attach it to localhost and use Navigate() to get the page. Would that work?
Upvotes: 0
Views: 2385
Reputation: 3027
Typical, I spend a few hours with this and then figure it out 10 minutes after asking the question.
The problem was I wasn't setting a DOCTYPE in the HTML, consider this:
browser.NavigateToString("<html><head><title></title></head><body>" +
"<iframe height=\"383\" src=\"http://www.youtube.com/embed/9bZkp7q19f0\" width=\"680\"></iframe>"+
"</body></html>");
This doesn't work. The video displays an error. However, this:
browser.NavigateToString("<!doctype html>" +
"<html><head><title></title></head><body>" +
"<iframe height=\"383\" src=\"http://www.youtube.com/embed/9bZkp7q19f0\" width=\"680\"></iframe>"+
"</body></html>");
Works fine, and the only difference is the doctype declaration.
The moral of the story is always use well-formed HTML.
I am guessing the reason for this is without the HTML5 doctype the browser doesn't render as HTML5 and WP doesn't support flash so no video is displayed. Once there is an HTML5 doctype the browser is able to load the HTML5 player.
Upvotes: 3