M
M
Misha_mishy12020-02-14 11:30:31
YouTube
Misha_mishy1, 2020-02-14 11:30:31

Why does the video work after closing?

Good afternoon!
Please tell me what can be done with this problem: there is a block with a video on the site, I upload the video through lazyYT and open it in popup. I click on the play, everything turns on, everything is fine, but when I close it by clicking on the cross, it starts to turn on from the very beginning.
https://ugryumovmm.ru/vac/ - link to the site
Thank you in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Talalaev, 2020-02-14
@Misha_mishy1

I didn’t go straight into your code on the site, it’s inconvenient.
But the problem is not with the plugin. The plugin does only two things: it puts the video preview as a regular picture, on click the iframe of the entire youtube player is dynamically loaded. Everything.
Your task is to implement new functions for closing the model window.
Algorithm:
1. Track the window closing event.
2. When the event fired, you either pause the player via youtube js api (I don’t know how possible this is in your version) or completely delete the entire player yourself and restore the default view, then how the html code should look like from the very beginning of the div tag with parameters, but here the question is how dynamically the library tracks, so it will probably be easier to demolish everything from there. And initialize the div and the lazyYT library dynamically every time the modal is opened.
In general, of course, everything is clumsy by modern standards.
In general, I advise you to use then it’s better to use plyr instead of the outdated lazyYT , it at least has api for convenient player control.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question