Enable detecting autoplay status

This commit is contained in:
Sam Carlton 2021-04-27 16:52:22 -05:00
parent df6f0487bf
commit 8358e21f2d

View file

@ -219,9 +219,8 @@ export default {
// Set frame ID here so that it's the same when Youtube API looks for it // Set frame ID here so that it's the same when Youtube API looks for it
// this.frameId = `youtube-bg-${this._uid}` // this.frameId = `youtube-bg-${this._uid}`
// this.initializeLitePlayer() this.detectAutoplay()
.then( statuses => console.log(statuses) )
// this.initializePlayer()
}, },
methods: { methods: {
scrollRow ( timestamp ) { scrollRow ( timestamp ) {
@ -239,6 +238,21 @@ export default {
timestampsScroller.scroll({ left: newScrollPosition, behavior: 'smooth' }) timestampsScroller.scroll({ left: newScrollPosition, behavior: 'smooth' })
}, },
async detectAutoplay () {
if ( !process.client ) return false
const { default: canAutoPlay } = await import('can-autoplay')
const willAutoplay = await canAutoPlay.video()
const willAutoplayMuted = await canAutoPlay.video({ muted: true, inline: true })
return {
willAutoplay,
willAutoplayMuted
}
},
async seekTo (timestampInSeconds) { async seekTo (timestampInSeconds) {
if (this.playerLoaded === false) { if (this.playerLoaded === false) {