Html5 Full screen video

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

    You can do it with jQuery.

    I have my video and controls in their own <div> like this:

    <div id="videoPlayer" style="width:520px; -webkit-border-radius:10px; height:420px; background-color:white; position:relative; float:left; left:25px; top:55px;" align="center">
    
        <video controls width="500" height="400" style="background-color:black; margin-top:10px; -webkit-border-radius:10px;">
             <source src="videos/gin.mp4" type="video/mp4" />
        </video>
    
        <script>  
            video.removeAttribute('controls');  
        </script> 
    
        <div id="vidControls" style="position:relative; width:100%; height:50px; background-color:white; -webkit-border-bottom-left-radius:10px; -webkit-border-bottom-right-radius:10px; padding-top:10px; padding-bottom:10px;">
    
             <table width="100%" height="100%" border="0">
    
                 <tr>
                     <td width="100%" align="center" valign="middle" colspan="4"><input class="vidPos" type="range" value="0" step="0.1" style="width:500px;" /></td>
                 </tr>
    
                 <tr>
                     <td width="100%" align="center" valign="middle"><a href="javascript:;" class="playVid">Play</a></td>
                     <td width="100%" align="center" valign="middle"><a href="javascript:;" class="vol">Vol</a></td>
                     <td width="100%" align="left" valign="middle"><p class="timer"><strong>0:00</strong> / 0:00</p></td>
                     <td width="100%" align="center" valign="middle"><a href="javascript:;" class="fullScreen">Full</a></td>
                  </tr>
    
                </table>
    
             </div>
    
          </div>
    

    And then my jQuery for the .fullscreen class is:

    var fullscreen = 0;
    
    $(".fullscreen").click(function(){
      if(fullscreen == 0){
        fullscreen = 1;
        $("video").appendTo('body');
        $("#vidControls").appendTo('body');
        $("video").css('position', 'absolute').css('width', '100%').css('height', '90%').css('margin', 0).css('margin-top', '5%').css('top', '0').css('left', '0').css('float', 'left').css('z-index', 600);
        $("#vidControls").css('position', 'absolute').css('bottom', '5%').css('width', '90%').css('backgroundColor', 'rgba(150, 150, 150, 0.5)').css('float', 'none').css('left', '5%').css('z-index', 700).css('-webkit-border-radius', '10px');
    
    }
    else
        {
    
            fullscreen = 0;
    
            $("video").appendTo('#videoPlayer');
            $("#vidControls").appendTo('#videoPlayer');
    
            //change <video> css back to normal
    
            //change "#vidControls" css back to normal
    
        }
    
    });
    

    It needs a little cleaning up as I'm still working on it but that should work for most browsers as far as I can see.

    Hope it helps!

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

    From CSS

    video {
        position: fixed; right: 0; bottom: 0;
        min-width: 100%; min-height: 100%;
        width: auto; height: auto; z-index: -100;
        background: url(polina.jpg) no-repeat;
        background-size: cover;
    }
    
    0 讨论(0)
提交回复
热议问题