Automatically play and loop video on upload

Hello :wave:

I am thinking of two ways how it’s going to be possible.

The first one is the easiest one, simply creating a little theme component which using the plugin api api.decorateCookedElement to find all videos in posts and add these attributes. (autoplay, loop etc.)

It will modify all of the videos HTML in posts on the whole site. In the composer still the markdown video code appears you mentioned above.
![happy-birthday|video](upload://abcdefg123456789.mp4)

Pros: affected all video on the site (so the previous uploads too)
Cons: users can’t control it because it is happening on the published posts. It affects all video so if you have a topic with lots of video and these want to start at same time it can make issues.


The second option is a little more work. It is a modal where users can control which attributes will be added to the uploadid video. It can be trigger with adding a specific button to composer or makes it to trigger automatically when it detects a video upload.

When it’s done it insert the video HTML in composer which contains the added attributes.

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

A great example for this the Insert Video theme component.

Pros: users can control their videos attributes and they can choose to disable autoplay etc. so video heavy topics tol will be ok.
Cons: it won’t affect the older videos. But it’s not a big cons because this whole second process is about how users can control their videos.


Plus

The first method can be combine with a user setting or a group. With this users can set up the videos behavior.
For example: Enable autoplay videos or join a group which will activate videos autoplay etc…


Edit: I just thinking of I forgot lazy load, probable the first process is not working now because lazy load is only load the video if user click the thumbnail play button. I didn’t try it yet… :thinking:

2 Likes