Skip to content

Commit 9b1f4ef

Browse files
committed
Fixed videos with autoplay not playing in content tabs
1 parent 1f7c404 commit 9b1f4ef

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

material/templates/assets/javascripts/bundle.94882406.min.js renamed to material/templates/assets/javascripts/bundle.05bf7199.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/templates/assets/javascripts/bundle.94882406.min.js.map renamed to material/templates/assets/javascripts/bundle.05bf7199.min.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/templates/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@
245245
</script>
246246
{% endblock %}
247247
{% block scripts %}
248-
<script src="{{ 'assets/javascripts/bundle.94882406.min.js' | url }}"></script>
248+
<script src="{{ 'assets/javascripts/bundle.05bf7199.min.js' | url }}"></script>
249249
{% for script in config.extra_javascript %}
250250
{{ script | script_tag }}
251251
{% endfor %}

src/templates/assets/javascripts/components/content/tabs/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,15 @@ export function mountContentTabs(
280280
/* Pause media (audio, video) on switch - see https://bit.ly/3Bk6cel */
281281
push$.pipe(takeUntil(done$))
282282
.subscribe(() => {
283-
for (const media of getElements<HTMLAudioElement>("audio, video", el))
284-
media.pause()
283+
// If the video or audio is visible, and has autoplay enabled, it will
284+
// continue playing. If it's not visible, it is paused in any case
285+
for (const media of getElements<HTMLAudioElement>("audio, video", el)) {
286+
if (media.offsetWidth && media.autoplay) {
287+
media.play()
288+
} else {
289+
media.pause()
290+
}
291+
}
285292
})
286293

287294
/* Create and return component */

0 commit comments

Comments
 (0)