3

I've got an edge-animate (4.0 version) inside of this iframe, in a div collection, and what I need is to pause/stop the sound of the iframe when I hide (display:none) it, and resume/play again when I show it (display:inline).

Now I've got something like this:

    if(!$('#slide_'+(slide_current-1)).find('iframe').hasClass('edgeanimate'))//
  {
    //Do nothing.
  }
  else
  {

    //Pause/Stop the sound, please
  }

The deal is that I can't touch the original javascript that comes out with the edge-animate export format; I need to stop the sound with an external JS script... Any ideas? Please help.

Thank you so much.

gyre
  • 16,369
  • 3
  • 37
  • 47
  • 1
    The sound of the iframe? Did the iframe src come from the same domain as the code you wish to stop the iframe sound from? If not you don't have CORS access, so it's not possible. – StackSlave May 05 '15 at 22:04
  • Yes, the sound of the iframe could be a solution, and i've got the src in the same domain... Any idea? – Santiago Penuela May 06 '15 at 13:49

2 Answers2

0

If you want to stop the Audio on the other page and you have access to both, you're code might look something like:

$('iframe').each(function(i, e){
  e.contents().find('audio').each(function(n, a){
    a.pause();
  });
});
StackSlave
  • 10,613
  • 2
  • 18
  • 35
0

Source code:

document.getElementByName("iframe")
.contentWindow.postMessage('{"method":"setVolume", "value":0}','*');

I think that should do the trick

jean
  • 4,159
  • 4
  • 31
  • 52