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
- As soon as that element is found, the plugin will stop observing
- Within the
#post_1node, 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.