$(function() {
var videoObj = []; // 存放所有vidoe的实例
for(var i = 0; i < $(".video").length; i++) {
(function(n) {
videoObj.push(
videojs('video' + (n + 1), { "controls": "true" }, function() {
this.on('play', function() {
console.log('正在播放');
// console.log(n)
for(var j = 0; j < $(".video").length; j++) {
if(n !== j) {
videoObj[j].pause()
}
}
});
//暂停--播放完毕后也会暂停
this.on('pause', function() {
console.log("暂停中")
});
// 结束
this.on('ended', function() {
console.log('结束');
})
})
);
})(i)
}
})