这里是简单的代码: http://jsfiddle.net/YAFuW/1/
basicly我试图用这样的:
<iframe src="http://player.vimeo.com/video/40977539?api=1" width="400" height="225" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
<a href="#">STOP</a>
$('a').click(function() {
alert('stoped');
froogaloop.api('unload');
});
我不知道要完成这个跨浏览器的一个“好”或“右”的方式。
YouTube的的JavaScript API失败了。
但这种方法是可靠的和做的工作。
基本上,它杀死<iframe>
和重建它。
$('a').click(function() {
alert('stoped');
vimeoWrap = $('#vimeoWrap');
vimeoWrap.html(vimeoWrap.html());
});
查看在的jsfiddle
如果你只需要播放或暂停视频使用这样的:
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');
})
和标记:
<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/
你错过了获得VIMEO视频的ID:
var iframe = $('#vimeo-player')[0];
var player = $f(iframe);
player.api('unload');
例如: 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>
如果您使用的Vimeo的最新API代码,那么你可以像下面: http://jsfiddle.net/deshg/8CV2S/ 。 你可以看到停止按钮现在给你的警告,然后视频被卸载。
干杯!
最好的办法是与工作Vimeo的API :
例:
<script>
var iframe = $('.vimeo-iframe').get(0);
var player = new Vimeo.Player(iframe);
player.pause();
//player.play();
</script>