Registered User
Registered User

Reputation: 3699

YouTube HTML5 embed code works on desktop but not on iOS

I have used the HTML5 embed code from this page: http://apiblog.youtube.com/2010/07/new-way-to-embed-youtube-videos.html

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

In the code I use it like this:

var str = 'http://www.youtube.com/v/' + videoid + '&rel=0&autoplay=' + autoplay;
var $video = $("<iframe class=\"youtube-player\" type=\"text/html\" width=\"297\" height=\"249\" src=\"" + str + "\" frameborder=\"0\"></iframe>");
$("#"+elemid).html($video);

}

In all desktop browsers all works great, but not on my iPad. On iPad nothing happens and I have no clue why. The video does work on iPad when I embed the code directly without using the jQuery insertion.

EDIT: http://jsfiddle.net/gGby6/

Upvotes: 2

Views: 2183

Answers (1)

Evan Mulawski
Evan Mulawski

Reputation: 55334

As per the tutorial,

http://www.youtube.com/v/...

should be

http://www.youtube.com/embed/...

This is confirmed working on Mobile Safari (iOS 5.1.1).

Upvotes: 1

Related Questions