Html5 Full screen video

前端 未结 8 648
名媛妹妹
名媛妹妹 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:16

    All hail HTML5 _/\_

    var videoElement = document.getElementById('videoId');    
    videoElement.webkitRequestFullScreen();
    
    0 讨论(0)
  • 2020-11-30 02:16

    You can use html5 video player which has full screen playback option. This is a very good html5 player to have a look.
    http://sublimevideo.net/

    0 讨论(0)
  • Here is a very simple way (3 lines of code) using the Fullscreen API and RequestFullscreen method that I used, which is compatible across all popular browsers:

    var elem = document.getElementsByTagName('video')[0];
    var fullscreen = elem.webkitRequestFullscreen || elem.mozRequestFullScreen || elem.msRequestFullscreen;
    fullscreen.call(elem); // bind the 'this' from the video object and instantiate the correct fullscreen method.

    For browser compatibility: MDN & Can I use

    0 讨论(0)
  • 2020-11-30 02:20
        if (vi_video[0].exitFullScreen) vi_video[0].exitFullScreen();
        else if (vi_video[0].webkitExitFullScreen) vi_video[0].webkitExitFullScreen();
        else if (vi_video[0].mozExitFullScreen) vi_video[0].mozExitFullScreen();
        else if (vi_video[0].oExitFullScreen) vi_video[0].oExitFullScreen();
        else if (vi_video[0].msExitFullScreen) vi_video[0].msExitFullScreen();
        else { vi_video.parent().append(vi_video.remove()); }
    
    0 讨论(0)
  • 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:

    <video controls id="myvideo">
      <source src="somevideo.webm"></source>
      <source src="somevideo.mp4"></source>
    </video>
    

    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

    0 讨论(0)
  • 2020-11-30 02:31

    Add object-fit: cover to the style of video

    <video controls style="object-fit: cover;" >
    
    0 讨论(0)
提交回复
热议问题