Search code examples
videoembedhidemute

hiding a video and muting the sound


I'm trying to hide an embedded video using som simple jQuery and it all worked fine till turned my speakers on. The video hides fine but the sound keeps on playing in the background.

Is there a function I can cal that either mutes the video aswell or completely removes it?

Check the link below for an example, play the video then click the hide video link to see what I'm talking about. Been at this for ages and it's properly annoying me now.

http://jsfiddle.net/P3zKc/


Solution

  • Well Vimeo's API reference is horrible, but check out this page. http://developer.vimeo.com/player/js-api Mainly the play() and pause() functions. It says you need to send any of these API functions indirectly to the iFrame containing the video. To do this you need to add api=1 to the iFrame url like this <iframe id="video2" src="http://player.vimeo.com/video/16965687?title=0&amp;byline=0&amp;portrait=0&api=1" width="400" height="225" frameborder="0"></iframe>
    You can't call these functions directly on the iFrame though, you have to use postMessage() to send the function call to the iFrame. https://developer.mozilla.org/en/DOM/window.postMessage has some good documentation on the syntax of that function. Hope this helps.