Merge pull request #16805 from overleaf/tm-website-redesign-ios-video-tweaks

Website redesign - video autoplay tweaks primarily to fix playback on iOS

GitOrigin-RevId: ba2844b8af64627512470d0f27ec450ee2d86b09
This commit is contained in:
M Fahru 2024-01-30 08:41:56 -07:00 committed by Copybot
parent 7f9d105d8c
commit 93976a2748
6 changed files with 2 additions and 9 deletions

View file

@ -19,7 +19,6 @@ function setup(videoEl) {
const INTERSECTION_THRESHOLD = 0.7
let videoIsVisible
let canPlayListenerAdded
videoEl.addEventListener('ended', () => {
setTimeout(() => {
@ -36,17 +35,11 @@ function setup(videoEl) {
if (change.isIntersecting) {
videoIsVisible = true
if (videoEl.readyState >= videoEl.HAVE_FUTURE_DATA) {
if (videoEl.paused && !videoEl.ended) {
if (!videoEl.ended) {
videoEl.play()
}
} else {
if (!canPlayListenerAdded) {
canPlayListenerAdded = true
videoEl.addEventListener('canplay', function playWhenReady() {
videoEl.play()
videoEl.removeEventListener('canplay', playWhenReady)
})
}
videoEl.play()
}
} else {
videoIsVisible = false

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 245 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB