收藏
回答

video组件视频 不能播放问题报错?MEDIA_ERR_DECODE(-4000,-3)

视频不能播放。但是开发工具是可以的。报错信息是MEDIA_ERR_DECODE(-4000,-3)

index.wxml

<view class="page-body">
  <view class="page-section tc">
    <video 
      id="myVideo" 
      src="https://video.01recycle.com/fe39e4bd753c4e9bba50cf8655fb802e/b28c2cccda1049ceb647895fb1864db2-3238cebf7de8f000b6a39e5612d22d59-sq.mp4" 
      binderror="videoErrorCallback" 
      danmu-list="{{danmuList}}" 
      enable-danmu 
      danmu-btn 
      show-center-play-btn='{{false}}' 
      show-play-btn="{{true}}" 
      controls
      picture-in-picture-mode="{{['push', 'pop']}}"
      bindenterpictureinpicture='bindVideoEnterPictureInPicture'
      bindleavepictureinpicture='bindVideoLeavePictureInPicture'
    ></video>
    <view style="margin: 30rpx auto" class="weui-label">弹幕内容</view>
    <input bindblur="bindInputBlur" class="weui-input" type="text" placeholder="在此处输入弹幕内容" />
    <button style="margin: 30rpx auto"  bindtap="bindSendDanmu" class="page-body-button" type="primary" formType="submit">发送弹幕</button>
    <navigator style="margin: 30rpx auto"  url="picture-in-picture" hover-class="other-navigator-hover">
      <button type="primary" class="page-body-button" bindtap="bindPlayVideo">小窗模式</button>
    </navigator>
  </view>
</view>

index.js

// index.js
// 获取应用实例
const app = getApp()
function getRandomColor() {
  const rgb = []
  for (let i = 0; i < 3; ++i) {
    let color = Math.floor(Math.random() * 256).toString(16)
    color = color.length === 1 ? '0' + color : color
    rgb.push(color)
  }
  return '#' + rgb.join('')
}


Page({
  onShareAppMessage() {
    return {
      title'video',
      path'page/component/pages/video/video'
    }
  },


  onReady() {
    this.videoContext = wx.createVideoContext('myVideo')
  },


  onHide() {


  },


  inputValue'',
  data: {
    src'',
    danmuList:
    [{
      text'第 1s 出现的弹幕',
      color'#ff0000',
      time1
    }, {
      text'第 3s 出现的弹幕',
      color'#ff00ff',
      time3
    }],
  },


  bindInputBlur(e) {
    this.inputValue = e.detail.value
  },


  bindButtonTap() {
    const that = this
    wx.chooseVideo({
      sourceType: ['album''camera'],
      maxDuration60,
      camera: ['front''back'],
      success(res) {
        that.setData({
          src: res.tempFilePath
        })
      }
    })
  },


  bindVideoEnterPictureInPicture() {
    console.log('进入小窗模式')
  },


  bindVideoLeavePictureInPicture() {
    console.log('退出小窗模式')
  },


  bindPlayVideo() {
    console.log('1')
    this.videoContext.play()
  },
  bindSendDanmu() {
    this.videoContext.sendDanmu({
      textthis.inputValue,
      color: getRandomColor()
    })
  },


  videoErrorCallback(e) {
    console.log('视频错误信息:')
    console.log(e.detail.errMsg)
  }
})
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容