user2097705
user2097705

Reputation: 1

Playing Youtubes with HTML 5 on iOS

I am trying load a YouTube video into a HTML 5 tag.
The problem I am having is I do not know what the “src” property should be. Using the URL for a video on YouTube does not seem to work, that URL seems to retrieve an entire page rather than just a video file. I have been able to copy and paste YouTube’s own tag (by viewing the page source), that they use on their pages, but this is not a very efficient or long term solution. Is there a better solution? I have tried to use YouTube’s API, but no matter what I do, it seems always to pull in the flash player version of the player (which of course won’t work for iOS.) Am I missing something obvious here?

Upvotes: 0

Views: 977

Answers (1)

Amadan
Amadan

Reputation: 198324

This blog post might help: http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html

The suggestion is to use this code:

<iframe class="youtube-player" type="text/html" width="640" height="385"
        src="http://www.youtube.com/embed/VIDEO_ID" frameborder="0">
</iframe>

The iframe will autodetect HTML5 capabilities and use them; if not, it uses Flash as fallback.

Upvotes: 1

Related Questions