here is the simple code: http://jsfiddle.net/YAFuW/1/
basicly i tried to use like this:
You missed get the id of the vimeo video:
var iframe = $('#vimeo-player')[0];
var player = $f(iframe);
player.api('unload');
Example: http://jsfiddle.net/joan_r/dutzh512/
<html>
<head>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="http://a.vimeocdn.com/js/froogaloop2.min.js"></script>
<style>
#play,#pause,#stop{
width:60px;
margin:5px;
text-align: center;
border: solid;
cursor:pointer;
}
</style>
</head>
<body>
<iframe id="vimeo-player" src="//player.vimeo.com/video/76979871" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<div id="play">[PLAY]</div>
<div id="pause">[PAUSE]</div>
<div id="stop">[STOP]</div>
<script>
$('#play').click(function() {
var iframe = $('#vimeo-player')[0];
var player = $f(iframe);
player.api('play');
});
$('#pause').click(function() {
var iframe = $('#vimeo-player')[0];
var player = $f(iframe);
player.api('pause');
});
$('#stop').click(function() {
var iframe = $('#vimeo-player')[0];
var player = $f(iframe);
player.api('unload');
});
</script>
</body>
</html>
I don't know a "good" or "right" way to accomplish this cross-browser.
Youtube's JavaScript API fails, too.
But this method is reliable and does work.
Basically, it kills the <iframe>
and rebuilds it.
$('a').click(function() {
alert('stoped');
vimeoWrap = $('#vimeoWrap');
vimeoWrap.html(vimeoWrap.html());
});
View at JSFiddle
If you use Vimeo's updated API code then you can do it like the following: http://jsfiddle.net/deshg/8CV2S/. You can see the stop button now gives you the alert and then the video is unloaded.
Cheers!
if you need only play or pause video use like this:
var iframe = $('#vimeo-player')[0];
var player = $f(iframe);
$('#stop').click(function() {
alert('stoped');
player.api('pause');
});
$('#play').click(function(){
alert('play');
player.api('play');
})
and markup:
<script src="http://a.vimeocdn.com/js/froogaloop2.min.js"></script>
<iframe id="vimeo-player" src="http://player.vimeo.com/video/40977539?api=1" width="400" height="225" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<a id="stop" href="#">STOP</a>
<a id="play" href="#">PLAY</a>
http://jsfiddle.net/zimm/8CV2S/14/
The best way is to work with Vimeo API:
Example:
<script>
var iframe = $('.vimeo-iframe').get(0);
var player = new Vimeo.Player(iframe);
player.pause();
//player.play();
</script>