Uma*_*mil 7 video html5 google-chrome
我在Chrome中遇到视频支持问题.我的网页必须在Chrome中运行,并且我使用以下代码定期检查网页是否必须播放视频...但问题是,在我删除元素后,我仍然听到音频,当我重新创建eleemnt,新视频的音频和旧的重叠.
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.
}
}
Run Code Online (Sandbox Code Playgroud)
我怎么解决?
谢谢.
以下是我必须要做的最小工作.当用户按下后退按钮时,我实际上遇到了缓冲,同时产生了ajax请求.暂停Chrome和Android浏览器中的视频会使其保持缓冲状态.非异步的ajax请求会等待缓冲完成,这是永远不会的.
将其绑定到beforepagehide事件修复它.
$("#SOME_JQM_PAGE").live("pagebeforehide", function(event)
{
$("video").each(function ()
{
logger.debug("PAUSE VIDEO");
this.pause();
this.src = "";
});
});
Run Code Online (Sandbox Code Playgroud)
这将清除页面上的每个视频标签.
就我而言,我必须先暂停视频,然后再将其删除,否则音频仍在后台播放。我使用暂停的原因是因为 html5 视频元素上没有 stop() 函数。
} else {
videobox.hide();
// you can add something like this
$("#videoplayer").pause();
videobox.empty(); // Clear any children.
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4946 次 |
| 最近记录: |