微信小游戏android视频播放失败

小游戏 企业微信 微信支付 小程序 文章 2020-07-30 21:01 895 0 全屏看文

AI助手支持GPT4.0

微信小游戏android视频播放失败

微信小游戏在android设备上运行概率性出现视频播放失败,返回的错误码是解码失败MEDIA_ERR_DECODE。

麻烦帮忙看看,印象中ios没有出现过这样的问题

When wechat games run on Android devices, there is a probability that video playback fails, and the error code returned is media, which fails to decode_ ERR_ DECODE。 Please help to have a look. I don't think IOS has had such a problem

回答:

Forever:

能提供复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)吗?官方的小游戏API调用示例(https://github.com/wechat-miniprogram/minigame-demo)复现不了你的bug

黄炜良:你好 我这边观察,如果只播放同一个视频一直循环播放是没有问题的,但是如果播放不同的视频,播着播着就卡主了。但是这个没有提示任何的错误信息。
Forever:那能不能制作简单的代码片段呢?
黄炜良:也是不行的,同一个视频循环播放16次之后也出现解码失败
黄炜良:这是我这边的代码
var video
let { screenWidth, screenHeight } = wx.getSystemInfoSync()
var myvideos = new Array()
myvideos[0] = "https://tomabc.oss-cn-hangzhou.aliyuncs.com/2DResources/u2l1/video/car/ufo/ufo.mp4"
myvideos[1] = "https://tomabc.oss-cn-hangzhou.aliyuncs.com/2DResources/u2l1/video/plane/ufo/ufo.mp4"
myvideos[2] = "https://tomabc.oss-cn-hangzhou.aliyuncs.com/2DResources/u2l1/video/bus/ufo/ufo.mp4"
myvideos[3] = "https://tomabc.oss-cn-hangzhou.aliyuncs.com/2DResources/u3l1/video/apple/ufo/ufo.mp4"
myvideos[4] = "https://tomabc.oss-cn-hangzhou.aliyuncs.com/2DResources/u3l1/video/orange/ufo/ufo.mp4"
myvideos[5] = "https://tomabc.oss-cn-hangzhou.aliyuncs.com/2DResources/u3l1/video/pear/ufo/ufo.mp4"
myvideos[6] = "https://tomabc.oss-cn-hangzhou.aliyuncs.com/2DResources/u2l1/video/car/ufo/hello.mp4"
myvideos[7] = "https://tomabc.oss-cn-hangzhou.aliyuncs.com/2DResources/u3l1/video/apple/ufo/hello.mp4"
var i = 0
export default class Main {
  constructor() {
    wx.setEnableDebug({
      enableDebug: true
    })
    this.play()
  }
  play () {
    this.stop()
    video = wx.createVideo({
      x: (screenWidth - screenHeight * 4 / 3) / 2,
      y: 0,
      width: screenHeight * 4 / 3,
      height: screenHeight,
      src: myvideos[i%myvideos.length],
      underGameView: true,
      autoplay: true,
      controls: false,
      objectFit: 'cover',
      enableProgressGesture: false,
      showCenterPlayBtn: false,
      customcache:false,
    })
    var start = true
    var pause = true
    video.onTimeUpdate((res) => {
        console.error('start, cur time:' + res.position + ", total time" + res.duration)
      if (pause && (res.duration - res.position) < 0.2 && res.duration > 0 && res.position > 0) {
        console.error('pause, cur time:' + res.position + ", total time" + res.duration)
        pause = false
        video.pause()
        i++
        console.error(i+" "+myvideos[i%myvideos.length])
        this.play()
      }
    })
    video.onError((res) => {
      console.error('视频加载失败,请检查网络' + res.errMsg);
      wx.showModal({
        content: '视频加载失败,请检查网络',
        confirmText: '重试',
        showCancel: false,
        success: function (res) {
          console.error('视频加载失败,请检查网络,重试')
        }
      });
    })
  }
  stop() {
    if (video) {
      video.stop()
    }
  }
}
黄炜良:每次播放完毕之后再播放另外一个视频
Forever:你上面的这段代码只是视频缓冲好就继续缓冲下一个视频吧
Forever:而且能否配合一下?能提供复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)会很难吗?
黄炜良:不是,那个是自动播放的。我看看可不可以,没试过出代码片段
黄炜良:您好,这是我的代码片段,麻烦帮忙看看https://developers.weixin.qq.com/s/tiss3xmb7Gi5  谢谢您
黄炜良:IOS也会出现,但是ios是循环播放很多遍了才出现
黄炜良:你好,麻烦问一下,现在是什么情况了
Forever:我们相关人员正在排查
黄炜良:谢谢,麻烦了
Forever:能麻烦你那边复现一次吗?然后在手机微信那里上传下日志: 我->设置->帮助与反馈右上角有个上报日志的入口,麻烦提供一下微信号,时间点
黄炜良:好的
黄炜良:你好,已上传日志10:51
Forever:微信号呢?
黄炜良:J1234567887654321
黄炜良:你好,这个问题能查到什么原因了吗
黄炜良:你好,麻烦问一下,那个问题现在跟进得怎么样,能先给一个结论吗?

-EOF-

AI助手支持GPT4.0