# Automatically playing mp4 uploaded file

**URL:** https://meta.discourse.org/t/automatically-playing-mp4-uploaded-file/281040
**Category:** Support
**Created:** [October 4, 2023, 1:46pm UTC](https://meta.discourse.org/t/automatically-playing-mp4-uploaded-file/281040 "2023-10-04T13:46:20Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Vinicius\_Goncalves](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinicius_goncalves/32/322206_2.png) [@Vinicius\_Goncalves](https://meta.discourse.org/u/Vinicius_Goncalves)
#### Post date: [October 4, 2023, 1:46pm UTC](https://meta.discourse.org/t/automatically-playing-mp4-uploaded-file/281040/1 "2023-10-04T13:46:21Z")

</div>

Hi team,

Is it possible to put [this forum page](https://www.simscale.com/forum/t/early-access-to-electromagnetic-simulation/97473) automatically playing that video whenever anyone just open the page?

Thanks in advance.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [October 4, 2023, 3:45pm UTC](https://meta.discourse.org/t/automatically-playing-mp4-uploaded-file/281040/3 "2023-10-04T15:45:34Z")

</div>

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:

```html
<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>

```

[/forum/uploads/default/original/3X/d/6/d6fab77fb56eeb98ef660d682f344dba4bbb66ce.mp4](https://www.simscale.com/forum/uploads/default/original/3X/d/6/d6fab77fb56eeb98ef660d682f344dba4bbb66ce.mp4)

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:

> **[Autoplay guide for media and Web Audio APIs - Media | MDN](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Autoplay)**
>
> Automatically starting the playback of audio (or videos with audio tracks) immediately upon page load can be an unwelcome surprise to users. While autoplay of media serves a useful purpose, it should be used carefully and only when needed. In order...

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](https://github.com/discourse/discourse/blob/main/app/assets/javascripts/pretty-text/addon/allow-lister.js#L115)

---

<div class="post-metadata">

### Author: ![Vinicius\_Goncalves](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinicius_goncalves/32/322206_2.png) [@Vinicius\_Goncalves](https://meta.discourse.org/u/Vinicius_Goncalves)
#### Post date: [October 4, 2023, 3:51pm UTC](https://meta.discourse.org/t/automatically-playing-mp4-uploaded-file/281040/4 "2023-10-04T15:51:50Z")

</div>

Hi @Canapin,

That’s really helpful, and I feel really appreciated for your answer.  
BTW, is there any HTML attribute to insert _ **loop** _ for such video? Or you think by inserting this autoplay HTML string it will be automatically in loop?

Thanks once again,

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [October 4, 2023, 3:54pm UTC](https://meta.discourse.org/t/automatically-playing-mp4-uploaded-file/281040/5 "2023-10-04T15:54:23Z")

</div>

You can add the `loop` attribute 🙂

[/forum/uploads/default/original/3X/d/6/d6fab77fb56eeb98ef660d682f344dba4bbb66ce.mp4](https://www.simscale.com/forum/uploads/default/original/3X/d/6/d6fab77fb56eeb98ef660d682f344dba4bbb66ce.mp4)

---

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [October 5, 2023, 3:28am UTC](https://meta.discourse.org/t/automatically-playing-mp4-uploaded-file/281040/6 "2023-10-05T03:28:12Z")

</div>

Nice @Canapin 🙂 I think it would be a great addition to [Insert Video](https://meta.discourse.org/t/insert-video/147651) theme component as it has other option like `nodownload` too. It can probably appear on modal to each video upload. 🤔

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [November 4, 2023, 3:29am UTC](https://meta.discourse.org/t/automatically-playing-mp4-uploaded-file/281040/7 "2023-11-04T03:29:02Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
