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.
Hey guys,
I am using the youtube field module and have used it in displaying youtube videos in my website. My requirement is to have the playlist videos show up on the related videos carousel. Is that possible? If not, are there any alternate solutions for this where I can provide the playlist suggestions in the carousel other than random related videos?
Comments
Comment #2
guschilds CreditAttribution: guschilds at Chromatic commentedHi sharath.chandar,
Sorry for the delayed response, but it is possible to create a custom playlist.
Embedded YouTube videos have playlist support using a
playlist
parameter in the embedded video's URL (as listed here). Because this module strips any parameters by default, you'll need to do the following:playlist
parameter with comma separated video IDs, as instructed by the YouTube documentation I linked to above. For example:https://www.youtube.com/watch?v=9HoUDDetAg0&playlist=Phl82D57P58,tN4WHTGWlHY,Yn2tHcZEnF0
.I'm going to go ahead and close this, but please reopen if you have any issues.
Comment #3
webservant316 CreditAttribution: webservant316 commentedAny possibility of add a default setting for the youtube after video playlist? I have many videos on my website with hundreds more expected. So rather than require a specific addition of the playlist to each video field I would instead like to express a default after video play list that is tagged on the end of all my videos.
So for example automatically paste this on the the end of every video URL, "&playlist=Phl82D57P58,tN4WHTGWlHY,Yn2tHcZEnF0". There could be other uses for this feature as well.
Comment #4
webservant316 CreditAttribution: webservant316 commentedComment #5
webservant316 CreditAttribution: webservant316 commentedFor an initial test solution I threw these two lines in youtube.theme.inc. Works great.
is this code block...
Comment #6
webservant316 CreditAttribution: webservant316 commentedany help here?
Comment #7
guschilds CreditAttribution: guschilds commentedHi webservant316,
Because we're not actively adding new features unless they're in high demand, I wasn't planning on doing any additional development here.
If you'd like to try adding the feature, I'd recommend searching the module for "youtube_width", which is an example of a textfield setting. You could then follow that to add your own setting that eventually gets used within
theme_youtube_video()
.From there I'd recommend creating a patch that you can then re-apply after any additional updates. You could upload it here as well in case anyone else finds it useful. I might also be able to review it if you'd like, but I can't make any promises about it being committed.
Hope that helps!
Comment #8
webservant316 CreditAttribution: webservant316 commentedok. I found the place in the code to add a one-liner for my purpose. So okay. I'll just maintain my own patch for now. Thanks for getting back to me.
Comment #9
guschilds CreditAttribution: guschilds commentedSounds good - you're welcome. I'm going to go ahead and close this again.
Comment #10
webservant316 CreditAttribution: webservant316 commentedSomething change in youtube. Youtube says that they play the main video first and the playlist second if available, https://developers.google.com/youtube/player_parameters. However, just noticed that if playlist is available youtube now only plays the playlist and not the main video. Dunno if this is a youtube problem or a problem with the settings in this module. I proposed #5 above to automatically add a thank you video after the main video. #5 did work, but something changed and now I use the code below...
I will have to keep an eye out to see if youtube changes back to be in compliance with their own documentation. Worst case is that my video will play twice with this proposed code.