# Media Autoplay

**URL:** <https://meta.discourse.org/t/media-autoplay/40595>\
**Category:** Plugin\
**Created:** [3월 4, 2016, 9:34오후 UTC](https://meta.discourse.org/t/media-autoplay/40595 "2016-03-04T21:34:38Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![dtchau](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dtchau/32/121852_2.png) [@dtchau](https://meta.discourse.org/u/dtchau)\
**Post date:** [3월 4, 2016, 9:34오후 UTC](https://meta.discourse.org/t/media-autoplay/40595/1 "2016-03-04T21:34:38Z")

</div>

Hello everyone,

I was learning to develop plugins when I came across [this topic](https://meta.discourse.org/t/autoplay-youtube-videos-opt-in/40370) and decided to make a plugin for it.

Here are what the [discourse-plugin-autoplay (GitHub Repo)](https://github.com/dtchau/discourse-plugin-autoplay) 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.

---

_[View the full topic](https://meta.discourse.org/t/media-autoplay/40595)._
