ethankr
ethankr

Reputation: 157

Autoplaying video without sound

I just finished reading this article on why autoplaying video is bad http://www.punkchip.com/autoplay-is-bad-for-all-users/. I knew autoplaying was a bad practice but this video gave me good, tangible reasons why its not a best practice.

My question, sites like YouTube, KickStarter and ProductHunt DO have autoplaying video, the catch is the audio is muted.

I'm working on a site for a client now, more specifically a page in which the client might request the video be autoplayed. Obviously this behavior would not be acceptable on with sound, but how about if I muted the sound by default and provided a volume button like ProductHunt?

And just replaced the video with a poster image on mobile? Thoughts?

Thanks.

Upvotes: 12

Views: 37668

Answers (1)

l33tstealth
l33tstealth

Reputation: 899

If you will be using the HTML5 player native to the browser. HTML5 video does provide the ability to mute a video and autoplay it. You simply have to include the 'muted' and 'autoplay' properties in your video tags in addition to the 'controls' property so that users have the ability to play,pause, unmute etc, as an example, the code would look like this:

<html>
<body>

<video width="320" height="240" autoplay controls muted>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  Your browser does not support the video tag.
</video>

<p><strong>Note:</strong> The muted attribute of the video tag is not supported in Internet Explorer 9 and earlier versions.</p>

</body>
</html>

Upvotes: 26

Related Questions