biati-digital / glightbox

Pure Javascript lightbox with mobile support. It can handle images, videos with autoplay, inline content and iframes
MIT License
2.03k stars 228 forks source link

Doesnt seem to work with youtube playlist. #415

Closed Lefthandmedia closed 9 months ago

Lefthandmedia commented 1 year ago

Im trying to use a youtube playlist link in GL. This playlistlink (https://www.youtube.com/embed/videoseries?list=PLM-mb7IpX4mryWYYoyl2HHboOUQHHC5hI&autoplay=1) works fine in a browser but not in the lightbox

Are you able to reproduce the bug in the demo site Yes see here: https://codepen.io/Lefthandmedia/pen/vYzMZQd

Expected behavior I expect the playlist to work in the Lightbox overlay

Post the code you are using There is no specific code. see the codepen

Desktop: All

Smartphone: All

Lefthandmedia commented 1 year ago

the only solution i see now is to not use PLYR for playlists and just use the embed code for embedding an Iframe when using a playlist.

gingerchew commented 1 year ago

Hey there @Lefthandmedia,

I think it is just a matter of updating the regex that determines the provider.

if (
  !provider &&
  (url.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/) || url.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/) || url.match(/(youtube\.com|youtube-nocookie\.com)\/embed\/([a-zA-Z0-9\-_]+)/))
  ) {
    provider = 'youtube';
}

Unless it's something that plyr is not able to do, in which case you would need to reach out to them about updating how they handle YouTube playlists.

Lefthandmedia commented 1 year ago

Hi Ginger, Thanks for the reply, i think it is something that PLYR is unable to do. However that shouldn't be a reason for GL to fail on this, when it is possible to embed the standaard YouTube embed for playlists instead of using PLYR. The only way i see now for GL to be able to service youtube playlists is not using PLYR for playlists. The regex you mention is only to determine the video provider, nothing wrong there as far as i can see.

Lefthandmedia

gingerchew commented 1 year ago

You're right on the RegEx. But I think I found the issue:

The url you're giving as a video is: https://www.youtube.com/embed/videoseries?list=PLM-mb7IpX4mryWYYoyl2HHboOUQHHC5hI&autoplay=1

But when you open the lightbox, the url that is used is: https://www.youtube-nocookie.com/embed/videoseries?autoplay=0&controls=0&disablekb=1&playsinline=0&cc_load_policy=0&cc_lang_pref=auto&widget_referrer=https%3A%2F%2Fcodepen.io%2F&rel=0&showinfo=0&iv_load_policy=3&modestbranding=1&customControls=true&noCookie=true&enablejsapi=1&origin=https%3A%2F%2Fcdpn.io&widgetid=2

So what is missing? The ?list= param. (Similar to #396)

Seems like Plyr is consuming the param and not using it, you might be able to pass in the parameter using the settings.plyr.config.youtube option, but if not that is a weird Plyr quirk.

stale[bot] commented 11 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.