javascript - Youtube api - stop video -



javascript - Youtube api - stop video -

i need help youtube api , embeded videos. want stop video when clicked on element (div,link,td etc.). trying work 1 video now, final function of script should stop videos loaded on current page. have read thru yt api documentation im beginner in js still quite hard understand me.

<html> <head> <script type="text/javascript" src="swfobject.js"></script> </head> <body> <a href="javascript:ytplayer.stopvideo()">play</a> <br/> <iframe id="ytplayer" src="http://www.youtube.com/embed/8ax-dar3abs?rel=0&iv_load_policy=3&showinfo=0&enablejsapi=1&version=3&playerapiid=ytplayer" type="application/x-shockwave-flash" frameborder="0" allowscriptaccess="always"></iframe> </body> </html>

thanks in advance advices

you can't command if embed iframe. have utilize object embedding, this:

<object id="ytplayer" style="height: 390px; width: 640px"> <param name="movie" value="http://www.youtube.com/v/8ax-dar3abs?version=3&enablejsapi=1"> <param name="allowscriptaccess" value="always"> <embed id="ytplayer" src="http://www.youtube.com/v/8ax-dar3abs?version=3&enablejsapi=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="640" height="390"> </object>

the rest of code should work after that, although may need updated say:

<a href="javascript:document.getelementbyid('ytplayer').stopvideo()">play</a>

also, have seen demo site? http://code.google.com/apis/youtube/youtube_player_demo.html

javascript api video youtube

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -