2

The youtube player's play button works fine, but my custom play button does not work.

example is here

** EDIT **

The current JSFiddle now works fine on a pc/mac, but not on an iPad.

** EDIT 2 **

iframed youtube w/external play button

** EDIT 3 **

This isn't possible right now

Community
  • 1
  • 1
Jacksonkr
  • 31,583
  • 39
  • 180
  • 284

4 Answers4

5

Try this:

http://jsfiddle.net/CHu7H/

however i would recommend to use something like swfobject to embed the video.

https://developers.google.com/youtube/js_api_reference#Embedding

stewe
  • 41,820
  • 13
  • 79
  • 75
  • works great, just not on an iPad :( I should have mentioned that is really what got me here in the first place. – Jacksonkr Apr 02 '12 at 17:05
  • 1
    I'd try embedding it using an – stewe Apr 02 '12 at 17:46
  • aye aye. Well the player works in the iPad now, but the playbutton still only works on a computer! wtf.. JS Fiddle link w/iframe is in the latest edit. – Jacksonkr Apr 02 '12 at 21:38
  • Your last example (edit 2) looks good, unfortunately i don't have an ipad to test :( – stewe Apr 02 '12 at 22:02
  • Check this out: http://stackoverflow.com/questions/8972726/youtube-api-not-working-with-ipad-iphone-non-flash-device/9028877#9028877 – Jacksonkr Apr 03 '12 at 00:13
0

For whatever reason, limitations are in place. This does not work if you are on an ipad in html5. My jsfiddle does, however, work for desktop browsers.

Please post back if you've gotten this to work for ipad and I'll re-mark you as the answer.

Jacksonkr
  • 31,583
  • 39
  • 180
  • 284
0

I just had this problem too I decided to give HTML5 a try and it worked. The only problem is that you will have to host the videos on your host.

(Works on iPad) http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_video_js_prop

Sinan Samet
  • 6,432
  • 12
  • 50
  • 93
0

Every Youtube embedded player contains a player id that is in the form of :

player_uid_\d+_1

like - player_uid_271874942_1

So just do a regex search for player_uid_\d+_1 in the page source and add following js to anything you want :

var player = document.getElementById(playerId);
//playerId id the matched string from regex search in page-source
player.playVideo();

Other actions related to above player variable can be found here.

shyam
  • 596
  • 9
  • 18