video标签如何实现点击按钮视频回放、全屏播放功能

  • Post author:
  • Post category:其他



回放

重置下currentTime属性

document.getElementById('videoID').currentTime=0


全屏播放

比如要控制视频全屏播放,页面上有个按钮:

html

<button id="fullScr">全屏播放</button>

<video src="xxx.mp4" id="movie"></video>

js

var btnFullScr = document.getElementById('fullScr');
var movie = document.getElementById('movie');
btnFullScr.onclick = function(){
if (movie.requestFullscreen) { 
movie.requestFullscreen(); 
} 
//FireFox 
else if (movie.mozRequestFullScreen) { 
movie.mozRequestFullScreen(); 
} 
//Chrome等 
else if (movie.webkitRequestFullScreen) { 
movie.webkitRequestFullScreen(); 
} 
//IE11 
else if (movie.msRequestFullscreen) { 
movie.msRequestFullscreen(); 
}
}



版权声明:本文为qq_35695023原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。