locked
How can I play YouTube videos within my application?

    Question

  • Hi!
    I want to show some YouTube videos in my application with the possibility to see the video in fullscreen. However when i use an iframe to play the video, like:
    <iframe width="560" height="315" src="http://www.youtube.com/embed/RnYcPJTtV1A"></iframe>
    It can't set to fullscreen and I also get the error "Can't load the activex plug-in..."

    So i thought it would be better to use the video tag?, but i can't figure out how to play a YouTube video within the video tag...

    So how can I play YouTube videos within my application with the ability to watch in fullscreen and without getting the error?
    Sunday, May 5, 2013 8:44 AM

Answers

  • windows 8 metro apps are not like a web browser, so the youtube server detects the iframe settings and disables certain settings. just like websites that will not allow iframe loading. here is an idea you could implement, first, change your code to.

    <iframe width="300" height="150" src="http://www.youtube.com/embed/RnYcPJTtV1A?version=3" frameborder="0"></iframe>

    this will allow the video to play like it should.

    option : add your own full screen button for the user to tap. then just change the size of the iframe via javascript to a larger size.

    • Marked as answer by Colombium Monday, May 6, 2013 5:48 PM
    Sunday, May 5, 2013 4:23 PM
  • That class ID is the Id of shockwave/flash wich actually means that the iframe tries to instanciate a flash player. adding html5=1 to the url like:

    <iframe width="300" height="150" src="http://www.youtube.com/embed/RnYcPJTtV1A?version=3&html5=1" frameborder="0"></iframe>

    should solve the problem. This forces youtube to use the html5 player (which is actually a video tag) instead of flash.

    However - as far as I know videos with adds allways use the flash. But maybe that has changed in the recent past.

    hope that helps!

    • Marked as answer by Colombium Monday, May 6, 2013 5:48 PM
    Monday, May 6, 2013 5:38 PM

All replies

  • windows 8 metro apps are not like a web browser, so the youtube server detects the iframe settings and disables certain settings. just like websites that will not allow iframe loading. here is an idea you could implement, first, change your code to.

    <iframe width="300" height="150" src="http://www.youtube.com/embed/RnYcPJTtV1A?version=3" frameborder="0"></iframe>

    this will allow the video to play like it should.

    option : add your own full screen button for the user to tap. then just change the size of the iframe via javascript to a larger size.

    • Marked as answer by Colombium Monday, May 6, 2013 5:48 PM
    Sunday, May 5, 2013 4:23 PM
  • Thanks for your reply!

    I have now made my own fullscreen button and it works perfectly!

    But still I get the error:
    "Can’t load the ActiveX plug-in that has the class ID {D27CDB6E-AE6D-11CF-96B8-444553540000}"

    Is there some easy way to fix this error or should i just ignore it?

    Thanks for the help!
    Monday, May 6, 2013 1:03 PM
  • That class ID is the Id of shockwave/flash wich actually means that the iframe tries to instanciate a flash player. adding html5=1 to the url like:

    <iframe width="300" height="150" src="http://www.youtube.com/embed/RnYcPJTtV1A?version=3&html5=1" frameborder="0"></iframe>

    should solve the problem. This forces youtube to use the html5 player (which is actually a video tag) instead of flash.

    However - as far as I know videos with adds allways use the flash. But maybe that has changed in the recent past.

    hope that helps!

    • Marked as answer by Colombium Monday, May 6, 2013 5:48 PM
    Monday, May 6, 2013 5:38 PM
  • Thank you so much!

    That solved the problem!
    Monday, May 6, 2013 5:46 PM