in Technology

Autoplay Video in HTML5

I’ve been playing around with SublimeVideo; it’s being used on the Launch Page of Levoma. As the video had to be part of the page, I was hoping I can do an autoplay in the HTML and it automatically play on its own. However, SublimeVideo won’t allow that.

The Video Embed code for HTML5 states that you can have an autoplay so the video can be played without needing user intervention.

<video src="myvideo.ogg" width="320" height="240" autoplay></video>

That didn’t play well with Sublime Video code. SublimeVideo’s API (still in beta) suggest using sublimevideo.prepareAndPlay(video) but they didn’t have a code handy to use. So, here is the simple code to do it.

Here is a working example.

(Video Source: Bruce Lee: The Lost Interview (1971))

P.S. However, on a philosophical note and best practice, I’d not throw a video to a user that auto-play on its own. The Video on Levoma was part of the landing-page experience and there was no audio.