小程序开发工具、真机调试视频都可以播放,但是发布了不行
发布于 5 年前 作者 juanfan 14079 次浏览 来自 问答

开发工具跟真机调试视频可正常播放显示,发布一直在转圈

// 请求视频信息

 getVideoInfo: function (vid) {

   var that = this;

   var urlString = https://vv.video.qq.com/getinfo?otype=json&appver=3.2.19.333&platform=11&defnpayver=1&vid= + vid;

   wx.request({

     url: urlString,

     success: function (res) {

       var dataJson = res.data.replace(/QZOutputJson=/, ‘’) + ‘qwe’;

       var dataJson1 = dataJson.replace(/;qwe/, ‘’);

       var data = JSON.parse(dataJson1);

       var fn_pre = data.vl.vi[0].lnk

       host = data[‘vl’][‘vi’][0][‘ul’][‘ui’][0][‘url’]

       var streams = data[‘fl’][‘fi’]

       var seg_cnt = data[‘vl’][‘vi’][0][‘cl’][‘fc’]

       if (parseInt(seg_cnt) == 0) {

         seg_cnt = 1

       }

       var best_quality = streams[streams.length - 1][‘name’]

       var part_format_id = streams[streams.length - 1][‘id’]

       for (var i = 1; i < (seg_cnt + 1); i++) {

         var filename = fn_pre + ‘.p’ + (part_format_id % 10000) + ‘.’ + i + ‘.mp4’;

         pageArr.push(i);

         that.requestVideoUrls(part_format_id, vid, filename, ‘index’ + i);

       }

     }

   })

 },

 // 解析视频真正的地址

 requestVideoUrls: function (part_format_id, vid, fileName, index) {

   var keyApi = https://vv.video.qq.com/getkey?otype=json&platform=11&format= + part_format_id + “&vid=” + vid + “&filename=” + fileName + “&appver=3.2.19.333”

   var that = this;

   var part_urls = [];

   wx.request({

     url: keyApi,

     success: function (res) {

       var dataJson = res.data.replace(/QZOutputJson=/, ‘’) + “qwe”;

       var dataJson1 = dataJson.replace(/;qwe/, ‘’);

       var data = JSON.parse(dataJson1);

       if (data.key != undefined) {

         var vkey = data[‘key’]

         var url = host + fileName + ‘?vkey=’ + vkey;

         part_urls[index] = String(url)

         that.setData({

           videoUrl: part_urls.index1

         });

       }

     }

   })

 },

这是前端

<video id=“myVideo” class=“myVideo” src="{{videoUrl}}" controls=“false” autoplay=“true” loop=“true” show-play-btn=“false” show-center-play-btn=“false” show-progress=“false” enable-progress-gesture=“false” objectFit=“fill”>
        </video>

1 回复

建议是先对线上版本进行调试,看看有没有明显的错误提示https://developers.weixin.qq.com/miniprogram/dev/api/wx.setEnableDebug.html

回到顶部