优化音视频通话

This commit is contained in:
cc
2026-02-06 18:00:19 +08:00
parent 946cff6c52
commit 6a655a302a

View File

@@ -130,7 +130,45 @@ export const useUserStore = defineStore('user', () => {
console.log(tencentUserSig.value.appKey, '====')
await connectIM()
// #endif
// #ifdef APP-PLUS
// CallLib.init({})
CallLib.onCallReceived(res => {
console.log(
'Engine:OnCallReceived=>' + '监听通话呼入, 目标id=>',
res.data
)
console.log('res: ',res.data);
if (res.data.targetId) {
// let url = res.data.mediaType == 0 ? "" : "/pages/room/room"
uni.setStorageSync('room-parameters', {
callType: 'in',
mediaType: res.data.mediaType === 0 ? 'audio' : 'video'
});
uni.navigateTo("/pages/room/incom", {
type: res.data.extra,
callType: 'in',
mediaType: res.data.mediaType == 0 ? "audio" : "video",
userID: res.data.mine.userId // 对方的用户id
})
}
})
/** 挂断电话 */
CallLib.onCallDisconnected(res => {
console.log(
'Engine:OnCallDisconnected=>' + '挂断成功, 挂断原因=>',
res.data.reason
)
uni.navigateBack()
})
CallLib.onError(res => {
console.log('通话过程中,发生异常,异常原因=>', res.data.reason)
uni.navigateBack()
})
// #endif
}
//连接融云IM
@@ -178,45 +216,7 @@ export const useUserStore = defineStore('user', () => {
// })
console.log('连接已存在,不需要再连接')
}
// #ifdef APP-PLUS
// CallLib.init({})
CallLib.onCallReceived(res => {
console.log(
'Engine:OnCallReceived=>' + '监听通话呼入, 目标id=>',
res.data
)
console.log('res: ',res.data);
if (res.data.targetId) {
// let url = res.data.mediaType == 0 ? "" : "/pages/room/room"
uni.setStorageSync('room-parameters', {
callType: 'in',
mediaType: res.data.mediaType === 0 ? 'audio' : 'video'
});
navigateTo("/pages/room/incom", {
type: res.data.extra,
callType: 'in',
mediaType: res.data.mediaType == 0 ? "audio" : "video",
userID: res.data.mine.userId // 对方的用户id
})
}
})
/** 挂断电话 */
CallLib.onCallDisconnected(res => {
console.log(
'Engine:OnCallDisconnected=>' + '挂断成功, 挂断原因=>',
res.data.reason
)
uni.navigateBack()
})
CallLib.onError(res => {
console.log('通话过程中,发生异常,异常原因=>', res.data.reason)
uni.navigateBack()
})
// #endif
}
}
let code = await imEngine.value.connect(