We are using your YouTube Field module to generate a YouTube thumbnail that links to a Colorbox of the YouTube video, on this page http://www.homebuildersgallery.com/scott-patrick-homes (in the bottom-right of the page).

The Colorbox Trigger opens the video in the Colorbox, and everything is working great, except if we set the video to autoplay. This would be ideal, as the user will be clicking the thumbnail to view the video.

The problem is that if we set the video to autoplay, it will autoplay of course. But the video is not displayed in the View, but it's autoplaying in the background. This will get worse as we add more videos, as all the videos will autoplay. Is there a way to have the video only autoplay when the thumbnail is clicked.

Any help or patch will be appreciated.

Thanks!

CommentFileSizeAuthor
#1 1914406-youtube-hidden-modal-content.png109.95 KBguschilds
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

guschilds’s picture

Category: task » support
FileSize
109.95 KB

Alf,

Thanks for providing a link. If you look at the attached screenshot, you'll see that what is happening is the videos are rendered into the page but hidden. When the modal window is used, it is pulling that embed code from the page. When you set them to autoplay, they are playing upon the initial page load because they are all rendered into the HTML from the beginning.

This isn't really something that can be fixed with a module patch, but I can think of a few options you have:

  • Use JavaScript/jQuery and the YouTube JavaScript API's .playVideo() to tell the video to play when the link is clicked to open the modal window.
  • I'm not familiar with Colorbox, but other modal windows can load entirely new URLs rather than just a particular div on the existing page. If Colorbox can, you could set up a URL using hook_menu() that takes an nid from the URL and uses field_view_value() to render the video field of that node. There are then ways to stop that page from rendering the rest of the usual Drupal templates/theme so that only your video is shown. Because the video wouldn't be loaded until the modal window is opened, autoplay wouldn't begin until you'd expect.

Does this help?

Gus

guschilds’s picture

Status: Active » Closed (duplicate)

Alf, I suggest you check out #1929652: Support for colorbox. A patch has been provided to add Colorbox support for this module. I think it would work well for what you are trying to accomplish here, as you could set the field's formatter in your view to be a thumbnail linked to open Colorbox in a modal window. Please share all further experience with Colorbox integration in that issue.