基础库版本 >= 3.120.0, 小红书 App 版本 >= 8.76 开始支持本方法。
用于预约直播,用户可以通过
handleLiveBooking() {
if (!this.data.trailerId) {
xhs.showToast({ title: '请先获取 trailerId' });
return;
}
let _this = this;
xhs.reserveLivestream({
trailerId: String(_this.data.trailerId),
success(res) {
console.log('reserveLivestream success', res);
_this.setData({ trailerInfo: '获取 trailerInfo 信息成功:' + JSON.stringify(res) });
},
fail(err) {
console.log('reserveLivestream fail', err);
_this.setData({ trailerInfo: '获取 trailerInfo 信息失败:' + JSON.stringify(err) });
}
});
}
属性名 | 类型 | 必填 | 说明 | 最低支持版本 |
|---|---|---|---|---|
| trailerId | string | 是 | 直播预约 ID | 3.120.x |
| success | Function | 否 | 接口调用成功的回调函数 | 3.120.x |
| fail | Function | 否 | 接口调用失败的回调函数 | 3.120.x |
| complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | 3.120.x |
属性 | 类型 | 说明 | 最低支持版本 |
|---|---|---|---|
| errMsg | string | reserveLivestream:ok | 3.120.x |
| status | number | 调用状态码 status | 3.120.x |
属性 | 类型 | 说明 | 最低支持版本 |
|---|---|---|---|
| errMsg | string | reserveLivestream:fail + 错误信息 | 3.120.x |
基础库版本>= 3.120.0,小红书 App 版本 >= 8.76 开始支持本方法。
用于跳转直播间,用户可以通过
handleLiveJump() {
if (!this.data.roomId) {
xhs.showToast({ title: '请先获取 roomId' });
return;
}
let _this = this;
xhs.openLivestream({
roomId: String(_this.data.roomId),
success(res) {
console.log('openLivestream success', res);
_this.setData({ jumpInfo: `跳转直播间成功[${_this.data.roomId}]: ${JSON.stringify(res)}` });
},
fail(err) {
console.log('openLivestream fail', err);
_this.setData({ jumpInfo: `跳转直播间失败[${_this.data.roomId}]: ${JSON.stringify(err)}` });
}
});
}
属性名 | 类型 | 必填 | 说明 | 最低支持版本 |
|---|---|---|---|---|
| roomId | string | 是 | 直播间 ID | 3.120.x |
| success | Function | 否 | 接口调用成功的回调函数 | 3.120.x |
| fail | Function | 否 | 接口调用失败的回调函数 | 3.120.x |
| complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | 3.120.x |
属性 | 类型 | 说明 | 最低支持版本 |
|---|---|---|---|
| errMsg | string | openLivestream:ok | 3.120.x |
| status | number | 调用状态码 status | 3.120.x |
属性 | 类型 | 说明 | 最低支持版本 |
|---|---|---|---|
| errMsg | string | openLivestream:fail + 错误信息 | 3.120.x |
基础库版本 >= 3.120.0,小红书 App 版本 >= 8.76 开始支持本方法。
用于回放直播,用户可以通过
handleLiveReplay() {
if (!this.data.roomId) {
xhs.showToast({ title: '请先获取 roomId' });
return;
}
let _this = this;
xhs.replayLivestream({
roomId: String(_this.data.roomId),
success(res) {
console.log('replayLivestream success', res);
_this.setData({ replayInfo: `跳转直播间回放成功[${_this.data.roomId}]: ${JSON.stringify(res)}` });
},
fail(err) {
console.log('replayLivestream fail', err);
_this.setData({ replayInfo: `跳转直播间回放失败[${_this.data.roomId}]: ${JSON.stringify(err)}` });
}
});
}
属性名 | 类型 | 必填 | 说明 | 最低支持版本 |
|---|---|---|---|---|
| roomId | string | 是 | 直播间 ID | 3.120.x |
| success | Function | 否 | 接口调用成功的回调函数 | 3.120.x |
| fail | Function | 否 | 接口调用失败的回调函数 | 3.120.x |
| complete | Function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | 3.120.x |
属性 | 类型 | 说明 | 最低支持版本 |
|---|---|---|---|
| errMsg | string | replayLivestream:ok | 3.120.x |
| status | number | 调用状态码 status | 3.120.x |
属性 | 类型 | 说明 | 最低支持版本 |
|---|---|---|---|
| errMsg | string | replayLivestream:fail + 错误信息 | 3.120.x |