Last active
March 21, 2021 05:09
-
-
Save troy-lamerton/252f441bbc273f4676be789bdb1b8a76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function preloadVideo(video) { | |
// just before video would play, pause it | |
video.addEventListener('canplay', preloadingVideoCanPlay, {once: true}); | |
// begin preloading the playlist and first hls segment (useful for VODs) | |
video.play(); | |
} | |
function preloadingVideoCanPlay() { | |
// video has buffered enough for playback | |
video.pause(); | |
} | |
function playVideo(video) { | |
video.removeEventListener('canplay', preloadingVideoCanPlay); | |
video.play(); | |
} | |
// 1. preloadVideo(video) | |
// ... some time later ... | |
// 2. playVideo(video) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function preloadVideo(video) { | |
video.muted = true; | |
// just before video would play, pause it | |
video.addEventListener('canplay', preloadingVideoCanPlay, {once: true}); | |
// begin preloading the playlist and first hls segment (useful for VODs) | |
video.play(); | |
} | |
function preloadingVideoCanPlay() { | |
// video has buffered enough for playback | |
video.pause(); | |
} | |
function playVideo(video) { | |
video.removeEventListener('canplay', preloadingVideoCanPlay); | |
video.play(); | |
} | |
// 1. preloadVideo(video) | |
// ... some time later ... | |
// 2. *tap to enter community* -> playVideo(video) | |
// 3. on entered community (web view will appear now) -> video.muted = false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment