调用方法:

autoFullScrenn(obj)

 

还有一篇:

使用MediaElement.js构建个性的HTML5音频和视频播放器

 

var fullscreen = function(elem) {
    var prefix = \'webkit\';
      if ( elem[prefix + \'EnterFullScreen\'] ) {
        return prefix + \'EnterFullScreen\';
      } else if( elem[prefix + \'RequestFullScreen\'] ) {
        return prefix + \'RequestFullScreen\';
      };
    return false;
};

function autoFullScrenn(v){
    var ua   = navigator.userAgent.toLowerCase();  
    var Android = String(ua.match(/android/i)) == "android";
    // if(!Android) return;//非android系统不使用;
    var video  = v,doc = document;
    var fullscreenvideo = fullscreen(doc.createElement("video"));
    if(!fullscreen) {
        alert("不支持全屏模式");
        return;
    }
    video.addEventListener("webkitfullscreenchange",function(e){
        if(!doc.webkitIsFullScreen){//退出全屏暂停视频
            this.pause();
            // this.pause();
        };
    }, false);
    video.addEventListener("click", function(){
        this.play();
        video[fullscreenvideo]();
    }, false);


    video.addEventListener(\'ended\',function(){
        doc.webkitCancelFullScreen(); //播放完毕自动退出全屏
    },false);

};

// autoFullScrenn(video_obj)

  

版权声明:本文为dtdxrk原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/dtdxrk/p/4602166.html