Youtube api – stop video

You can’t control it if you embed it with an iframe. You have to use object embedding, like 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 your code should generally work after that, although it may need to be updated to say:

<a href="javascript:document.getElementById('ytplayer').stopVideo()">Play</a>

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

Leave a Comment