请选择 进入手机版 | 继续访问电脑版
设为首页收藏本站

jeesite

 找回密码
 注册新会员
查看: 176|回复: 0

[贴图] 微信小程序video组件调用腾讯视频的解决方案

[复制链接]
admin 发表于 2018-7-27 16:03:50 | 显示全部楼层 |阅读模式
微信小程序video组件调用腾讯视频的解决方案

==================================



2018年6月更新最新消息:小程序插件已经支持直接引用腾讯视频了。

文档:https://mp.weixin.qq.com/wxopen/ ... 4258&lang=zh_CN



==================================





最近在折腾微信小程序,需要引用一些腾讯视频网站上的视频去播放,很多地方都是教人用F12抓一个mp4地址,这根本不行,因为那个地址是动态的,大概一两个小时就失效了。

翻了微信小程序的官方社区这方面的问题只有人提问,没有人有正确的回答(包括官方人员也都不懂),那就只能自己研究了。还好不是很难,折腾了一晚上终于搞定了。



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

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

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

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

http://vv.video.qq.com/getinfo?v ... ge=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.qqv ... EF7536E090EBD018BB2

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

使用道具 举报

您需要登录后才可以回帖 登录 | 注册新会员

本版积分规则

QQ|手机版|小黑屋|Archiver|jeesite 官方论坛. ( 吉ICP备12004769号  

GMT+8, 2018-10-19 08:43 , Processed in 0.171875 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表