mirror of
https://github.com/ThatGuySam/doesitarm.git
synced 2026-05-18 06:44:46 -07:00
Trigger autoplay when allowed
This commit is contained in:
parent
bc7a5de462
commit
f7af4fb950
1 changed files with 10 additions and 5 deletions
|
|
@ -220,7 +220,13 @@ export default {
|
||||||
// this.frameId = `youtube-bg-${this._uid}`
|
// this.frameId = `youtube-bg-${this._uid}`
|
||||||
|
|
||||||
this.detectAutoplay()
|
this.detectAutoplay()
|
||||||
.then( statuses => console.log(statuses) )
|
.then( ({ willAutoplay }) => {
|
||||||
|
// If we're allowed to autoplay
|
||||||
|
// then start loading the player
|
||||||
|
if ( willAutoplay === true ) {
|
||||||
|
this.startPlayerLoad()
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
scrollRow ( timestamp ) {
|
scrollRow ( timestamp ) {
|
||||||
|
|
@ -240,16 +246,15 @@ export default {
|
||||||
|
|
||||||
async detectAutoplay () {
|
async detectAutoplay () {
|
||||||
|
|
||||||
if ( !process.client ) return false
|
if ( !process.client ) return { willAutoplay: false }
|
||||||
|
|
||||||
const { default: canAutoPlay } = await import('can-autoplay')
|
const { default: canAutoPlay } = await import('can-autoplay')
|
||||||
|
|
||||||
const willAutoplay = await canAutoPlay.video()
|
const willAutoplay = await canAutoPlay.video()
|
||||||
const willAutoplayMuted = await canAutoPlay.video({ muted: true, inline: true })
|
// const willAutoplayMuted = await canAutoPlay.video({ muted: true, inline: true })
|
||||||
|
|
||||||
return {
|
return {
|
||||||
willAutoplay,
|
willAutoplay: willAutoplay.result
|
||||||
willAutoplayMuted
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue