Stop a Vimeo Video with Jquery

前端 未结 4 1793
迷失自我
迷失自我 2021-01-20 21:26

I need to stop a Vimeo video embedded with new oembed api (universal player) but when I try to add an event I get this error:

Uncaught TypeError: Object #<         


        
4条回答
  •  盖世英雄少女心
    2021-01-20 22:14

    This is not the correct answer, but may work for your situation as it did for mine. I simply wanted to stop my Vimeo from playing when I closed its containing DOM element. I was collapsing its container and that hid it visually but the audio continued to play and use browser resources unnecessarily.

    What I do now is simply store the iframe in a variable, remove it from the DOM, then replace it immediately. I have NOT tested across browsers, only the latest version of Chrome and Safari Mobile.

    var container = $("#VimeoContainer");
    var iframe = container.find("iframe");
    iframe.remove();
    container.append(iframe);
    

    Again, Froogaloop is really the way to go, however I've had issues with it in the past so for this situation I was looking for something simple. Obviously you could do this without JQuery with the same results.

提交回复
热议问题