gpt4 book ai didi

javascript - 同源HTML5视频同时加载失败?

转载 作者:行者123 更新时间:2023-11-28 00:17:20 26 4
gpt4 key购买 nike

我这里有一个简单的测试页面:

<!DOCTYPE HTML>
<html>
<head>
<title>Event "seeked" test</title>
</head>
<body>
<div id="main" align="center"></div>
<script>
var main = document.getElementById("main");
var thumbnails = document.getElementById("thumbnails");

var video = document.createElement("video");
video.setAttribute("id", "video");
video.setAttribute("src", "pathtomyvideo.mp4");
video.setAttribute("controls", "true");
video.setAttribute("autoplay", "true");
main.appendChild(video);

var video2 = document.createElement("video");
video2.setAttribute("id", "video2");
video.setAttribute("src", "pathtomyvideo.mp4");
video2.setAttribute("controls", "true");
video2.setAttribute("autoplay", "true");
main.appendChild(video2);
</script>
</body>
</html>

在 Chrome 中,只有一个视频文件加载,而另一个似乎没有加载。当两个来源不同时,它加载正常。如果我明确地键入 HTML,则只有其中一个加载而另一个不加载(相同的行为)。

我该如何解决?

最佳答案

你要为这个而自责吗,你肯定复制粘贴了?第二个视频 src 没有设置,你只是覆盖第一个:

video.setAttribute("src", "pathtomyvideo.mp4");

改为

video2.setAttribute("src", "pathtomyvideo.mp4");

刚刚测试,效果很好......

关于javascript - 同源HTML5视频同时加载失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11464095/

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