The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

 locked
How to embed youtube video in WebBrowser control RRS feed

  • Question

  • Hi everyone !

    I search for long hours the "how to" which corresponding with the topic subject, but i didn't find it... In Windows Phone 7, is it possible to embed youtube video in the WebBrowser control ? How I can do that programmatically ? 

    Thank your for your answer !

    • Moved by Eric Fleck Friday, May 18, 2012 2:33 PM Migration data
    Wednesday, May 25, 2011 3:39 PM

All replies

  • Well, as far as I know MS filed a complaint against Google (who owns Youtube) for blocking some WP7 requests.

    If you do something like this in the loaded-event:

    webBrowser1.NavigateToString(

     

    "<body><iframe width='800' height='800' src='http://www.u2u.be' frameborder='0' allowfullscreen></iframe><body>");

     



    well, it works perfectly. But if you try it with a link to Youtube :

    webBrowser1.NavigateToString(

     

    "<body><iframe width='800' height='800' src='http://www.youtube.com/embed/O6WLkyxySA0' frameborder='0' allowfullscreen></iframe><body>");

    then you simply end up with a black square, and no video.

    That's also the reason why the WP7 Youtube-app has a high sucking-level...

     

    Thursday, May 26, 2011 7:31 PM
  • Hello,

    No news from this problem (I know it's an old thread:), but i have this problem with an app reading rss feed).

    Kind regards
    Friday, May 18, 2012 9:47 AM
  • The browser does not support playing video directly inside the web page.
    Videos are always played full screen, i.e. the browser relies on the media player task.

    • Proposed as answer by brian11 Monday, April 8, 2013 8:57 PM
    Friday, May 18, 2012 2:32 PM
  • Thanks for the quick response (it's the first time i use the forum, and i didn't expect it could be so quick). I explain more deeply the problem. I get a description of a rss subject, ans use webbrowser.navigatetostring to display the description. In this description, I have html tags, and some youtube share (<iframe width="420" height="315" src="http://www.youtube.com/embed/jCwVGHSqQ7A" frameborder="0" allowfullscreen></iframe>). If i open the description in the browser of the phone, youtube send me a "preview" of the video, on wich I can tap to open it fullscreen. If i open it in a webbrowser in my app, i got a flash error, so, what's the difference between my component and IE? Youtube seems to not understand that's wp asking the preview. I'm affraid of doing some dirty parsing to remove and transform my links :(
    Friday, May 18, 2012 4:11 PM
  • Sorry, I don't know the details of why youtube is failing in this case but ...
    I seem to recall that youtube redirects to a different Uri when it detects the phone browser.

    If your application is targeting windows Phone OS 7.0 the WebBrowser control may be sending the old UserAgent string.


    Friday, May 18, 2012 10:59 PM
  • Sorry, I don't know the details of why youtube is failing in this case but ...
    I seem to recall that youtube redirects to a different Uri when it detects the phone browser.

    If your application is targeting windows Phone OS 7.0 the WebBrowser control may be sending the old UserAgent string.


    You're right, the 7.0 project send a 4.0 user agent, but it was not the problem, nor the referer or the host in the header, as I suspected. I dreamed about it all night :s
    The solution is to add a tag defining the html as mobile request.
    code :
    webBrowser1.NavigateToString("<!DOCTYPE html PUBLIC '-//WAPFORUM//DTD XHTML Mobile 1.2//EN' 'http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd'>"+                
                    "<iframe width='210' height='150' src='http://www.youtube.com/embed/LUoT27E5zTU' frameborder='0' allowfullscreen></iframe>"
                    );

    Thanks for all your help :)
    Saturday, May 19, 2012 8:48 AM