Am trying to play YouTube and other videos by embedding it in the HTML source for displaying them in iOS.
Both and
Use the new <iframe>
embed code:
<iframe width="420" height="315" src="http://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allowfullscreen></iframe>
YouTube will detect what platform the user is using and serve the appropriate code, i.e. Flash for desktop users, <video>
for iOS, etc.
You can find this embed code (in any YouTube video page) by clicking on the Share button, then the Embed button.
Update: You are not going to find a general solution that will play any video from any provider on iOS devices. The provider has to specifically encode the video so that is can be played by the <video>
element in Safari.
I suggest:
Find the embed code for every video site you support (not the FLV source URL, the embed code that the site gives to users).
If the site uses <iframe>
then they probably support playback on iOS. Use this code verbatim.
If the site uses a Flash player, use SWFObject to embed the video instead of their <embed>
code. If SWFObject detects that the browser does not support Flash, it can show some alternate content instead (e.g. a message like "Sorry, you need to have Flash to view this video").
Use a giant switch
statement:
switch (videoType):
case 'YouTube':
// use YouTube iframe code
break;
case 'Vimeo':
// use Vimeo iframe code
break;
// ...on and on...
default:
// use SWFObject to embed
}
You are defining type="application/x-shockwave-flash"
in the object tag
but where are you defining the fallback for iOS
. If you trying to do target iOS
specifically then why not use video
tag. The documentation given in http://websitehelpers.com/video/html.html will help you to play video in iOS
For iOS
you need to define the video tag
otherwise it does not understand or you can use any one flash player like flowplayer
which has a fallback support for iOS
. You can refer the documentation from http://flash.flowplayer.org/plugins/javascript/ipad.html. Try and let me know if this solves your issue
Update :
Try the following <iframe id="frame" title="Youtube Video" width="320" height="194" scrolling="no" src='http://www.youtube.com/embed/J_DV9b0x7v4' frameborder="1"></iframe>
. This works well in desktop
and in ipad
. J_DV9b0x7v4
is the video you want to play. Check the demo from http://jsfiddle.net/AAUgG/ in iOS
. This should solve the purpose as you desired.