Add media preload logging

This commit is contained in:
Max Goodhart
2020-11-12 00:06:27 -08:00
parent 9ba7dc564b
commit 356d84dfc6

View File

@@ -118,10 +118,12 @@ async function lockdownMediaTags() {
} }
function waitForQuery(query) { function waitForQuery(query) {
console.log(`waiting for '${query}'...`)
return new Promise(async (resolve) => { return new Promise(async (resolve) => {
const scan = throttle(() => { const scan = throttle(() => {
const el = document.querySelector(query) const el = document.querySelector(query)
if (el) { if (el) {
console.log(`found '${query}'`)
resolve(el) resolve(el)
observer.disconnect() observer.disconnect()
} }
@@ -228,10 +230,12 @@ async function findVideo(kind) {
video.play() video.play()
if (!video.videoWidth) { if (!video.videoWidth) {
console.log(`video isn't playing yet. waiting for it to start...`)
const videoReady = new Promise((resolve) => const videoReady = new Promise((resolve) =>
video.addEventListener('playing', resolve, { once: true }), video.addEventListener('playing', resolve, { once: true }),
) )
await videoReady await videoReady
console.log('video started')
} }
const info = { const info = {