Javascript循环浏览图像
Javascript loop through images
我正在使用video.js创建一个播放列表视频组件。我试图循环遍历一个数组,并将图像放在div"playlistnav"中。下面是我的代码。海报变量是保持图像的因素。
<!DOCTYPE html>
<html>
<head>
<title>Video.js | HTML5 Video Player</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- Chang URLs to wherever Video.js files will be hosted -->
<link href="video-js.css" rel="stylesheet" type="text/css">
<!-- video.js must be in the <head> for older IEs to work. -->
<script src="video.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="videojs-playlists.js"></script>
<!-- Unless using the CDN hosted version, update the URL to the Flash SWF -->
<script>
videojs.options.flash.swf = "video-js.swf";
</script>
</head>
<body>
<div class="playlistnav">
<h1></h1>
<button type="button" data-action="prev">Previous</button>
<button type="button" data-action="next">Next</button>
</div>
<div class="wrapper">
<div class="videocontent">
<video id="videoplayer" class="video-js vjs-default-skin vjs-fullscreen" controls preload="none" width="auto" height="auto"
data-setup="{}">
</video>
</div>
</div>
<script type="text/javascript">
var vid = videojs("videoplayer");
vid.on("ended", function(){
alert("This is the end");
})
</script>
<script>
var videos = [
{
src:['http://stream.flowplayer.org/bauhaus/624x260.mp4'],
poster : 'http://flowplayer.org/media/img/demos/minimalist.jpg',
title : 'Video 1'
},
{
src : ['http://stream.flowplayer.org/night3/640x360.mp4'],
poster : 'http://flowplayer.org/media/img/demos/playlist/railway_station.jpg',
title : 'Video 2'
},
{
src : ['http://stream.flowplayer.org/functional/624x260.mp4'],
poster : 'http://flowplayer.org/media/img/demos/functional.jpg',
title : 'Video 3'
}
];
var player = videojs('videoplayer');
player.playList(videos, {
getVideoSource: function(vid, cb) {
cb(vid.src, vid.poster);
}
});
$('[data-action=prev]').on('click', function(e) {
player.prev();
});
$('[data-action=next]').on('click', function(e) {
player.next();
});
</script>
</body>
</html>
试试这样的东西:
document.ready(function(){
var nav = $('.playlistnav');
$.each(videos, function(i,val){
nav[i].append("<img src=" + $(this).poster + ">");
});
});
JSFiddle:http://jsfiddle.net/skoshy/7CMsn/
我添加的唯一部分是:
for (x=0; x < videos.length; x++) {
$('.playlistnav').append('<img width="200" src="'+videos[x].poster+'"/>');
}
相关文章:
- 循环浏览多个身体背景图像
- 模式上的后退和前进按钮位于图像库上(可滚动浏览)
- 利用移动设备上的滑动功能浏览图像阵列
- Javascript循环浏览图像
- 基于缩略图在路径中循环浏览图像
- 循环浏览 base64 图像并保存为 pdf
- 如何自动循环浏览图像数组
- 如何使用上一个/下一个按钮循环浏览图像
- 如何让不同的图像和文本自动循环浏览?我的图像正在循环,但我的文本不是
- 如何禁止复制浏览我的网站的图像
- 使用 javascript 循环浏览多个图像
- 如何设置图像数组并单独循环浏览它们
- 如何在同一页面中浏览和显示图像
- 在 javascript 中循环浏览图像数组
- 循环浏览 javascript 以进行图像预览
- 在jquery/Javascript中浏览图像时,如何从本地磁盘获取本地url图像路径
- 循环浏览web字体文件中的图像
- 如何循环浏览每个图像并在casperjs脚本中检查其是否存在错误
- 使用按钮循环浏览存储在阵列中的图像
- 循环浏览图像中的像素