Automatically pause media when content tabs are hidden

This commit is contained in:
squidfunk 2023-05-12 15:12:40 +02:00
parent 3520926284
commit 01136b2fb9
No known key found for this signature in database
GPG Key ID: 5ED40BC4F9C436DF
4 changed files with 15 additions and 8 deletions

View File

@ -240,7 +240,7 @@
</script>
{% endblock %}
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.fac441b0.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.c2be25ad.min.js' | url }}"></script>
{% for path in config.extra_javascript %}
<script src="{{ path | url }}"></script>
{% endfor %}

View File

@ -244,6 +244,13 @@ export function mountContentTabs(
}
})
/* Pause media (audio, video) on switch - see https://bit.ly/3Bk6cel */
push$.pipe(takeUntil(done$))
.subscribe(() => {
for (const media of getElements<HTMLAudioElement>("audio, video", el))
media.pause()
})
/* Create and return component */
return watchContentTabs(el)
.pipe(