收藏
回答

在小游戏中使用 Video.seek 视频跳转时,画面会抖动一下

ios 机型 seek 不会自动播放,而安卓机型会自动播放

// 监听视频播放进度
  vVideo.onTimeUpdate((res) => {
    if (res.position >= PVideoCardFrame[this.mPageIndex][1]) {
      const vTimer = res.position - PVideoCardFrame[this.mPageIndex][1];
      vVideo.pause();
      vVideo.seek(PVideoCardFrame[this.mPageIndex][0] + vTimer).then(res => {
        vVideo.play();
      });
    }
  });
回答关注问题邀请回答
收藏

2 个回答

  • 小游戏运营专员 - 宏
    小游戏运营专员 - 宏
    2022-11-14

    请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

    2022-11-14
    有用
    回复
  • 幼稚完
    幼稚完
    2022-11-16
    const mLoadWxVideo(src: string, x: number, repeat: boolean) {
      const mVideoWidth = 800;
      const mVideoHeight = 1334;
      const { screenHeight } = wx.getSystemInfoSync();
      const vVideoWidth = (mVideoWidth * screenHeight) / mVideoHeight;
      const vWxVideo = wx.createVideo({
        src,
        x,
        y: 0,
        width: vVideoWidth,
        height: screenHeight,
        autoplay: false,
        loop: repeat,
        controls: false,
        showCenterPlayBtn: false,
        enableProgressGesture: false,
        objectFit: 'cover',
        underGameView: true,
      });
      return vWxVideo;
    } 
    
    const PVideoCardFrame = [
      [4.04, 5.55],
      [9.04, 11.04],
      [16.01, 18.01],
      [21.21, 23.19],
      [27.07, 28.63],
      [34.02, 35.6],
      [41.05, 43.05],
      [48.18, 50.18],
    ];
    const mVideoWidth = 800;
    const mVideoHeight = 1334;
    const { screenWidth, screenHeight } = wx.getSystemInfoSync();
    const vVideoWidth = (mVideoWidth * screenHeight) / mVideoHeight;
    const vVideoOffsetX = (vVideoWidth - screenWidth) / 2;
    const vVideo = this.mLoadWxVideo(`https://acsp-static.sit.sf-express.com/sfoss/annual-report/videos/normal.mp4`, -vVideoOffsetX, false);
    let vTimer = false;
    // 监听视频播放事件
    vVideo.onPlay(() => {
      // console.log(`第${this._mPageIndex + 1}个非循环视频开始播放`);
      console.log('onPlay。。。。');
      if (!vTimer) {
        vTimer = true;
        this.mScriptLoading.MAddProgress();
      }
    });
    
    
    // 监听视频播放到末尾事件
    vVideo.onProgress((res) => {
      if (res.buffered > 5) {
        vVideo.play();
      }
    });
    vVideo.onTimeUpdate((res) => {
        if (res.position >= PVideoCardFrame[this.mPageIndex][1]) {
          const vTimer = res.position - PVideoCardFrame[this.mPageIndex][1];
          vVideo.pause();
          vVideo.seek(PVideoCardFrame[this.mPageIndex][0] + vTimer).then(res => {
            vVideo.play();
          });
        }
      });
    
    


    2022-11-16
    有用
    回复
登录 后发表内容