We're aware that some users are experiencing technical issues which the team are working to resolve. See the Community Noticeboard for more info. Thank you for your patience.
📨 Have you signed up to the Forum's new Email Digest yet? Get a selection of trending threads sent straight to your inbox daily, weekly or monthly!

MP4 Video not playing in Chrome

Options
scaredofdebt
scaredofdebt Posts: 1,663 Forumite
Part of the Furniture 1,000 Posts Combo Breaker
edited 11 September 2018 at 3:24PM in Techie Stuff
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.
Make £2018 in 2018 Challenge - Total to date £2,108

Comments

  • AndyPix
    AndyPix Posts: 4,847 Forumite
    Fifth Anniversary 1,000 Posts Name Dropper Photogenic
    You can post links - lets have a look
  • 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
    AndyPix Posts: 4,847 Forumite
    Fifth Anniversary 1,000 Posts Name Dropper Photogenic
    edited 11 September 2018 at 4:28PM
    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 ..


    Capture.jpg


    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 !!)
  • 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
    AndyPix Posts: 4,847 Forumite
    Fifth Anniversary 1,000 Posts Name Dropper Photogenic
    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
  • 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
  • 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
    AndyPix Posts: 4,847 Forumite
    Fifth Anniversary 1,000 Posts Name Dropper Photogenic
    edited 13 September 2018 at 3:21PM
    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.


    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 ;) )
  • AndyPix
    AndyPix Posts: 4,847 Forumite
    Fifth Anniversary 1,000 Posts Name Dropper Photogenic
    Oh, and you also want ..


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


    So the controls dont appear when you hovver the mouse over the video
  • Thanks, yes Javascript isn't my strong point!
    Make £2018 in 2018 Challenge - Total to date £2,108
This discussion has been closed.
Meet your Ambassadors

🚀 Getting Started

Hi new member!

Our Getting Started Guide will help you get the most out of the Forum

Categories

  • All Categories
  • 350.9K Banking & Borrowing
  • 253.1K Reduce Debt & Boost Income
  • 453.5K Spending & Discounts
  • 243.9K Work, Benefits & Business
  • 598.7K Mortgages, Homes & Bills
  • 176.9K Life & Family
  • 257.1K Travel & Transport
  • 1.5M Hobbies & Leisure
  • 16.1K Discuss & Feedback
  • 37.6K Read-Only Boards

Is this how you want to be seen?

We see you are using a default avatar. It takes only a few seconds to pick a picture.