I am using an image over the youtube video. On the image click (#imageID) the video is shown. Now I have a problem how to stop the video, reverse it back to the start position (0:00) and show image over the video again on the button click (#stop_replace) for example.
HTML:
<div id="ytapiplayer2" style="display:none;">
<object width="600" height="375">
<param name="movie" value="http://www.youtube.com/v/WSulgIt-Q_c?fs=1&hl=en_US&rel=0&autoplay=1"></param>
<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/WSulgIt-Q_c?fs=1&hl=en_US&rel=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="375"></embed>
</object>
</div>
<img src="image.jpg" id="imageID" />
<img src="button_image.jpg" id="stop_replace" />
JavaScript/Jquery:
$('#imageID').click(function() {
$('#ytapiplayer2').show();
$('#imageID').hide();
});
The code on jsfiddle: http://jsfiddle.net/AdUvY/6/. I know this also could be done using iframe but I need it implemented in this way. Could you help me please. Thanks.
I created a sample Demo for you.
Please check this and let me know if it gives a solution to your problem.
Demo : http://jsfiddle.net/codebombs/Rpgkk/2/
Here I am using jQuery SWFObject Plugin from http://jquery.thewikies.com/swfobject/. This allows us to write simple code to embed SWF Objects.
Also, in IE Browsers if you jus Hide the SWF object, then there is a chance of playing in the background. So, best thing will be remove the complete player from the div, if you don’t need that any more.
So, I removed the SWF object from player div when I don’t want that.
This automatically allows us to start the player from starting when we need.
Please let me know if it need any modifications.