javascript - 在 mousemove 上播放视频时出现抽搐

标签 javascript html html5-video mousemove jquery-easing

应用鼠标移动功能时,我遇到视频播放问题。该功能正常工作,但播放视频时出现抖动。我希望它能够通过缓动功能变得平滑。请指导我如何在不挂断的情况下播放视频。

const startDrawing = () => {
    const video = document.querySelector("video");
    let currentFrame = 0
    let mediaTime;
    let paintCount = 0;
    let startTime = 0.0;
    let fps = 60
    video.pause();
    window.addEventListener("mousemove", () => {video.currentTime = video.currentTime + 1/fps});
    video.addEventListener("play", () => {
      if (!("requestVideoFrameCallback" in HTMLVideoElement.prototype)) {
        return alert("Your browser does not support the `Video.requestVideoFrameCallback()` API.");
      }    
    });
  };
  window.addEventListener("load", startDrawing);
Courtesy of Big Buck Bunny: </br><video width="320" height="240" autoplay="" muted="" loop="" src="https://www.w3schools.com/html/mov_bbb.mp4"></video>

最佳答案

不要使用帧播放,在 mousemove 事件中播放视频,否则暂停视频。

关于javascript - 在 mousemove 上播放视频时出现抽搐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70821140/

相关文章:

javascript - 在 head 中运行 javascript,不能使用 window.onload,不能使用 jquery

javascript - javascript 从哪里获取日期

javascript - 当排序字符串时应该 é 在 e 之前

php - DOB mysql插入

javascript - KineticJS 以及捏合和缩放

jquery - 使用 JQuery 播放/暂停 HTML 5 视频

javascript - 未捕获的类型错误 : Cannot read property 'apply' of undefined Google Maps

javascript - 如何使用 jQuery/JS 检测元素的继承背景颜色?

html - github页面html中没有视频加载吗?

javascript - 在 ipad 中覆盖动态插入的视频标签