Skip to main content
Inspiring
July 25, 2022
Answered

mobile video delay

  • July 25, 2022
  • 1 reply
  • 3175 views

minor issue -

 

the incredibly generous Osgood guided me into a video slideshow as my background for a showcase site

https://toddheymandirector.com/

 

evenutally i will create a responsive site but for now

I created a mobile/tablet version that works wonderfully on a desktop using developer tools

https://toddheymandirector.com/tablet/

however if you watch on a tablet or mobile (resized-mobile version as soon as I figure out the pause)..

it has a pause in each video- a freeze-frame for a second before it starts playing. 

 

is there an attibute I should add ?

i optimized them all so they are 5m or under and i tried preloading but it makes no difference..

 

    This topic has been closed for replies.
    Correct answer osgood_

    i made a vid only page

    https://toddheymandirector.com/tablet/index_movietest_vidonly.html



    I've testing the code below out on a couple of web-servers I have access to and there are no major issues. All videos/text load as expected.

     

    On Chrome browser I didnt see the slight delayed start of the videos, it worked smoothly BUT on Safari desktop and Chrome mobile there was a slight delay before the videos started, not much, but a slight lag, so now I've actually included an overlay above the video to try and mask this. For me it seems to be working. I can no longer see the delay in Safari destop or on Chrome mobile.

     

    I've used your set of _m.mp4 videos to test.

     

    What I suggest is take the code as it is and upload it as a test page to your server and see how your server responds. If it works then DONT alter any of the timings. You can alter the type-face/color/spacing of course but don't start adding any weird css like 'animation delay' to the css, which I saw in your last version.

     

    Once/if it works in a stand alone page then transfer the code to your main page but check as you go along to make sure there are no code conflicts. 

     

    If the test page doesnt work on your server I have no more suggestions.

     

     

     

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Full Page Video Content</title>
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Source+Serif+Pro:wght@300;400&display=swap" rel="stylesheet">
    <style>
    body {
    margin:	 0;
    font-family: 'Source Serif Pro', serif;
    }
    .videoShowcase {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100vh;
    width:	100vw;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    }
    .videoContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000;
    }
    .videoContainer::after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    content: '';
    background-color: rgba(0, 0, 0, 0.3);
    }
    .videoContainer video {
    min-width: 100%;
    min-height: 100%;
    object-fit: cover;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 1s ease-in-out;
    opacity: 0;
    }
    .videoText {
    z-index: 10;
    transform: translateY(200px);
    transition: all 700ms ease-in-out;
    opacity: 0;
    }
    .videoText h2 {
    margin:	0 0 10px 0;
    padding: 0;
    color: #fff;
    text-align: center;
    font-size: 45px;
    line-height: 45px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 400;
    }
    .videoText h4 {
    margin:	0 0 15px 0;
    padding: 0;
    color: #fff;
    text-align: center;
    font-size: 25px;
    line-height: 25px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 400;
    }
    .videoText h5 {
    margin:	0;
    padding: 0;
    color: #fff;
    font-size: 16px;
    line-height: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    }
    .slideUp {
    transform: translateY(0);
    }
    .fullOpacity {
    opacity: 1!important;
    }
    
    .videoOverlay {
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 9;
    transition: all 700ms ease-in-out;
    }
    .opacityZero {
    opacity: 0;
    }
    </style>
    
    </head>
    <body>
    <section class="videoShowcase">
    <div class="videoOverlay"></div>
    <div class="videoContainer">
    <video class="video" src="movies/ocean4.mp4" autoplay muted></video>	
    </div>
    <div class="videoText">
    <h2>Todd Heyman</h2>
    <h4>Film Director</h4>
    </div>
    </section>
    
    
    <script>
    const videoText = document.querySelector('.videoText');
    const video = document.querySelector('.video');
    const videoOverlay = document.querySelector('.videoOverlay');
    
    const videos = [
    {name: 'ocean4.mp4' , title: 'Todd Heyman' , director: 'Film Director' , agency: ''},
    {name: 'nike_getaway_m.mp4' , title: 'Nike' , director: 'The Getaway' , agency: 'Agency &bull; Wieden &amp; Kennedy'},
    {name: 'redcross_m.mp4' , title: 'Red Cross' , director: 'Jumper' , agency: 'Agency &bull; Ogilvy NY'},
    {name: 'bartenura_m.mp4' , title: 'Bartenura' , director: 'The Text' , agency: 'Agency &bull; DDB Paris'}
    ];
    
    // Default when page loads
    setTimeout(function() {
    videoText.classList.add('slideUp' , 'fullOpacity');
    setTimeout(function(){
    video.classList.add('fullOpacity');
    videoOverlay.classList.add('opacityZero');
    }, 100);
    }, 200);
    
    let count = 0;
    
    
    // Change content after 6 seconds
    setInterval(function() {
    video.classList.remove('fullOpacity');
    videoText.classList.remove('fullOpacity');	
    
    videoOverlay.classList.remove('opacityZero');
    
    
    setTimeout(function(){
    videoText.classList.remove('slideUp');	
    }, 500);
    
    
    
    count === videos.length - 1 ? count = 0 : count++;
    
    setTimeout(function(){
    videoText.classList.add('slideUp' , 'fullOpacity');	
    
    
    videoText.innerHTML = `
    <h2>${videos[count].title}</h2>
    <h4>${videos[count].director}</h4>
    <h5>${videos[count].agency}</h5>
    `;	
    video.src=`movies/${videos[count].name}`;
    }, 1000);
    
    
    setTimeout(function(){
    videoOverlay.classList.add('opacityZero');
    }, 1500);
    
    
    setTimeout(function(){
    video.classList.add('fullOpacity');
    }, 1000);
    
    
    }, 6000)
    </script>
    
    </body>
    </html>​

     

     

     

     

     


     

     

    1 reply

    Legend
    July 25, 2022

    There is a possibility that if you just load the video by javascript there will be a slight time lag before it starts, given the size of the files. The original solution had a black screen overlay before the video/s appeared, that just might have 'concealed' the slight delay. I'm not 100% saying that is the case, its a possibility, but you've mixed things up enough for it to not work properly, either on desktop or mobile. Also not sure why you've elected to use the .mov format rather than mp4.

     

    I dont know a lot about video format but .mov is NOT one of the supported formats for the <video> tag according to the link below:

    https://www.w3schools.com/tags/tag_video.asp 

     

    So that also could be having an undesired effect.

    Jon Fritz
    Community Expert
    Community Expert
    July 25, 2022
    REELHEROAuthor
    Inspiring
    July 25, 2022

    thanks Jon - ive been using the gif converter it rocks..