[英]Changing JWPlayer video on Click
我閱讀了此Changeing JWPlayer視頻onClick並進行了嘗試,但播放第二個視頻時遇到問題。 每當我單擊“播放視頻2”時,都不會發生! 下面的代碼
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My JWPlayer</title>
<script type="text/javascript" src="jwplayer.js" ></script>
<script type="text/javascript">
function changeVideo(filename) {
jwplayer("video").setup({
file: filename,",
height: 360,
width: 640,
});
jwplayer('video').load();
}
</script>
</head>
<body>
<div id="video">Loading the player ...</div>
<script type="text/javascript">
jwplayer("video").setup({
file: "http://longtailvideo.com/jw/upload/bunny.flv",
height: 360,
width: 640
});
</script>
<p><a href="javascript:void();" onclick="javascript:changeVideo("http://www.auby.no/files/video_tests/h264_720p_mp_3.1_3mbps_aac_shrinkage.mp4");">Play Video 2</a></p>
</body>
</html>
function changeVideo(filename) {
jwplayer("video")
.setup({
file: filename,
height: 360,
width: 640
})
.load()
;
}
changeVideo("videoURL01");
$(".changeVideo").click(function()
{
var videoUrl = $(this).attr("data-video_url");
changeVideo(videoUrl);
})
html
為了更有趣,將videoURL添加為錨點的數據屬性
<div id="video">Loading the player ...</div>
<a href="#" class="changeVideo" data-video_url="videoURL2">load video 2</a>
這就是你所需要的
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.