这是简单的代码:http://jsfiddle.net/YAFuW/1/
基本上我试着这样使用:
<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');
});
答案 0 :(得分:14)
如果您只需播放或暂停视频使用,请执行以下操作:
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>
答案 1 :(得分:12)
我不知道完成这种跨浏览器的“好”或“正确”方式 Youtube的JavaScript API也失败了。
但这种方法可靠且有效
基本上,它会杀死<iframe>
并重建它。
$('a').click(function() {
alert('stoped');
vimeoWrap = $('#vimeoWrap');
vimeoWrap.html(vimeoWrap.html());
});
答案 2 :(得分:2)
你错过了获取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>
答案 3 :(得分:0)
如果您使用Vimeo更新的API代码,则可以执行以下操作:http://jsfiddle.net/deshg/8CV2S/。您可以看到停止按钮现在为您提供警报,然后视频将被卸载。
干杯!
答案 4 :(得分:0)
最好的方法是使用Vimeo API:
示例:
<script>
var iframe = $('.vimeo-iframe').get(0);
var player = new Vimeo.Player(iframe);
player.pause();
//player.play();
</script>