腾讯云视频Node.js SDK
Table of Contents generated with DocToc
国际惯例:
npm install wqcloud-video --save
# 或
yarn add wqcloud-video
公共参数:
var options = {
appid: '',
appkey: '',
};
这是一个示例传入的参数:
{
t: 10, // 会自动根据当前时间向后推10s, 如果不传,默认值为当前时间
channel_id: 'test', // 会根据值的类型进行判断,变成 Param.s.channel_id
status: 0 // 会根据值的类型进行判断,变成 Param.n.status
}
const { getPushUrl } = require('wqcloud-video');
console.log(
getPushUrl({
bizid: 8888,
streamid: 'test',
key: 'aabbccdd001122333444', // 注意,这里是 推流防盗链Key
expires: 3600
})
);
// rtmp://8888.livepush.myqcloud.com/live/8888_test?bizid=8888&txTime=5943874C&txSecret=ffc8cc832447ea92335df69970e6ce25
const { getPlayUrl } = require('wqcloud-video');
console.log(
getPlayUrl({
bizid: 8888,
streamid: 'test'
})
);
//{ rtmp: 'rtmp://8888.liveplay.myqcloud.com/live/8888_test',
// flv: 'http://8888.liveplay.myqcloud.com/live/8888_test.flv',
// m3u8: 'http://8888.liveplay.myqcloud.com/live/8888_test.m3u8' }
设置直播状态示例:
// API调用地址为: http://fcgi.video.qcloud.com/common_access
const { fcgi } = require('wqcloud-video');
const qcloud = fcgi({
appid: '1234567890',
appkey: 'aabbccddeeffgghhiijjkkmmnnooppqq' // 注意,这里是 API鉴权Key
});
qcloud.Live_Channel_SetStatus({
channel_id: '8888_test',
status: 1
}).then(console.log).catch(console.err);
查询直播状态示例:
const { fcgi } = require('wqcloud-video');
const qcloud = fcgi({
appid: '1234567890',
appkey: 'aabbccddeeffgghhiijjkkmmnnooppqq'
});
qcloud.Live_Channel_GetStatus({
channel_id: '8888_test'
}).then(console.log).catch(console.err);
查询指定直播流的推流和播放信息示例:
// API调用地址为: http://statcgi.video.qcloud.com/common_access
const { statcgi } = require('wqcloud-video');
const qcloud = statcgi({
appid: '1234567890',
appkey: 'aabbccddeeffgghhiijjkkmmnnooppqq'
});
qcloud.Get_LiveStat({
stream_id: '8888_test'
}).then((data) => {
console.log(JSON.stringify(data, null, 2));
}).catch(console.err);
TODO: 下一个版本进行完善
- vod(点播): https://www.qcloud.com/document/product/266/8757
- lvb(直播): https://www.qcloud.com/document/product/267/5956
- 您可能还会用到
WQcloud
完整SDK: https://github.com/willin/wqcloud
MIT
通过支付宝捐赠: