Javascript,一次加载多个源

发布于 2024-12-21 10:33:36 字数 467 浏览 1 评论 0原文

我正在尝试制作一些可以快速加载第二个视频的东西,以使其看起来像是两个视频连接成一个(因为根据按键输入,一个视频可能会导致两个选择,具体取决于用户是否按下了正确的键)

现在我使用的基本功能是:

function play(first, second){
    var video = document.getElementById("media")

    video.setAttribute("src", first)
    video.load()
    video.play()

    setTimeout(function(){
        video.setAttribute("src", second)
        video.load()
        video.play()
    }, 2000)
}

现在它有大约一秒的延迟,这样就不会显得两个视频是一个。关于如何解决这个问题有什么想法吗?

I'm trying to make something that will quickly load a second video to make it appear is if the two videos were concatenated into one (because depending on key inputs, one video could lead to two choices depending on if the user hits the correct key)

Right now the basic function I'm using is:

function play(first, second){
    var video = document.getElementById("media")

    video.setAttribute("src", first)
    video.load()
    video.play()

    setTimeout(function(){
        video.setAttribute("src", second)
        video.load()
        video.play()
    }, 2000)
}

Right now it's got about a second of lag so that it doesn't appear as if the two videos are one. Any ideas on how to fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文