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 embed code:
YouTube will detect what platform the user is using and serve the appropriate code, i.e. Flash for desktop users, 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 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 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 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
}