Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've been using video embed field for months now, awesome, awesome module!!!
It would be awesome if it would support youtube playlists. They are in the format: http://www.youtube.com/playlist?list=PLAFAD1CE9CCB21F73
When I embed that link it will show the youtube player window but with an "an error occurred" message.
The iframe code is:
<iframe style="width:640px; height:360px;" src="http://www.youtube.com/embed/playlist?width=640&height=360&autoplay=0&hd=1&rel=0&autohide=2&showinfo=1&theme=dark&wmode=opaque" frameborder="0" allowfullscreen=""></iframe>
but according to the youtube embed code it should be:
<iframe width="560" height="315" src="http://www.youtube.com/embed/videoseries?list=PLAFAD1CE9CCB21F73&hl=en_US" frameborder="0" allowfullscreen></iframe>
When I copy that embed code into the window it plays just fine.
Also, the video thumbnail doesn't show if you enter a playlist URL.
Thanks
UWE
Comment | File | Size | Author |
---|---|---|---|
#8 | playlist-support-1520100-8.patch | 3.1 KB | wbobeirne |
#3 | playlist-support-1520100-3.patch | 1.51 KB | wbobeirne |
#1 | playlist-support-1520100-1.patch | 1.65 KB | wbobeirne |
Comments
Comment #1
wbobeirne CreditAttribution: wbobeirne commentedGood request, just needed an extra if to check for playlists. The only odd thing is that playlists need an extra ampersand on the end to take options, i.e. /embed/playlist?list=%id%&?width=640, as opposed to single videos which just do /embed/%id%?width=640
Attached is a patch that adds the support. I didn't do any heavy testing though, only your supplied playlist.
Comment #2
wbobeirne CreditAttribution: wbobeirne commentedIt's just occurred to me that that patch does nothing for thumbnails on playlists. I'll work on that shortly. I guess I'll just grab the thumb of the first video, or something.
Comment #3
wbobeirne CreditAttribution: wbobeirne commentedI'm really striking out today. Patch in #1 includes a left-over dpm statement. Apologies! Attached is one that removes it.
Comment #4
mototribe CreditAttribution: mototribe commentedcool, thanks for the quick fixes. Yes, the thumbnail of the first video would be perfect.
Now, how would you retrieve an image from a playlist id?
When I view a playlist from my account it shows this url for sharing: http://www.youtube.com/playlist?list=PLE5959DFE442479A7
When I click "play all" and then copy the URL I get this:
http://www.youtube.com/watch?v=lb7vHYrTzDo&feature=share&list=PLE5959DFE...
If I click the "share" below the video I get:
http://www.youtube.com/watch?v=lb7vHYrTzDo&list=PLE5959DFE442479A7&featu...
Maybe it's easier to work with those playlist URLs?
thanks again
UWE
Comment #5
jec006 CreditAttribution: jec006 commentedhttps://developers.google.com/youtube/2.0/reference#Playlist_feed
might be some data here or in the various docs for the youtube api about how to retrieve that info.
Comment #6
jec006 CreditAttribution: jec006 commentedSo it basically look like the format is something like this:
A playlist has a url like this:
http://www.youtube.com/playlist?list=PLE5959DFE442479A7
The playlist's id is then the list id minus PL so : E5959DFE442479A7
The playlists info is stored (as xml) at : https://gdata.youtube.com/feeds/api/playlists/E5959DFE442479A7?v=2
and in the xml we have:
which tells us that we have 2 thumbnails - the bigger of which is http://i.ytimg.com/vi/lb7vHYrTzDo/hqdefault.jpg
So ... should be a similar processor to how we get the regular thumbnail, just some additional api work in the thumbnail section.
Comment #7
jec006 CreditAttribution: jec006 commentedSidenote - this is also a valid link to the aforementioned playlist, which the current patch doesn't deal with:
https://www.youtube.com/view_play_list?p=E5959DFE442479A7
Comment #8
wbobeirne CreditAttribution: wbobeirne commentedAlright guys, I think I've covered all the bases. view_play_list links now work (Oddly enough, the ID in them is different. It lacks the 'PL' suffix that playlists have) and playlists are generating thumbnails now. If there's any other cases you can think of that this patch doesn't handle, let me know.
Comment #9
mototribe CreditAttribution: mototribe commentedthat is freaking awesome!!!
Thanks so much. Both versions of the URL worked:
https://www.youtube.com/view_play_list?p=E5959DFE442479A7
http://www.youtube.com/playlist?list=PLE5959DFE442479A7
The URLs that are generated from a video within a playlist don't work (they only show the video, not the playlist):
http://www.youtube.com/watch?v=lb7vHYrTzDo&feature=share&list=PLE5959DFE...
http://www.youtube.com/watch?v=lb7vHYrTzDo&list=PLE5959DFE442479A7&featu...
I don't think that's critical, more like a "nice to have".
Thanks again for the quick turnaround and the great work!!!
Members are loving the module on my site, both for youtube and vimeo videos.
http://cruiser.mototribe.com/videos
Cheers
UWE
Comment #10
jec006 CreditAttribution: jec006 commentedFinally committed this, thanks all.
http://drupalcode.org/project/video_embed_field.git/commit/125710b
Comment #11.0
(not verified) CreditAttribution: commentedfixed ending tag
Comment #12
handkerchiefNow the drupal 8 version doesn't support youtube playlists.
i made a quick and dirty workaround in the two functions below:
video_embed_field/src/Plugin/video_embed_field/Provider/YouTube.php
Note: Again, this is a quick and dirty solution, i'm sure the module contributers can integrate a better code solution in the module.
I hope this feature will be added soon.
Comment #13
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedThanks for the feature request and reference implementation. I've opened #2688449: Support playlists in YouTube provider to deal with this. If you would like to create a patch, I can provide feedback on the code.
Comment #14
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedPlaylists added to 8.x, see above issue.
Comment #15
handkerchiefOh that's great thank you. I have tested it but it is not working.
I also clear all caches but the paylist will not show up, only the first video of the playlist.
Comment #16
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedThe embedded playlists look a lot like normal videos, but they have a tab that slide in from the right. Do you want to log any further support questions in the issue above?
Comment #17
handkerchiefI know this, because with my temporary and dirty code the playlist has worked. But now i see only the first video without a playlist tab, like before my first comment.
Ok i found the reason:
The URL should look like this:
https://www.youtube.com/watch?v=lYFSqKXAfHM&list=PLhIv90n3FQfZPYQ-zJM5DbLl7msn-g8Em
But i insert this kind of URL:
https://www.youtube.com/watch?list=PLhIv90n3FQfZPYQ-zJM5DbLl7msn-g8Em&v=lYFSqKXAfHM
It's the same playlist and on youtube works both. But only the structure of the first URL works with the module. Maybe you can implement this other structure or you can document this somewhere. In any case thank you again.
Comment #18
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedAh, interesting. I'll implement both order of parameters.
Comment #19
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedImplemented in #2690649: Support a wider variety of YouTube playlist inputs..