添加容错

This commit is contained in:
luyuan 2020-10-29 15:51:38 +08:00
parent 24e5c4c50c
commit f6c95e9525
Signed by: theluyuan
GPG Key ID: A7972FD973317FF3

View File

@ -239,45 +239,6 @@ export default defineComponent({
});
}
async function pingmu(){
const result = await TRTC.checkSystemRequirements()
console.log(result,11111)
if(!result) {
message.error("您的浏览器不支持屏幕分享请下载新版chrome");
return ;
}
localStream = TRTC.createStream({ userid: store.state.userinfo.memberid, audio: true, screen: true });
const id = localStream.getId();
await localStream
.initialize()
.catch((error: string) => {
console.error('初始化本地流失败 ' + error);
message.error("请选择分享的内容")
setTimeout(()=>{
pingmu()
}, 1000)
})
.then(() => {
console.log('初始化本地流成功');
client
.publish(localStream)
.catch((error: string) => {
console.log('本地流发布失败 ' + error);
})
.then(() => {
const el = document.querySelector("#local_stream");
if(el){
el.innerHTML = ""
}
localStream.play('local_stream');
console.log('本地流发布成功');
console.log(id , 123)
});
});
}
async function shexiang(){
localStream = TRTC.createStream({ userId: store.state.userinfo.memberid, audio: true, video: true });
const id = localStream.getId();
@ -304,6 +265,48 @@ export default defineComponent({
});
});
}
async function pingmu(){
const result = await TRTC.checkSystemRequirements()
console.log(result,11111)
if(!result) {
message.error("您的浏览器不支持屏幕分享请下载新版chrome");
shexiang()
return ;
}
localStream = TRTC.createStream({ userid: store.state.userinfo.memberid, audio: true, screen: true });
const id = localStream.getId();
await localStream
.initialize()
.catch((error: string) => {
console.error('初始化本地流失败 ' + error);
message.error("请选择分享的内容")
setTimeout(()=>{
shexiang()
}, 1000)
})
.then(() => {
console.log('初始化本地流成功');
client
.publish(localStream)
.catch((error: string) => {
console.log('本地流发布失败 ' + error);
})
.then(() => {
const el = document.querySelector("#local_stream");
if(el){
el.innerHTML = ""
}
localStream.play('local_stream');
console.log('本地流发布成功');
console.log(id , 123)
});
});
}
async function init(fun: any, userSig: string): Promise<void>{
console.log(userSig)
const el = document.querySelector("#local_stream");