Vimeo Chapter Markers with Multiple Videos

Please view this as a full screen project . CodePen is looking into why the Vimeo iframe breaks the CSS within their own DIV structure but right now it looks really bad

Vimeo chapter markers with multiple videos on the same page, using the Froogaloop API

My recent exploration of chapter markers in Vimeo was pretty popular. In fact, it was so popular that I got two more jobs out of it. Vimeo is an awesome YouTube alternative. While it’s not as inherently social as YouTube, it’s got a much more professional presentation. I know, I know… you’re going to miss the YouTube comments.

Almost immediately after my last posting, a sound designer needed to be able to place multiple videos on the same page. Since the original script was using a very simple API implementation, it was grabbing the element by ID. That meant a control element could only target the first video on the page, which was a problem. So by popular request, here’s how you would implement multiple videos with chapter navigation on the same page. A more detailed explanation follows.

Video content is provided by modio.tv , because tutorials are one of the places where chapter markers can dramatically improve a website's user experience.

Tutorial 07

How to Make Smooth Keyframe Animations in After Effects

Tutorial 03

Understanding Masks & Shape Layers

A deeper explanation

As you can see, the JS does all the work and is lifted almost directly out of the latest Vimeo API playground file (Thanks Brad!). The custom magic happens in the last part:

  • We use the .delegate() jQuery method, in case the video is populated using AJAX. This is because dynamically generated content appears after the handlers are bound, so jQuery can't see it. In our case, that means the the video and chapter navigation would stop working.
  • From there we execute a callback function on the event click
  • In case you bound the data elements to a null link (#), run a prevent default so the URL doesn't change. In my example, I've styled a span instead.
  • Grab the player ID and Seek values from the clicked element
  • Target the Froogaloop object ($f) and pass a player ID by reference, then use the api to jump to the seek value.
  • Profit.

Critically, each player needs to include both the ?api and ?player_id call in the URL reference, and its iframe ID needs to mach exactly. In a CMS application, that would all be dynamically generated. In a static application, you’ll have to be a little careful with this or the chapter link won't work correctly. The production implementation is up to you.

In the navigation itself, the data-seek and data-id attribute are the key. The seek time (data-seek) is in seconds, which a CMS could calculate on the fly using the entered minute-second timestamp (minutes*60 + seconds). It's worth noting that in many cases you'll want to tune things more finely and jump to a marker like 52.35 seconds.

Finally, the data-id attribute is the matching player ID from the actual iframe. If you copy & paste the NAV, you could end up targeting the wrong video.

As always, I’m available in the comments if you have questions, bugs, or things to add.