mp4 video only loads when chrome dev tools are ope

2019-07-23 17:44发布

The video i have set for background of the div will only start playing when i refresh the page and the chrome dev tools are open.

html:

<div id="videoDiv">
<div id="videoBlock">
<img src="" id="vidSub">
<video preload="preload" id="vid1" autoplay="autoplay" loop="loop">
<source src="images/solPromo.mp4" type="video/mp4"></source>
</video>

css:

#vid1 {
    display: none;
}

#vidSub {
    display:block;
    width:100%;
    height:auto;
    max-width:100%;     
}

@media only screen and (min-width: 992px) {
    #vid1 {
        display: block;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        padding-top: 480px;
        z-index: 1;

    }
    #vidSub {
        display: none;
    }
}

#videoDiv {
    width: 100%; 
    max-width:992px; 
    margin:auto; 
    display:block;
    position: relative;
    z-index: 2;
    background: transparent;
}

my thought was with the z-index but i have switched them both and neither had any effect on the loading of the video w/o the dev tools opened

标签: html css mp4
1条回答
你好瞎i
2楼-- · 2019-07-23 18:04

This is not so much related to dev tools, but to new Chrome browser "Video Autoplay Policy" changes. Chrome stopped autoplaying unmuted videos.

查看更多
登录 后发表回答