stamat / youtube-background

ESM / jQuery plugin for creating video backgrounds from YouTube, Vimeo or video file links.
https://stamat.github.io/youtube-background/
MIT License
173 stars 54 forks source link

Not work with othes libs. #24

Closed semenov-anton-a closed 2 years ago

semenov-anton-a commented 3 years ago

Exemple. glightbox https://github.com/biati-digital/glightbox

glightbox not open video then "jquery.youtube-background" plugin work. How can stop or pause jquery.youtube-background?

stamat commented 2 years ago

@semenov-anton-a hey man sorry for an extremely late reply... I hope you solved the issue by yourself, but I'll respond just for the sake of documentation.

It is possible what you are asking for, of course, but keep in mind that this script is only for the backgrounds.

I would suggest that you just add youtube embeds to the slides of your lightbox, and to tune to the events https://github.com/biati-digital/glightbox#events.

On each slide you would check if it contains the youtube iframe, and if it does you would play it via the youtube iframe api. When the slide changes to another slide you would stop all other youtube iframes.

To achieve the same effect with this script, you would need to use the new VideoBackground('[data-youtube]') to initialize the videos once the lightbox initializes. This constructor will return an object where you can access all the videos in the object's index property and you can do a .play() or .pause() depending on which video is shown in a slide. You can get the video by it's unique index - from the index object, which is also an ID of the iframe wrapper.

See you around buddy!