全国咨询热线:18720358503

报名工具小程序_微信小程序嵌入腾讯视频源过程

类别:媒体报道 发布时间:2021-01-07 浏览人次:

微信小程序嵌入腾讯视频源过程详解       这篇文章主要介绍了微信小程序嵌入腾讯视频源过程详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
getinfo otype=json appver=3.2.19.333 platform=11 defnpayver=1 vid=

获取的数据格式是这样的

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":,"sl":1},{"id":2,"name":"mp4","lmt":0,"sb":1,"cname":"高清;(480P)","br":34,"drm":0,"video":1,"fs":,"sl":0}]},"hs":0,"ip":"119.137.195.73","ls":0,"preview":1186,"s":"o","sfl":{"cnt":0},"tm":,"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":,"fst":5,"fvkey":"EBB1F5C7B5100A3DAE3FF9D0AAE3DA6670594D507B02AD489CF21D2868B0803B76F7434CE51B5C70D75554D68ED24A49EE3DE4791E0BA58444A77756FA7CBC6FB1B3E579F44F87AFB1CB79E8522A4A5EDC1C842A9EF7536E090EBD018BB2","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":"vhot2.qqvideo./AuRJoSSIabzpOb1RsXSviFl-nYwRDSZoFU5OpwBhfrAk/","vt":200,"dtc":0,"dt":2},{"url":"vhot2.qqvideo./AuRJoSSIabzpOb1RsXSviFl-nYwRDSZoFU5OpwBhfrAk/","vt":200,"dtc":0,"dt":2},{"url":"vhot2.qqvideo./AuRJoSSIabzpOb1RsXSviFl-nYwRDSZoFU5OpwBhfrAk/","vt":200,"dtc":0,"dt":2},{"url":"/","vt":0,"dtc":0,"dt":2}]},"vh":272,"vid":"b0136et5ztz","videotype":27,"vr":0,"vst":2,"vw":480,"wh":1.7647059,"wl":{"wi":[]}}]}};

需要的视频播放地址的格式是这样的

url + fn + ' vkey=' + fvkey

我需要的是用户可以在后台发布时候只需要复制视频链接填入即可

vedio 是腾讯播放地址例如:  所以稍加改造后,代码如下

function getVideoInfo(vedio) {
 if (!vedio) return
 var vid = vedio.substring(vedio.lastIndexOf('/') + 1, vedio.lastIndexOf('html') - 1);
 var that = this;
 var urlString = '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 data = JSON.parse(dataJson);
 var fileName = data['vl']['vi'][0]['fn'];
 var fvkey = data['vl']['vi'][0]['fvkey'];
 var host = data['vl']['vi'][0]['ul']['ui'][2]['url']
 that.setData({
 videoUrl: host + fileName + ' vkey=' + fvkey
 }

生成的videoUrl即是我需要的最终可以直接插入播放的视频

最后写入wxml

 view 
 video src='{{videoUrl}}' bindplay='playVideo' id="myVideo" /video 
 view 建议WIFI环境下播放 /view 
 /view 

在小程序中使用发现 需要绑定授权域名p>

//腾讯视频获取实际播放放地址
function getVideoInfo($video){
 $vid = "";
 //正则表达式截取vid
 )/i",$video, $vid);
 $vid = $vid[1][0];
 $urlString = 'getinfo otype=json appver=3.2.19.333 platform=11 defnpayver=1 vid='.$vid;
 $res = fopen_url($urlString);
 //字符串截取json
 $json = str_replace("QZOutputJson=","",$res);
 $json = str_replace("}}]}};","}}]}}",$json);
 //json转换为数组
 $json = json_decode($json,true);
 $fileName = $json['vl']['vi'][0]['fn'];
 $fvkey = $json['vl']['vi'][0]['fvkey'];
 $host = $json['vl']['vi'][0]['ul']['ui'][2]['url'];
 $url = $host.$fileName.' vkey='.$fvkey;
 return $url;
 获取远程文件内容
 @param $url 文件http地址
function fopen_url($url)
 if (function_exists('file_get_contents')) {
 $file_content = @file_get_contents($url);
 } elseif (ini_get('allow_url_fopen') ($file = @fopen($url, 'rb'))){
 $i = 0;
 while (!feof($file) $i++ 1000) {
 $file_content .= strtolower(fread($file, 4096));
 fclose($file);
 } elseif (function_exists('curl_init')) {
 $curl_handle = curl_init();
 curl_setopt($curl_handle, CURLOPT_URL, $url);
 curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT,2);
 curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER,1);
 curl_setopt($curl_handle, CURLOPT_FAILONERROR,1);
 curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Trackback Spam Check'); //引用垃圾邮件检查
 $file_content = curl_exec($curl_handle);
 curl_close($curl_handle);
 } else {
 $file_content = '';
 return $file_content;
}

因此在小程序接口上我们使用getVideoInfo()方法来转换视频地址就行了

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持凡科。


推荐阅读

报名工具小程序_微信小程序嵌入腾讯视频源过程

手机微信微信小程序置入腾迅视頻源全过程详细说明 本文关键详细介绍了手机微信微信小程序置入腾迅视頻源全过程详细说明,原文中根据实例编码详细介绍的十分详尽,对大伙儿...

2021-01-07
广州凡科互联网科技股份有限公司招聘网销(地

招聘人数:7职位信息岗位职责:1.利用微信进行公司产品的营销及推广,及时回复客户的咨询问题并促成交易2.了解和收集网络上各同行及竞争产品的动态信息。3.通过网络进行客户资源...

2021-01-07
网站的安全防护措施有哪些?

在安全性行业,存有多种多样种类的安全防护对策。除开选用登陆密码技术性的安全防护对策以外,也有下列别的种类的安全防护对策: ①物理学安全性。防盗锁或别的物理学浏览操纵...

2021-01-07
广州凡科互联网科技股份有限公司招聘广告投放

招聘人数:21职位信息岗位职责:1、负责在搜索引擎和信息流各大平台(百度、360、搜狗、今日头条等)投放广告;2、负责推广后台管理工作,包括账户规划、筛选关键词、调价等;...

2021-01-07
南宁企业网站建设模板-郑州信网企业网站建设技

企业介绍 企业创立于2001年九月份,是技术专业出示互连网服务、手机软件开发设计及系统软件集成化的技术性型公司。企业主营业务业务流程涉及到:企业网站建设,网站新项目业务...

2021-01-07
广州凡科互联网科技股份有限公司招聘脚本文案

招聘人数:29职位信息岗位职责:1、独立撰稿及制作脚本,擅长创意策划2、文笔功力深厚,不拘一格的文字表达方式3、概括架构,在繁杂的事物中快速找到规律,提炼主旨4、配合团队...

2021-01-07
X

400-8700-61718720358503
企业邮箱2639601583@qq.com
官方微信