gpt4 book ai didi

HTML

转载 作者:太空狗 更新时间:2023-10-29 14:16:11 24 4
gpt4 key购买 nike

我正在尝试将视频设置为页面中的背景。问题是我有一个并触发了 1 次视频下载,然后当它完成时你再次开始播放视频,但它也会再次下载。

好像这是一件小事,在第五次迭代之后,它就停止播放视频了。

我现在在 Ubuntu 13.04 上使用 Chrome 30.0.1599.14 dev


这是截图

Dev tools with the video requests

关于如何阻止这种行为有什么建议吗?

最佳答案

 <style type="text/css">
body { background: url(demo.jpg) center;
background-size: 300%;
width:100%;
height:150px;}
video { display: block; }
video#bgvid {
position: fixed;
top: 50%;
left: 50%;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -100000;
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);

}
@media screen and (max-device-width: 800px) {
body { background: url(demo.jpg) #000 no-repeat center center fixed; }
#bgvid { display: none; }
}
</style>
<script type="text/javascript">
//if it is not already in local storage
if (localStorage.getItem("demo") === null){
//make request for file
var oReq = new XMLHttpRequest();
oReq.open("POST", "http://LINK_TO_demo.mp4", true);
// arraybuffer needed for binary file
oReq.responseType = "arraybuffer";
// once loaded
oReq.onload = function(oEvent) {
// Convert to Blob Object
var blob = new Blob([oReq.response], {type: "video/mp4"});
var reader = new FileReader();
reader.readAsDataURL(blob);
reader.onload = function(e) {
var dataURL = reader.result;
localStorage.setItem("demo", dataURL);
// reload or add document ready function.
location.reload();
}
oReq.send();}}
var videlem = document.createElement("video");
videlem.autoplay = true;
videlem.loop = true;
videlem.poster = "demo.jpg";
videlem.id = "bgvid";
var sourceMP4 = document.createElement("source");
sourceMP4.type = "video/mp4";
sourceMP4.src = localStorage.getItem("demo");
sourceMP4.autoPlay = true;
videlem.appendChild(sourceMP4);
document.body.appendChild(videlem);
</script>

这将使它播放得更快并将视频存储在本地存储中,因此不再向服务器发出更多请求。

关于HTML <video loop> - 下载多次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18480562/

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