I'm trying to start playing an embedded youtube video by clicking an image. The idea is to have an image on top of a video, and when the image is clicked it fades out and starts playing the video.
I'm using jquery to fade the image, and was hoping to find a way to play or click the video using jquery as well.
The fading is working fine, but I can't figure out how to trigger the video to play.
I got it to work on a couple of browsers by setting the video to autoplay and hide it, and then fade in the video when the image was clicked. On most browsers the video would autoplay when faded in, but in chrome it started to autoplay even when it was hidden. It didn't work well in iOS either.
Since I'm pretty new at this, I'm not even sure if I'm writing it 100% correct, but I've tried something like this without success:
$('#IMAGE').click(function() { $('#VIDEO').play(); });
So, how would I go about to make the video play on an image click?
Is there a way to play the video when the image is clicked, just using jquery?
Thank you in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…