gpt4 book ai didi

javascript - 使用 Javascript 循环播放不同的多个视频

转载 作者:行者123 更新时间:2023-12-03 12:32:34 25 4
gpt4 key购买 nike

我正在尝试循环播放来自 Vimeo 等外部源的视频,一个接一个。当 Vimeo 的视频播放结束时,我已成功捕获该事件。

但是,我如何才能一个接一个地循环播放多个视频

下面是我的代码,它捕获单个视频的完成事件。任何帮助,将不胜感激。谢谢。

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Your Website</title>
<script src="jquery-1.11.1.min.js"></script>
<script src="froogaloop.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var iframe = $('#player1')[0],
player = $f(iframe),
status = $('.status');

// When the player is ready, add listeners for pause, finish, and playProgress
player.addEvent('ready', function() {
status.text('ready');

player.addEvent('pause', onPause);
player.addEvent('finish', onFinish);
player.addEvent('playProgress', onPlayProgress);
});

// Call the API when a button is pressed
$('button').bind('click', function() {
player.api($(this).text().toLowerCase());
});

function onPause(id) {
status.text('paused');
}

function onFinish(id) {
status.text('finished');
}

function onPlayProgress(data, id) {
status.text(data.seconds + 's played');
}

});
</script>


</head>
<body>
<section>
<article>

<iframe id="player1" src="http://player.vimeo.com/video/470742?api=1&player_id=player1&autoplay=1" width="400" height="225" frameborder="0"></iframe>
<p>Video status: <span class="status">...</span></p>
<p><button>Play</button> <button>Pause</button></p>

</article>
</section>
</body>
</html>

最佳答案

用这个改变你的 onFinish 函数

function onFinish(id) {
status.text('finished');
$("#player1").attr("src","new video url here")
}

Working Demo

关于javascript - 使用 Javascript 循环播放不同的多个视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23867068/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com