HTML5 Video Stop onClose

后端 未结 9 884
暗喜
暗喜 2020-12-10 11:23

I\'m using jQuery tools for an overlay. Inside the overlay I have an HTML5 video. However, when I close the overlay, the video keeps playing. Any idea how I might get the vi

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-10 12:01

    For a JQM+PhoneGap app the following worked for me.

    The following was the minimum I had to go to get this to work. I was actually experiencing a stall due to the buffering while spawning ajax requests when the user pressed the back button. Pausing the video in Chrome and the Android browser kept it buffering. The non-async ajax request would get stuck waiting for the buffering to finish, which it never would.

    Binding this to the beforepagehide event fixed it.

     $("#SOME_JQM_PAGE").live("pagebeforehide", function(event)
     {
               $("video").each(function () 
               { 
                   logger.debug("PAUSE VIDEO");
                   this.pause();
                   this.src = "";
               });
     });
    

    This will clear every video tag on the page.

    The important part is this.src = "";

提交回复
热议问题