This commit is contained in:
parent
2c8f281a0f
commit
aa17766689
|
|
@ -127,24 +127,40 @@ const Meeting: React.FC = () => {
|
||||||
enableCamera: true
|
enableCamera: true
|
||||||
})
|
})
|
||||||
await getRoomUser()
|
await getRoomUser()
|
||||||
setTimeout(() => {
|
setTimeout(async () => {
|
||||||
agora.setupLocalVideo({
|
let view = document.getElementById(`video-${info.localUid}`) as HTMLElement;
|
||||||
uid: Number(info.localUid),
|
if (view && !view.getAttribute('load')) {
|
||||||
view: document.getElementById(`video-${info.localUid}`) as HTMLElement,
|
await agora.setupLocalVideo({
|
||||||
channelId: info.channelId,
|
uid: Number(info.localUid),
|
||||||
sourceType: VideoSourceType.VideoSourceCameraPrimary,
|
view,
|
||||||
})
|
channelId: info.channelId,
|
||||||
|
sourceType: VideoSourceType.VideoSourceCameraPrimary,
|
||||||
|
})
|
||||||
|
view.setAttribute('load', 'true')
|
||||||
|
}
|
||||||
|
if (String(info.localUid).length === 9) {
|
||||||
|
await agora.setupLocalVideo({
|
||||||
|
uid: Number(info.localUid),
|
||||||
|
view: document.getElementById(`look-video`) as HTMLElement,
|
||||||
|
channelId: info.channelId,
|
||||||
|
sourceType: VideoSourceType.VideoSourceScreen,
|
||||||
|
})
|
||||||
|
}
|
||||||
getShowUser();
|
getShowUser();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
},
|
},
|
||||||
onUserJoined: async (info: any, remoteUid: any, _elapsed: any) => {
|
onUserJoined: async (info: any, remoteUid: any, _elapsed: any) => {
|
||||||
await getRoomUser()
|
await getRoomUser()
|
||||||
setTimeout(() => {
|
setTimeout(async () => {
|
||||||
agora.setupRemoteVideoJoin({
|
let view = document.getElementById(`video-${remoteUid}`) as HTMLElement;
|
||||||
uid: Number(remoteUid),
|
if (view && !view.getAttribute('load')) {
|
||||||
view: document.getElementById(`video-${remoteUid}`) as HTMLElement,
|
await agora.setupRemoteVideoJoin({
|
||||||
channelId: info.channelId,
|
uid: Number(remoteUid),
|
||||||
})
|
view,
|
||||||
|
channelId: info.channelId,
|
||||||
|
})
|
||||||
|
view.setAttribute('load', 'true')
|
||||||
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
},
|
},
|
||||||
onUserOffline: async (info: any, remoteUid: any, _reason: any) => {
|
onUserOffline: async (info: any, remoteUid: any, _reason: any) => {
|
||||||
|
|
@ -153,6 +169,14 @@ const Meeting: React.FC = () => {
|
||||||
view: document.getElementById(`video-${remoteUid}`) as HTMLElement,
|
view: document.getElementById(`video-${remoteUid}`) as HTMLElement,
|
||||||
channelId: info.channelId,
|
channelId: info.channelId,
|
||||||
})
|
})
|
||||||
|
if (String(info.localUid).length === 9) {
|
||||||
|
await agora.setupRemoteVideo({
|
||||||
|
uid: Number(remoteUid),
|
||||||
|
view: document.getElementById(`look-video`) as HTMLElement,
|
||||||
|
channelId: info.channelId,
|
||||||
|
sourceType: VideoSourceType.VideoSourceScreen,
|
||||||
|
})
|
||||||
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getRoomUser()
|
getRoomUser()
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,9 @@ const agora = {
|
||||||
onUserOffline: async (info: any, remoteUid: any, reason: any) => {
|
onUserOffline: async (info: any, remoteUid: any, reason: any) => {
|
||||||
await onUserOffline(info, remoteUid, reason)
|
await onUserOffline(info, remoteUid, reason)
|
||||||
},
|
},
|
||||||
|
// onConnectionStateChanged: (connection: any, state: any, reason: any) => {
|
||||||
|
// console.log(connection, reason)
|
||||||
|
// },
|
||||||
// // 视频发布状态改变回调
|
// // 视频发布状态改变回调
|
||||||
// onVideoPublishStateChanged: (source: any, channel: any, oldState: any, newState: any, elapseSinceLastState: any) => {
|
// onVideoPublishStateChanged: (source: any, channel: any, oldState: any, newState: any, elapseSinceLastState: any) => {
|
||||||
// if (newState === 1) {
|
// if (newState === 1) {
|
||||||
|
|
@ -150,7 +153,8 @@ const agora = {
|
||||||
// 摄像头采集
|
// 摄像头采集
|
||||||
setCameraCapture: () => {
|
setCameraCapture: () => {
|
||||||
agora.stopScreenCapture()
|
agora.stopScreenCapture()
|
||||||
// rtcEngine.destroyRendererByConfig(option.sourceType, option.channelId, option.account)
|
const user = JSON.parse(storage.getItem('user') as string)
|
||||||
|
rtcEngine.destroyRendererByConfig(VideoSourceType.VideoSourceScreen, option.channelId, Number(user.screenShareId))
|
||||||
agora.setupLocalVideo({
|
agora.setupLocalVideo({
|
||||||
uid: Number(option.uid),
|
uid: Number(option.uid),
|
||||||
view: document.getElementById(`video-${option.uid}`),
|
view: document.getElementById(`video-${option.uid}`),
|
||||||
|
|
@ -173,11 +177,11 @@ const agora = {
|
||||||
// 共享屏幕采集
|
// 共享屏幕采集
|
||||||
setDesktopCapturerVideo: async (targetSource: any) => {
|
setDesktopCapturerVideo: async (targetSource: any) => {
|
||||||
// await rtcEngine.stopCameraCapture(option.sourceType)
|
// await rtcEngine.stopCameraCapture(option.sourceType)
|
||||||
// rtcEngine.destroyRendererByConfig(option.sourceType, option.channelId, option.account)
|
|
||||||
const user = JSON.parse(storage.getItem('user') as string)
|
const user = JSON.parse(storage.getItem('user') as string)
|
||||||
|
rtcEngine.destroyRendererByConfig(VideoSourceType.VideoSourceScreen, option.channelId, Number(user.screenShareId))
|
||||||
rtcEngine.joinChannelEx(
|
rtcEngine.joinChannelEx(
|
||||||
option.token,
|
option.token,
|
||||||
{ channelId: option.channelId, localUid: Number(user.uid) },
|
{ channelId: option.channelId, localUid: Number(user.screenShareId) },
|
||||||
{
|
{
|
||||||
autoSubscribeAudio: false,
|
autoSubscribeAudio: false,
|
||||||
autoSubscribeVideo: false,
|
autoSubscribeVideo: false,
|
||||||
|
|
@ -187,12 +191,6 @@ const agora = {
|
||||||
publishScreenTrack: true,
|
publishScreenTrack: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
await agora.setupLocalVideo({
|
|
||||||
uid: Number(user.uid),
|
|
||||||
view: document.getElementById(`look-video`),
|
|
||||||
channelId: option.channelId,
|
|
||||||
sourceType: VideoSourceType.VideoSourceScreen,
|
|
||||||
})
|
|
||||||
agora.stopScreenCapture();
|
agora.stopScreenCapture();
|
||||||
if (
|
if (
|
||||||
targetSource.type ===
|
targetSource.type ===
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue