消息关闭
    暂无新消息!

小程序中,在页面A播放视频,navigate到页面B,在页面B获取到了页面A视频的播放进度,在通过seek()方法为页面B上的视频设置获取到的播放进度时,安卓机上出现如下现象:视频从进度处开始播放1s后重新跳回到进度处播放,是什么原因呢?

页面A:

<!--pages/testStorage/testStorage.wxml-->
<video id="myVideo" bindtimeupdate="update" src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400"></video>
<navigator url="/pages/testStorage1/testStorage1">点击跳转页面 当前视频播放时间:{{playTime}}</navigator>

页面A.js:

// pages/testStorage/testStorage.js
Page({
  data: {
    playTime:''
  },
  onReady:function(){
    this.videoContext = wx.createVideoContext('myVideo');
  },

  onHide: function () {
    var playTime = this.data.playTime;
    this.videoContext.pause();
    wx.setStorageSync('playTime', playTime);  //设置当前进度
  },
  update:function(e){
    var time = e.detail.currentTime;
    // console.log(time)
    this.setData({
      playTime: time
    })
  }
})

页面B:

<!--pages/testStorage1/testStorage1.wxml-->
  <video id="myVideo1" bindtimeupdate="testRun" src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400"></video>

页面B.js:

// pages/testStorage1/testStorage1.js
Page({
  data: {
    isRun: false
  },
  onReady: function () {
    // console.log('onReady')
    var that = this;
    this.videoContext = wx.createVideoContext('myVideo1');
    setTimeout(function () {
      that.playFun();
    }, 100)
  },
  playFun: function () {
    var that = this;
    var interval = setInterval(function(){
      that.getIndex();
      if (that.data.isRun){
        clearInterval(interval);
      }
    },1000)
  },
  getIndex:function(){
    var that = this;
    var time = wx.getStorageSync('playTime');
    this.videoContext.seek(time);
    this.videoContext.play();
  },
  testRun:function(){
    var that = this;
    if(!this.data.isRun){
      var isRun = true;
      that.setData({
        isRun:isRun
      })
    }
  }
})

0个回答

暂无回答!