Automatically playing mp4 uploaded file

Instead of just having the video link handled by Discourse when it bakes the post, you can insert the video HTML element and add the autoplay attribute:

<video width="100%" height="100%" preload="metadata" controls="" autoplay>
      <source src="https://www.simscale.com/forum/uploads/default/original/3X/d/6/d6fab77fb56eeb98ef660d682f344dba4bbb66ce.mp4">
      <a href="https://www.simscale.com/forum/uploads/default/original/3X/d/6/d6fab77fb56eeb98ef660d682f344dba4bbb66ce.mp4">/forum/uploads/default/original/3X/d/6/d6fab77fb56eeb98ef660d682f344dba4bbb66ce.mp4</a>
</video>

Since the video has no sound, it will autoplay. If it had sound, you would have to add the muted attribute as well.

More info:

You can see what HTML tags are allowed in posts here: https://github.com/discourse/discourse/blob/main/app/assets/javascripts/pretty-text/addon/allow-lister.js#L115

4 Likes