加载BigVideo.js之前,小玩家出现在左上角

2 html javascript css jquery html5-video

我正在尝试将BigVideo.js实现为Bootstrap 3.0.3网站中的集中容器背后的背景视频.

正在播放样本视频,但是,当页面加载时,在视频最终播放之前,左上角会出现一个小玩家:

在此输入图像描述

如果您在Firefox中查看此示例,则可以看到加载动画的分布.

在显示内容和视频之前,我希望这个加载动画居中并跨越整个背景.之前在GitHub上报告了这个问题,但没有提供令人满意的,有效的解决方案.

不幸的是,我的JavaScript知识非常有限.我已经实现了PreLoadMe.js来隐藏BigVideo.js的加载过程,但不幸的是,当PreLoadMe.js完成后,后台视频开始加载.所以同样的效果发生了.

我目前按照以下方式调用BigVideo函数,如支持站点所述:

<!-- BigVideo -->

<script>
$(function() {
var BV = new $.BigVideo();
BV.init();
BV.show('http://vjs.zencdn.net/v/oceans.mp4', {ambient:true});
});
</script>

<!-- Preloader -->

<script type="text/javascript">
//<![CDATA[
    $(window).load(function() { // makes sure the whole site is loaded
        $('#status').fadeOut(); // will first fade out the loading animation
        $('#preloader').delay(350).fadeOut('slow'); // will fade out the white DIV that covers the website.
        $('body').delay(350).css({'overflow':'visible'});
    })
//]]>
</script>
Run Code Online (Sandbox Code Playgroud)

HTML:

<!-- Preloader -->
<div id="preloader">
<div id="status">&nbsp;</div>
</div>

<div class="container">


  <div class="content-box" >
    <h1>Ipsum Lorum</h1>
    <p class="lead">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam.</p>
  </div>

</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

html, body { 
    overflow: hidden;
    margin:0;
    padding:0;
}

.content-box {

    position: absolute;
    top: 50%;
    left: 50%;
    text-align: center;

    background-color: rgba(0,0,0,0.75);
    color: white;

    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;

    z-index: 2;

    padding: 50px;
    width: 400px;
    height: 400px;
    margin: -200px 0 0 -200px;  
}


#preloader {
    position:fixed;
    top:0;
    left:0;
    right:0;
    bottom:0;
    background-color:#fff; /* change if the mask should have another color then white */
    z-index:99; /* makes sure it stays on top */
}

#status {
    width:200px;
    height:200px;
    position:absolute;
    left:50%; /* centers the loading animation horizontally one the screen */
    top:50%; /* centers the loading animation vertically one the screen */
    background-image:url(../img/status.gif); /* path to your loading animation */
    background-repeat:no-repeat;
    background-position:center;
    margin:-100px 0 0 -100px; /* is width and height divided by two */
}
Run Code Online (Sandbox Code Playgroud)

小智 12

这是一个适合我的解决方案:

CSS:

#big-video-wrap {
    display: none;
}
Run Code Online (Sandbox Code Playgroud)

JAVASCRIPT:

BV.getPlayer().on('durationchange',function(){
    $('#big-video-wrap').fadeIn();
});
Run Code Online (Sandbox Code Playgroud)