This commit is contained in:
parent
92ffd98bbc
commit
1ae5731b82
|
|
@ -17,7 +17,6 @@ const option: any = {
|
||||||
token: '',
|
token: '',
|
||||||
channelId: '',
|
channelId: '',
|
||||||
userid: '',
|
userid: '',
|
||||||
sourceType: '',
|
|
||||||
}
|
}
|
||||||
let iMediaRecorder: any = '';
|
let iMediaRecorder: any = '';
|
||||||
let rtcEngine: any = '';
|
let rtcEngine: any = '';
|
||||||
|
|
@ -117,16 +116,29 @@ const agora = {
|
||||||
storage.setItem('isJoin', false)
|
storage.setItem('isJoin', false)
|
||||||
},
|
},
|
||||||
// 加入频道
|
// 加入频道
|
||||||
joinChannel: () => {
|
joinChannel: (bool: boolean) => {
|
||||||
|
// false 摄像头 true 共享屏幕
|
||||||
|
if (bool) {
|
||||||
rtcEngine.joinChannel(option.token, option.channelId, option.userid, {
|
rtcEngine.joinChannel(option.token, option.channelId, option.userid, {
|
||||||
channelProfile: ChannelProfileType.ChannelProfileLiveBroadcasting, //设置频道场景为直播场景
|
channelProfile: ChannelProfileType.ChannelProfileLiveBroadcasting, //设置频道场景为直播场景
|
||||||
clientRoleType: ClientRoleType.ClientRoleBroadcaster, //用户角色 1主播 2观众
|
clientRoleType: ClientRoleType.ClientRoleBroadcaster, //用户角色 1主播 2观众
|
||||||
publishMicrophoneTrack: true, //设置是否发布麦克风采集到的音频
|
publishMicrophoneTrack: true, //设置是否发布麦克风采集到的音频
|
||||||
publishCameraTrack: true, //设置是否发布摄像头采集的视频
|
publishCameraTrack: false, //设置是否发布摄像头采集的视频
|
||||||
publishScreenTrack: true, //设置是否发布屏幕采集的视频
|
publishScreenTrack: true, //设置是否发布屏幕采集的视频
|
||||||
autoSubscribeAudio: true, //设置是否自动订阅所有音频流
|
autoSubscribeAudio: true, //设置是否自动订阅所有音频流
|
||||||
autoSubscribeVideo: true, //设置是否自动订阅所有视频流
|
autoSubscribeVideo: true, //设置是否自动订阅所有视频流
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
rtcEngine.joinChannel(option.token, option.channelId, option.userid, {
|
||||||
|
channelProfile: ChannelProfileType.ChannelProfileLiveBroadcasting, //设置频道场景为直播场景
|
||||||
|
clientRoleType: ClientRoleType.ClientRoleBroadcaster, //设置用户角色为主播;如果要将用户角色设置为观众,保持默认值即可
|
||||||
|
publishMicrophoneTrack: true, //发布麦克风采集的音频
|
||||||
|
publishCameraTrack: true, //发布摄像头采集的视频
|
||||||
|
publishScreenTrack: false, //设置是否发布屏幕采集的视频
|
||||||
|
autoSubscribeAudio: true, //自动订阅所有音频流
|
||||||
|
autoSubscribeVideo: true, //自动订阅所有视频流
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// 停止共享屏幕
|
// 停止共享屏幕
|
||||||
stopScreenCapture: () => {
|
stopScreenCapture: () => {
|
||||||
|
|
@ -149,7 +161,7 @@ const agora = {
|
||||||
option.token = data.token;
|
option.token = data.token;
|
||||||
option.channelId = data.channelId;
|
option.channelId = data.channelId;
|
||||||
option.userid = Number(data.userid);
|
option.userid = Number(data.userid);
|
||||||
agora.joinChannel()
|
agora.joinChannel(false)
|
||||||
},
|
},
|
||||||
// 桌面捕获音频和视频的媒体源的信息
|
// 桌面捕获音频和视频的媒体源的信息
|
||||||
getDesktopCapturerVideo: async () => {
|
getDesktopCapturerVideo: async () => {
|
||||||
|
|
@ -159,7 +171,6 @@ const agora = {
|
||||||
setDesktopCapturerVideo: (targetSource: any, sourceType: number) => {
|
setDesktopCapturerVideo: (targetSource: any, sourceType: number) => {
|
||||||
// rtcEngine.stopCameraCapture(VideoSourceType.VideoSourceCamera);
|
// rtcEngine.stopCameraCapture(VideoSourceType.VideoSourceCamera);
|
||||||
agora.stopScreenCapture();
|
agora.stopScreenCapture();
|
||||||
// rtcEngine.destroyRendererByConfig(VideoSourceType.VideoSourceCameraPrimary, option.channelId, option.account)
|
|
||||||
if (
|
if (
|
||||||
targetSource.type ===
|
targetSource.type ===
|
||||||
ScreenCaptureSourceType.ScreencapturesourcetypeScreen
|
ScreenCaptureSourceType.ScreencapturesourcetypeScreen
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue