开发者

Stop playing HTML5Media when jQuery UI tab is switched

开发者 https://www.devze.com 2023-03-31 17:56 出处:网络
Is it possible to stop an HTML5 video from playing when the tab is switched or out of focus? I am using HTML5 video in conjunction with jQuery UI tabs.

Is it possible to stop an HTML5 video from playing when the tab is switched or out of focus?

I am using HTML5 video in conjunction with jQuery UI tabs.

I apologize in advance, I can't seem to find a working solution.


Thanks for your help, but my knowledge of javascript is at amateur level. I tried using CSS to throw it off screen instead of hiding it, but that didn't work either.

WTK, Thanks, your solution worked for every browser but IE 7/8. IE kicks back an error ("Object doesn't support this property or method") and won't switch to the video tab at all – it's broken in IE.

I assume that's because IE < v.开发者_如何学C9 doesn't understand the html5 video object and falls back to Flowplayer when using HTML5Media's solution…?

Any ideas? Thanks!


$('#example').tabs({
    select: function(event, ui) {
        // if tab we're switching to isn't the one with a video player
        if (ui.tab.id != 'tab_with_player') {
            // pause your video player
            $("#your_video_tag")[0].pause();
        }
    }
})


handling the select event should do the trick.

0

精彩评论

暂无评论...
验证码 换一张
取 消