gpt4 book ai didi

html - 在 Chrome 中删除

转载 作者:太空狗 更新时间:2023-10-29 14:08:54 26 4
gpt4 key购买 nike

我在 Chrome 中遇到视频支持问题。我的网页必须在 Chrome 中运行,我正在使用以下代码定期检查网页是否必须播放视频......但问题是在我删除元素后,我仍然听到音频,当我重新创建元素,新视频的音频和旧的重叠。

function showVideo() {
var video = videodata;

var videobox = $('#videobox').first();
var videoplayer = $('#videoplayer').first();

if (video.Enabled) {
if ((videoplayer.length > 0 && videoplayer[0].currentSrc != video.Location) || videoplayer.length == 0) {
videobox.empty();
videobox.append('<video id="videoplayer" preload="auto" src="' + video.Location + '" width="100%" height="100%" autoplay="autoplay" loop="loop" />');
videobox.show();
}
} else {
videobox.hide();
videobox.empty(); // Clear any children.
}
}

我该如何解决?

谢谢。

最佳答案

以下是我必须完成的最低限度的工作。当用户按下后退按钮时,由于在生成 ajax 请求时发生缓冲,我实际上遇到了一个停顿。在 Chrome 和 Android 浏览器中暂停视频会使其保持缓冲状态。非异步 ajax 请求会卡住等待缓冲完成,这是永远不会发生的。

将其绑定(bind)到 beforepagehide 事件修复了它。

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

这将清除页面上的每个视频标签。

关于html - 在 Chrome 中删除 <video> 元素后音频继续,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9045440/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com