Benoit Delaunay

Benoit Delaunay

Hey guys,

I'm working on my website but I'm usually more into graphics stuff than coding. I created tabs using javascript so all the website is on a single html page.

Now I am trying to pause all the videos when someone switch to another tab. Do you think there is a way ? Using javascript, css, html, json, moogaloop, anything.

I have a function for tab-switching but I don't know what to add in there. Probably something like "collect all the videos in the html page, pause" ? As I am fairly new to javascript I have no idea how to code this.

If someone could point me in the right direction I would be super-happy !
I would like to stick to the universal player and not flash if possible.

Ben

Pablo Bollansée

Pablo Bollansée

I'm looking for the same kind of functionality. The 'collect all the videos in the html page' can be done with: $$('iframe') I think, but I'm also stuck at the 'pause' part.
Did you find a solution yet ?

Benoit Delaunay

Benoit Delaunay

Hi, I'm working on it, I will get back to you when I find the answer !

Pablo Bollansée

Pablo Bollansée

Ok, I got it working !
Here's the code I use (with some comments added :P):

//First find all iframes
var iframes = $$('iframe');
//make a froogaloop for each of those frames
var froogaloops = new Array(iframes.length);
for(var i = 0, l = iframes.length; i < l; ++i)
{
var frame = iframes[i];
froogaloops[i] = new Froogaloop( frame );
}

function pauseAllVideos()
{
//For each froogaloop call the .api method
for(var i = 0, l = froogaloops.length; i < l; ++i)
{
froogaloops[i].api('api_pause');
}
}

Hope it helps !

Matthew Ferry

Matthew Ferry

couldn't get this to work on my end. can you post your html as well?

Benoit Delaunay

Benoit Delaunay

I haven't been email-notified of your answer

It works perfectly. Thanks a lot ! My learning of js is too slow :)

This conversation is missing your voice. Please join Vimeo or log in.

Forums

Forum Rules

  1. Be nice

    Even if you disagree with someone, keep it civil.

  2. Stay on topic

    If it’s not relevant, leave it out or start a new thread.

  3. Don't Spam

    Re-re-re-re-posts drive us crazy.

  4. Respect the Staff

    We were members once, just like you.

+ Learn more

Our Support Team

  • Sam Morrill Sam
  • Mark Cersosimo Mark
  • Ian Durkin Ian
  • Tommy Penner Tommy
  • Alex Dao Alex

We're here to help you 9AM-6PM EST, Monday to Friday.

Keyboard Shortcuts

Just think about it… What if you were trapped under something heavy and the mouse was out of your reach? Scary, right? That's exactly why we have these keyboard shortcuts so you can still use Vimeo until the help arrives.

  • [ Prev video
  • ] Next video
  • L Like this video
  • S Share this video
  • F Full screen
  • V Couch Mode
  • M More videos
  • ? More shortcuts