videojs

时间:2023-03-10 04:32:19
videojs
     <link href="http://vjs.zencdn.net/5.5.3/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/5.5.3/video.js"></script>
<!-- If you'd like to support IE8 -->
<script src="http://vjs.zencdn.net/ie8/1.1.1/videojs-ie8.min.js"></script> <video id="roomVideo" class="video-js" controls preload="auto" width="100%" height="100%" class="vjs-big-play-centered">
<source src="${RTMPUrl }" type="rtmp/flv">
<p class="vjs-no-js">播放视频需要启用 JavaScript,推荐使用支持HTML5的浏览器访问。</p>
</video> <script type="text/javascript">
document.getElementById("roomVideo").style.height= window.innerHeight +"px";
document.getElementById("roomVideo").style.width= window.innerWidth +"px"; var options = {
techOrder : ["html5","flash"],
//autoplay:true, //是否自动播放
bigPlayButton:false, //是否显示播放按钮
controls:true, //是否用显示控制条
textTrackDisplay:false,
posterImage:false,
errorDisplay:false,
control:{
captionsButton:false,
chaptersButton:false,
subtitlesButton:false,
liveDisplay:false,
playbackRateMenuButton:false
},
controlBar: {
muteToggle:false,
ProgressControl:false
}
};
var player = videojs('roomVideo', options, function onPlayerReady() {
videojs.log('播放器已经准备好了!');
player.play();
startVideo(); this.on('ended', function() {
console.log('播放结束了!');
}); }); var isVideoBreak;
function startVideo() {
//判断开始播放视频,移除高斯模糊等待层
/*var isVideoPlaying = setInterval(function(){
var currentTime = player.currentTime();
if(currentTime > 0){
$('.vjs-poster').remove();
clearInterval(isVideoPlaying);
}
},200)*/ //判断视频是否卡住,卡主3s重新load视频
var lastTime = -1,
tryTimes = 0; clearInterval(isVideoBreak);
isVideoBreak = setInterval(function(){
var currentTime = player.currentTime();
if(currentTime == lastTime){
//此时视频已卡主3s
//设置当前播放时间为超时时间,此时videojs会在play()后把currentTime设置为0
player.currentTime(currentTime+10000);
player.play(); //尝试5次播放后,如仍未播放成功提示刷新
if(++tryTimes > 5){
//dialog('提示',"您的网速有点慢,刷新下试试",1);
window.location.reload();
tryTimes = 0;
}
}else{
lastTime = currentTime;
tryTimes = 0;
}
},3000)
} </script> ${HLSUrl } <br/>
${RTMPUrl } <br/>
${HDLUrl } <br/>