I am a beginner in web development, i want put a youtube iframe with autoplay, but just for the first visit, using something cookie or variable for control it.
When i visit the site for the second time, the video wont autoplay.
Is it posible?
I am a beginner in web development, i want put a youtube iframe with autoplay, but just for the first visit, using something cookie or variable for control it.
When i visit the site for the second time, the video wont autoplay.
Is it posible?
Logic should be easy. When a user visits the website, check the user has the cookie. If not, assign him the cookie. If yes, do nothing.
And on adding parameters to Youtube Iframe, you should check the cookie is set or not and depending on that add the autoplay
parameter.
The below links will help and have the complete solution you are looking for. I am not reinventing the solution since they are already been posted.
Youtube Documentation:
For Setting and Retrieving Cookie with Vanilla JavaScript: