Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML HTML Video and Audio Media Basics The Video Element

autoplay not working

<video src="http://treehouse-code-samples.s3.amazonaws.com/html-video-and-audio/bridge.mp4" type="video/mp4"/>

The autoplay is not working upon page load

Thomas Macdonald
Thomas Macdonald
6,755 Points

For Chrome 70.0 and up (and maybe some other browsers)

autoplay doesn't work if no muted attribute is present

according to MDN.

I added muted as a boolean attribute (no value attached, like when adding controls or autoplay) and it now works.

<video src="http://treehouse-code-samples.s3.amazonaws.com/html-video-and-audio/bridge.mp4" type="video/mp4" autoplay muted />

1 Answer

Alexandra Hadjidaki
Alexandra Hadjidaki
26,471 Points

If you want your video to autoplay on page load, you need to let it know you want to do that

Add the autoplay attribute to your video tag like so:

<video src="http://treehouse-code-samples.s3.amazonaws.com/html-video-and-audio/bridge.mp4" type="video/mp4" autoplay/>


A better way to add video to your HTML would be the following, in case the browser doesn't support the video embed element:

<video autoplay>
    <source src="http://treehouse-code-samples.s3.amazonaws.com/html-video-and-audio/bridge.mp4" 
    <!-- You can add more source types here -->
    Sorry, your browser doesn't support embedded videos.

MDN Documentation for <video> element