Html5 Full screen video

前端 未结 8 693
名媛妹妹
名媛妹妹 2020-11-30 01:38

Is there any way to do this? I wan to play video in full screen. Without browser. setting width:100%; height:100%; keep browser visible yet

8条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 02:26

    No, there is no way to do this yet. I wish they add a future like this in browsers.

    EDIT:

    Now there is a Full Screen API for the web You can requestFullscreen on an Video or Canvas element to ask user to give you permisions and make it full screen.

    Let's consider this element:

    
    

    We can put that video into fullscreen mode with script like this:

    var elem = document.getElementById("myvideo");
    if (elem.requestFullscreen) {
      elem.requestFullscreen();
    } else if (elem.mozRequestFullScreen) {
      elem.mozRequestFullScreen();
    } else if (elem.webkitRequestFullscreen) {
      elem.webkitRequestFullscreen();
    } else if (elem.msRequestFullscreen) { 
      elem.msRequestFullscreen();
    }
    

    Full documentation

提交回复
热议问题