收藏
回答

video组件手机上不能播放引用地址的腾讯视频

问题模块 框架类型 问题类型 API/组件名称 终端类型 操作系统 微信版本 基础库版本
API和组件 小程序 Bug video 客户端 Android 6.6.7 1.9.91

我动态得到了腾讯的视频src真实播放地址,并且在开发者工具上也可以播放,但是发布上线后在手机上就播放不出来了。这是怎么回事?

最后一次编辑于  2018-06-21  (未经腾讯允许,不得转载)
邀请回答
复制链接收藏投诉关注问题回答

1 个回答

  • 大卫
    大卫
    2018-06-21

    1、首先我们从腾讯视频网站上找到一个视频网页的连接,格式是这样的

    https://v.qq.com/x/page/b0136et5ztz.html

    上面我标红色的是视频的vid

    2、我们把vid放到接口地址上变成 

    http://vv.video.qq.com/getinfo?vids=b0136et5ztz&platform=101001&charge=0&otype=json

    3、直接访问返回的是

    QZOutputJson={"dltype":1,"exem":0,"fl":{"cnt":2,"fi":[{"id":100701,"name":"msd","lmt":0,"sb":1,"cname":"流畅;(180P)","br":29,"drm":0,"video":1,"fs":35776912,"sl":1},{"id":2,"name":"mp4","lmt":0,"sb":1,"cname":"高清;(480P)","br":34,"drm":0,"video":1,"fs":74129447,"sl":0}]},"hs":0,"ip":"119.137.195.73","ls":0,"preview":1186,"s":"o","sfl":{"cnt":0},"tm":1503504934,"vl":{"cnt":1,"vi":[{"br":29,"ch":0,"cl":{"fc":0,"keyid":"b0136et5ztz.100701"},"ct":21600,"drm":0,"dsb":0,"fmd5":"87d7d2ef15f55a456bcdb359dd580795","fn":"b0136et5ztz.m701.mp4","fs":35776912,"fst":5,"fvkey":"EBB1F5C7B5100A3DA80802119E3FF9D0AAE3DA6670594D507B02AD489CF21D2868B0803B76F7434CE51B5C70D75554D68ED24A49EE3DE4791E0BA58444A77756FA7CBC6FB1B3E579F44F87AFB1CB79E8522A48576A4949037A5EDC1C842A9EF7536E090EBD018BB2","head":0,"hevc":0,"iflag":0,"level":0,"lnk":"b0136et5ztz","logo":1,"mst":8,"pl":null,"share":1,"sp":0,"st":2,"tail":0,"td":"1186.92","ti":"解密潮汕多神信仰","type":3,"ul":{"ui":[{"url":"http://113.105.167.156/vhot2.qqvideo.tc.qq.com/AuRJoSSIabzpOb1RsXSviFl-nYwRDSZoFU5OpwBhfrAk/","vt":200,"dtc":0,"dt":2},{"url":"http://113.105.167.155/vhot2.qqvideo.tc.qq.com/AuRJoSSIabzpOb1RsXSviFl-nYwRDSZoFU5OpwBhfrAk/","vt":200,"dtc":0,"dt":2},{"url":"http://113.105.167.154/vhot2.qqvideo.tc.qq.com/AuRJoSSIabzpOb1RsXSviFl-nYwRDSZoFU5OpwBhfrAk/","vt":200,"dtc":0,"dt":2},{"url":"http://video.dispatch.tc.qq.com/62098754/","vt":0,"dtc":0,"dt":2}]},"vh":272,"vid":"b0136et5ztz","videotype":27,"vr":0,"vst":2,"vw":480,"wh":1.7647059,"wl":{"wi":[]}}]}}; 

    4、我们把前面的QZOutputJson=跟最后的 ; 过滤掉,得到一个json字符串了。解析它变成json对象,然后把标红的三个部分组合一下,顺序是 

    url + fn + '?vkey=' + fvkey 

    例如上面这串,组合下来就是 

    http://113.105.167.156/vhot2.qqvideo.tc.qq.com/AuRJoSSIabzpOb1RsXSviFl-nYwRDSZoFU5OpwBhfrAk/b0136et5ztz.m701.mp4?vkey=EBB1F5C7B5100A3DA80802119E3FF9D0AAE3DA6670594D507B02AD489CF21D2868B0803B76F7434CE51B5C70D75554D68ED24A49EE3DE4791E0BA58444A77756FA7CBC6FB1B3E579F44F87AFB1CB79E8522A48576A4949037A5EDC1C842A9EF7536E090EBD018BB2

    这个地址就可以直接放在小程序的video组件里面播放了。


    注意:由于腾讯视频的地址vkey是定时变化的,所以肯定是不能写死在程序里面的。必须走后端照着上面写的方式抓取接口,过滤掉无用字符串,解析json,组合地址,通过接口返回给小程序video组件的src即可正常播放。

    当然如果你的后端解析json比较麻烦的(例如古老的asp ^_^),可以把第2步最后的json去掉或者改成xml,直接解析xml也一样。


    2018-06-21
    赞同
    回复 1
    • meeeao🐱
      meeeao🐱
      07-27
      这种方式获取到一个播放地址之后经常出现加载缓慢的情况,不知道为啥。
      07-27
      回复