微信小程序视频播放加载很慢
发布于 6 年前 作者 qsu 1909 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)
  • 预期表现
  • 复现路径
  • 提供一个最简复现 Demo

微信小程序视频播放加载很慢,一直转圈,3分钟后才能播放,而且播放很卡,加了带宽和cdn也没有效果,官方的video组件是不是有bug

<video id=“myVideo” hidden="{{!selected4}}" bindtimeupdate=“timeUpdate” bindended=“playended”  binderror=“playerror” class=‘kcxq-topimg’ style=“width:100%” src="{{videoUrl}}" initial-time="{{initial}}" custom-cache="{{false}}" controls>

<canvas canvas-id=‘myCanvas’ style=‘width:100%;margin-top:5%;’></canvas>

</video>

let videotime = e.currentTarget.dataset.videotime;

let currProgress = Number((parseInt(videotime) * progress / 100).toFixed(0));

lastTime = currProgress;

//wx.setStorageSync(‘lastTime’, currProgress);

if (progress == 100)

currProgress = 1;

console.log(“currProgress:” + currProgress);  

that.setData({

videoUrl: src + “?t=” +new Date().getTime(),

initial: currProgress,

selected3: false, //将封面图隐藏

selected4: true, //将视频video打开显示

selected5: false //将轮播图隐藏

videoCtx = wx.createVideoContext(‘myVideo’)

;

//监听视频播放进度

timeUpdate(e) {

let that = this;

//console.log(“duration:” + e.detail.duration)

if (fromProgress < 100) {

duration = e.detail.duration;

//var lastTime = wx.getStorageSync(‘lastTime’) || that.data.initial;

currentTime = e.detail.currentTime;

console.log(‘上次的时间’ + lastTime + ‘现在的时间’ + currentTime);

if ((parseInt(currentTime) - parseInt(lastTime)) > 3) {

videoCtx.seek(lastTime);

return false;

} else {

lastTime = currentTime;

//wx.setStorageSync(‘lastTime’, currentTime);

progress = Math.round((currentTime / duration) * 10000) / 100.00;

pgMap.set(lessionid, progress); //将lessionid和进度存到map中

//console.log(“progress:” + progress);

}

}

},

//当播放到末尾时触发 ended 事件

playended(e) {

let that = this;

console.log(“更新子课程进度:100”)

pgMap.set(lessionid, 100);

that.updateLearnItem(); //更新子课程进度

setTimeout(function () {

that.getDetail();

}, 1000)

},

2 回复

你好,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

遇到同样的问题。相同的链接PC上面播放非常流畅。小程序中播放很卡,而且需要很长时间才能加载出来,iOS直接报错。

回到顶部