const RtcClient = tt.createRtcRoomContext({
this.RtcClient = RtcClient;
const { screenWidth } = tt.getSystemInfoSync();
this.screenWidth = screenWidth;
const startAudioCapture = async () => {
return new Promise((resolve, reject) => {
app.RtcClient.changeAudioCapture({
const stopAudioCapture = async () => {
return new Promise((resolve, reject) => {
app.RtcClient.changeAudioCapture({
const startVideoCapture = async () => {
return new Promise((resolve, reject) => {
app.RtcClient.changeVideoCapture({
console.log('startVideoCapture success');
const stopVideoCapture = async () => {
return new Promise((resolve, reject) => {
app.RtcClient.changeVideoCapture({
const joinRoom = async (config) => {
console.log('joinRoom config', config);
return new Promise((resolve, reject) => {
app.RtcClient.joinRtcRoom({
const leaveRoom = async (roomId) => {
return new Promise((resolve, reject) => {
app.RtcClient.exitRtcRoom({
async handleJoin(options) {
await RtcClient.startVideoCapture().catch((err) => {
console.error('startVideoCapture', err);
tt.showToast({ title: '请打开相机权限!', icon: 'fail' });
await RtcClient.stopVideoCapture();
await RtcClient.startAudioCapture().catch((err) => {
console.error('startAudioCapture', err);
tt.showToast({ title: '请打开麦克风权限!', icon: 'fail' });
await RtcClient.publishStream('audio');
await RtcClient.stopAudioCapture();
await RtcClient.unPublishStream('audio');
token: decodeURIComponent(options.token),
await RtcClient.joinRoom({
roomId: `call_${this.data.roomId}`,
userId: this.data.userId,
tt.showToast({ title: '进房成功' });
console.log(' joinRtcRoom fail ', err);
tt.showToast({ title: '进房失败', icon: 'fail' });