You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to add autoplay functionality to videos a Webflow site. The videos should play when in view, pause when out of view.
I have all the intersection observer functionality working, but I can't seem to play the videos using playerjs. Whenever I call play(), the pause event is fired. Could this have to do with the Vimeo sources themselves?
/* utility function to fetch embed URL to uniquely identify players */constgetEmbed=(target)=>target.querySelector('iframe.embedly-embed');constgetEmbedSrc=(target)=>getEmbed(target).src;$(document).ready(function(){console.log('video-autoplay.js');constplayers={};constoptions={root: null,};constautoplayObserver=newIntersectionObserver((entries)=>{entries.forEach((entry)=>{constid=getEmbedSrc(entry.target);console.log(id);constplayer=players[id];player.on('ready',()=>{if(entry.isIntersecting){console.log(`intersecting: ${entry.target.id}`);player.play();}else{console.log(`not intersecting: ${entry.target.id}`);player.pause();}});});},options);constautoplayTargets=document.querySelectorAll('[data-autoplay=true]');autoplayTargets.forEach((target)=>{constid=getEmbedSrc(target);constplayer=newplayerjs.Player(getEmbed(target));player.on('play',()=>{console.log(`playing: ${id}`);});player.on('pause',()=>{console.log(`paused: ${id}`);});players[id]=player;autoplayObserver.observe(target);});console.log('players');console.log(players);globalThis.players=players;});
Crossing my fingers this repo is still maintained 🤞 @screeley
CleanShot.2022-04-13.at.12.26.52.mp4
Trying to add autoplay functionality to videos a Webflow site. The videos should play when in view, pause when out of view.
I have all the intersection observer functionality working, but I can't seem to play the videos using playerjs. Whenever I call
play(), thepauseevent is fired. Could this have to do with the Vimeo sources themselves?Crossing my fingers this repo is still maintained 🤞 @screeley