Your browser isn't supported
It looks like you're using an old web browser. To get the most out of the site and to ensure guides display correctly, we suggest upgrading your browser now. Download the latest:

Welcome to the MSE Forums

We're home to a fantastic community of MoneySavers but anyone can post. Please exercise caution & report spam, illegal, offensive or libellous posts/messages: click "report" or email forumteam@. Skimlinks & other affiliated links are turned on

Search
  • FIRST POST
    • scaredofdebt
    • By scaredofdebt 11th Sep 18, 3:18 PM
    • 1,198Posts
    • 582Thanks
    scaredofdebt
    MP4 Video not playing in Chrome
    • #1
    • 11th Sep 18, 3:18 PM
    MP4 Video not playing in Chrome 11th Sep 18 at 3:18 PM
    Hi,

    Not sure if anyone can help but I have trawled the net without much success.

    I am building a website with an embedded MP4 video in a slider, it works OK in Firefox and IE but not Chrome, I have tested in on a laptop, desktop and phone so I know the issue is Chrome.

    Any ideas?

    I'm not allowed to post links am I?

    OK so I am thanks:

    http://sweeneydogkr.co.uk/video.html

    Cheers for any ideas, workarounds etc.
    Last edited by scaredofdebt; 11-09-2018 at 3:24 PM. Reason: Added link, hope it's OK!
    Make 2018 in 2018 Challenge - Total to date 2,108
Page 1
    • AndyPix
    • By AndyPix 11th Sep 18, 3:19 PM
    • 3,967 Posts
    • 3,339 Thanks
    AndyPix
    • #2
    • 11th Sep 18, 3:19 PM
    • #2
    • 11th Sep 18, 3:19 PM
    You can post links - lets have a look
    Running with scissors since 1978
    • scaredofdebt
    • By scaredofdebt 11th Sep 18, 3:28 PM
    • 1,198 Posts
    • 582 Thanks
    scaredofdebt
    • #3
    • 11th Sep 18, 3:28 PM
    • #3
    • 11th Sep 18, 3:28 PM
    Oh, you may need to scroll right as the first thing in the slider is an image, the video should autoplay.
    Make 2018 in 2018 Challenge - Total to date 2,108
    • AndyPix
    • By AndyPix 11th Sep 18, 4:22 PM
    • 3,967 Posts
    • 3,339 Thanks
    AndyPix
    • #4
    • 11th Sep 18, 4:22 PM
    • #4
    • 11th Sep 18, 4:22 PM
    Ok, so your video is there , the issue is that it is not autoplaying ..


    I have seen this before in HTML5 and chrome not listening to the autoplay flag here ..





    Try a little javascript to make it autoplay ..


    Directly after you close the video tag, add this line


    <script> document.getElementById('asvideo0').play(); </script>


    That should sort you out . If not, then get on google and research the fact that chrome doesnt like autoplaying videos that are not muted - so you may need to add some tags to mute the video (even if it doesnt have sound !!)
    Last edited by AndyPix; 11-09-2018 at 4:28 PM.
    Running with scissors since 1978
    • scaredofdebt
    • By scaredofdebt 13th Sep 18, 12:39 PM
    • 1,198 Posts
    • 582 Thanks
    scaredofdebt
    • #5
    • 13th Sep 18, 12:39 PM
    • #5
    • 13th Sep 18, 12:39 PM
    Thanks AndyPix, appreciate the help, unfortunately your idea just gives a blank white screen.


    But you did give me some other ideas, so far I've got it so Chrome does now show the video but it doesn't autploay it, I've raised this on the Google developers forum but no response as yet.
    Make 2018 in 2018 Challenge - Total to date 2,108
    • AndyPix
    • By AndyPix 13th Sep 18, 12:58 PM
    • 3,967 Posts
    • 3,339 Thanks
    AndyPix
    • #6
    • 13th Sep 18, 12:58 PM
    • #6
    • 13th Sep 18, 12:58 PM
    Thats strange ..
    You added the line directly after the </video> tag ?


    have you added mute tags like i suggested ? you should add "playsinline" and "muted"


    Chrome will not autoplay videos unless they are muted
    Running with scissors since 1978
    • scaredofdebt
    • By scaredofdebt 13th Sep 18, 2:54 PM
    • 1,198 Posts
    • 582 Thanks
    scaredofdebt
    • #7
    • 13th Sep 18, 2:54 PM
    • #7
    • 13th Sep 18, 2:54 PM
    Yes, this is the code:


    <video playsinline autoplay muted controls loop>
    <source src="images/sweeneydog.mp4" type="video/mp4">


    Your browser does not support the video tag. But you could include an iframe/embeded video here.
    </video>
    <script> document.getElementById('asvideo0').play(); </script>


    I've put it back in if you want to look at the white screen.
    Make 2018 in 2018 Challenge - Total to date 2,108
    • scaredofdebt
    • By scaredofdebt 13th Sep 18, 3:03 PM
    • 1,198 Posts
    • 582 Thanks
    scaredofdebt
    • #8
    • 13th Sep 18, 3:03 PM
    • #8
    • 13th Sep 18, 3:03 PM
    OK so this fixed it, thanks to Stackoverflow:


    </body>

    <script>
    var myVideo = document.getElementById("myVideo");
    setTimeout(() => {
    myVideo.play();
    }, 1000);
    </script>
    </html>


    Called the video id "myVideo"


    Appreciate your help Andy.
    Make 2018 in 2018 Challenge - Total to date 2,108
    • AndyPix
    • By AndyPix 13th Sep 18, 3:14 PM
    • 3,967 Posts
    • 3,339 Thanks
    AndyPix
    • #9
    • 13th Sep 18, 3:14 PM
    • #9
    • 13th Sep 18, 3:14 PM
    Yes, this is the code:


    <video playsinline autoplay muted controls loop>
    <source src="images/sweeneydog.mp4" type="video/mp4">


    Your browser does not support the video tag. But you could include an iframe/embeded video here.
    </video>
    <script> document.getElementById('asvideo0').play(); </script>


    I've put it back in if you want to look at the white screen.
    Originally posted by scaredofdebt

    Yeah - the problem was that you werent tagging your video with an ID , so the script didnt know what element you were referring to.
    in your video tag, you should have had id="asvideo0" like in my code snippet and it would have worked.


    Anyway you're sorted now - nice work


    (I still think my one liner is better than abstracting it though )
    Last edited by AndyPix; 13-09-2018 at 3:21 PM.
    Running with scissors since 1978
    • AndyPix
    • By AndyPix 13th Sep 18, 5:14 PM
    • 3,967 Posts
    • 3,339 Thanks
    AndyPix
    Oh, and you also want ..


    document.getElementById("myVideo").controls = false;


    So the controls dont appear when you hovver the mouse over the video
    Running with scissors since 1978
    • scaredofdebt
    • By scaredofdebt 14th Sep 18, 3:16 PM
    • 1,198 Posts
    • 582 Thanks
    scaredofdebt
    Thanks, yes Javascript isn't my strong point!
    Make 2018 in 2018 Challenge - Total to date 2,108
Welcome to our new Forum!

Our aim is to save you money quickly and easily. We hope you like it!

Forum Team Contact us

Live Stats

3,001Posts Today

8,596Users online

Martin's Twitter