最近再写一个关于VR视频播放的项目,最后选择用 JW player做为插件,此处记录一下
初始化:
<script>
var player = jwplayer('example').setup({
playlist: [{
title: '{{$log.title}}',
mediaid: 'AgqYcfAT',
image:'{{$log.picpath}}',
stereomode: 'monoscopic',
file: '{{$log.url}}'
}]
});
</script>
一些方法:
jwplayer().getFullscreen(false); //取消全屏
jwplayer().pause(); //暂停播放
jwplayer().seek(120); //指定播放时间
监听播放进度:
jwplayer().on('time',function (e) {
var time = e.position;
if(time>120){
jwplayer().getFullscreen(false);
jwplayer().pause();
jwplayer().seek(120);
swal({
title:"Please log in",
text: "You can only watch two minutes if you don't log in",
type:'error',
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "To Log In",
cancelButtonText: "Cancel",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm){
if (isConfirm) {
swal.close();
$('#sign').modal('show');
}else{
swal.close();
}
});
}
});