Media Autoplay

Hello everyone,

I was learning to develop plugins when I came across this topic and decided to make a plugin for it.

Here are what the discourse-plugin-autoplay (GitHub Repo) plugin is going to do:

  • Once a topic is loaded, the plugin will observe any changes made to the document object for the #post_1 element.
  • As soon as that element is found, the plugin will stop observing document.
  • Within the #post_1 node, if Youtube links are found, the first one will be played; if not, then the first audio tag (if available) will be played instead.

I would appreciate all feedback and suggestions. My way of accomplishing this wasn’t very clean. Better ways to listen to posts being loaded and to control the media would be great to know.

If this could be useful to you, please try it out and tell me what’s wrong and what can be improved.

Thanks.

7 Likes

Thx @dtchau. Sounds interesting.

Just to clarify the use case for our community, users want autoplay because they want the music (audio) of the first media element to continue play regardless of what message on the topic they are currently listening to.

Also important is that users will be able to control this setting in their options.

Do you have it on a test community by any chance?

users want autoplay because they want the music (audio) of the first media element to continue play regardless of what message on the topic they are currently listening to.

Hmm. Not how it is working at the moment, but I just got an idea. I will update when I have more details.

Also important is that users will be able to control this setting in their options.

I will make this happen.

Do you have it on a test community by any chance?

Unfortunately, I have nothing publicly available atm. I am open to hosting suggestions.

BTW, this is a proof of concept. Give it a try and share your thoughts. Together, we might be able to turn it into something useful.

2 Likes

Hi @dtchau @Falco. Our users have enjoyed this feature over the past few years, but it appears to have broken recently.

Would either of you be willing to take a look perhaps?

Here’s an example page on our community with autoplay. Note that it is a user option to activate it.
https://www.helloforos.com/t/francisco-adonde-voy-sin-ti/404467

Thx!

1 Like

Probably broke due to changes in how Chrome handles auto play:

2 Likes

You are correct, @falco diagnosed it and this is a new feature in Chrome. Unless you’ve interacted (activated) a bunch of videos on the site, Chrome disables autoplay on that site. It’s a good feature but hard to explain to users, which makes it kinda dangerous in my experience.

2 Likes

I think it would be a better feature if they handled it like they do with browser notifications. Whenever the browser comes to a site that is trying to autoplay something, it should have a pop-up that says something like:

This website is trying to autoplay a video, would you like to enable or disable autoplay for this domain?

1 Like