How to fix If playback doesn't begin shortly, try restarting your device using Youtube iFrame API on iPad?
I've banged my head against the computer for hours trying to solve this one... Here's what I've found.
This is happening because of Apple's draconian iOS limitation: web pages can only start playing audio/video when responding directly to user feedback. (Note this limitation only affects the first time audio/video is played on a page.)
Usually, to work around Apple's limitation, it's sufficient to make sure your play() call happens directly in an event handler (e.g., a click handler). This works for the Web Audio API and normal HTML5 videos -- but something about the YouTube player prevents this from working for YouTube.
As a result, the solution for YouTube apparently is to require the user to click the YouTube video itself to initiate playback. From then on, you can control it using the YouTube iframe API (play, pause, seek, etc.). But you cannot control the YouTube video using the API until after the user has clicked the video.
For a foolproof user experience, you can hide all of your player-controlling UI and tell users to click the YouTube video itself to start playback. Then, once, the user has clicked the video once, you can activate your UI. Of course, you should design this only to apply to iOS.
Thanks for the headaches, Apple!
Youtube autoplay not working on mobile devices with embedded HTML5 player
As it turns out, autoplay cannot be done on iOS devices (iPhone, iPad, iPod touch) and Android.
See https://stackoverflow.com/a/8142187/2054512 and https://stackoverflow.com/a/3056220/2054512
Youtube object embed ipad
Your code only links to the YT flash video player (not even pointing to a video).
Why not just use the automatically generated "share" code of YouTube?
Look out for the "embed" button in the "share" section right below your video and copy the default code. You can even activate some additional options:
<iframe width="560" height="315" src="http://www.youtube.com/embed/KVHO-FWuMXs" frameborder="0" allowfullscreen></iframe>
This should work for all browsers.
Edit:
if you need the object/param syntax, you can switch to the "old" way of embedding videos: the (currently fourth) option can be ticked to use this deprecated code:
<object width="560" height="315"><param name="movie" value="http://www.youtube.com/v/KVHO-FWuMXs?version=3&hl=de_DE"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/KVHO-FWuMXs?version=3&hl=de_DE" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>
Test it with this music video from Psy:
http://www.youtube.com/watch?v=KVHO-FWuMXs
javascript to play youtube video isn't working
I think you need to add &enablejsapi=1
to the querystring of the URL referencing the video in your <embed>
object.
Also, try replacing your <embed>
element with an <object>
element. Here's a working example.
A note about iOS/Mobile Webkit:
Apparently, according to this answer, Apple explicitly prohibits automated control of embedded media in Safari or other Mobile Webkit browsers, requiring the iOS user to interact directly with the video object to initiate playback. This goes for object
and embed
elements, as well as HTML5 video
and audio
elements.
Related Topics
Bootstrap 4: Why Popover Inside Scrollable Dropdown Doesn't Show
Is JavaScript Execution Deferred Until CSSom Is Built or Not
Permanently Change CSS Property with JavaScript/D3Js/Jquery
Expand/Collapse Mobile Navbar Without JavaScript
Absolute Positioned Floating Header Jitters in Safari
Retrieving or Changing CSS Rules for Pseudo Elements
Avoid Having to Double-Click to Toggle Bootstrap Dropdown
How to Check If All CSS Files Have Been Downloaded to Insert HTML Using JavaScript
Image Reflection Effect Using Pure CSS
Android - Parse Js Generated Urls with Jsoup
Change Image Onclick for a Set Amount of Time
Put Cursor at End of Text Input's Value
Jquery Tablesorter CSS Arrow Icons
Jquery - "Fadein Is Not a Function"
Update Progressbar in Each Loop
Get CSS Not-Computed Property-Value with JavaScript Only
How to Prevent Material Icon Text from Showing Up When Google's Js Fails to Convert Them