ios移动端 FullScreen

时间:2025-03-28 14:42:08

ios移动端 FullScreen


在开发视屏video时,我们有时需要让视频全屏播放,正常PC及移动安卓的方法为:

//进入全屏
function FullScreen() {
    var ele = ;
    if (ele .requestFullscreen) {
        ele .requestFullscreen();
    } else if (ele .mozRequestFullScreen) {
        ele .mozRequestFullScreen();
    } else if (ele .webkitRequestFullScreen) {
        ele .webkitRequestFullScreen();
    }
}
//退出全屏
function exitFullscreen() {
    var de = document;
    if () {
        ();
    } else if () {
        ();
    } else if () {
        ();
    }
}

但是在苹果手机里FullScreen是不支持,我们需要用webkitEnterFullscreen来解决:

var u = ;
var isiOS = !!(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    var y = $('#video').find('video')
    if(isiOS){ //判断是否为ios终端
      y[0].webkitEnterFullscreen() // 开启全屏
      y[0].play()
    }