原文連接:https://www.jianshu.com/p/e4573acf6564javascript
window.onresize = function(){ test_video.style.width = window.innerWidth + "px"; test_video.style.height = window.innerHeight + "px"; }
<video x5-video-player-type="h5" x5-video-orientation="landscape|portrait"/>
setTimeout(function () { video.play(); }, 1000); video.addEventListener('touchstart', function () { video.play(); });
video.on('x5videoenterfullscreen', function() { //延時修改video尺寸以佔滿全屏 //$(this).attr('x5-video-player-type',''); setTimeout(function() { $('video').css({ width: window.innerWidth, height: window.innerHeight, }); }, 200); });
//退出全屏狀態 video.on('x5videoexitfullscreen', function() { //清除 $(this).css({ width: '', height: '', }); });
video { object-position: 0 0; }
function gp() {
var _this=video;// video爲當前video元素 var percent=null; // FF4+, Chrome if (_this && _this.buffered && _this.buffered.length > 0 && _this.buffered.end && _this.duration) { percent = _this.buffered.end(0) / _this.duration; } // Some browsers (e.g., FF3.6 and Safari 5) cannot calculate target.bufferered.end() // to be anything other than 0. If the byte count is available we use this instead. // Browsers that support the else if do not seem to have the bufferedBytes value and // should skip to there. Tested in Safari 5, Webkit head, FF3.6, Chrome 6, IE 7/8. else if (_this && _this.bytesTotal != undefined && _this.bytesTotal > 0 && _this.bufferedBytes != undefined) { percent = _this.bufferedBytes / _this.bytesTotal; } if (percent !== null) { percent = 100 * Math.min(1, Math.max(0, percent)); return percent; } return 0; }