问题描述
我搜索并尝试了很多方法来让我的视频播放器在 chrome 浏览器中工作。
即使缓存为空,我也会出错;
他们一直工作到我将视频源切换为二进制数据。在 windows 和 linux 中的 mozilla 中都可以正常工作,没有任何错误,但在其他人中则不然。我在主页上的 iframe 中加载此页面。
视频源来自 $_[GET]
方法,然后附加到 data-src 属性。
/*plus other functions*/
video=player.querySelectorAll(".play-window")[0].getElementsByTagName("video")[0];
function is_playing(curTime){
return Feedback;
};
function can_play(what){
if((!what.canplay||!what.canplaythrough)&&what.loaded==false&&what.src==''){
what.setAttribute('poster',src_err);total.innerHTML='src Error';
}else{is_playing(what.currentTime);
};``
};
window.addEventListener('DOMContentLoaded',function(){
video.src=src_arg_all[0].getAttribute('data-src');video.load();can_play(video);
});
/*plus other functions & event listeners*/
到目前为止,我已经在基于 windows 和 linux 的浏览器上测试了这个问题。 没什么特别的。 如果需要更多细节,我会在这里发布。提前感谢您的帮助。
解决方法
`if(navigator.userAgent.toLowerCase().includes('chrome')){video.src=src_arg_all[0].getAttribute('data-src');};`
这太容易了,我一定忘记了。 ;-)