Hello Michael ! Thanks for the quick reply : )
- For now im using latest SDK version which is v5.5.12509.0330
-
- Code below
namespace Common
{
public class ZoomManager
{
private static ZoomManager m_Instance;
public static ZoomManager Instance
{
get
{
if (m_Instance == null)
{
m_Instance = new ZoomManager();
}
return m_Instance;
}
}
//public static ulong ZOOM_MEETING_ID = ;
//public static string ZOOM_MEETING_PWD = "";
//public static string ZOOM_USER_ID = "";
//public static string ZOOM_USER_ZAK = "";
//public static string ZOOM_USER_NAME = "Hogwarts";
public static bool ZOOM_AUDIO_OFF = false;
public static bool ZOOM_VIDEO_OFF = false;
public void Initialize()
{
InitParam param = new InitParam();
param.config_opts.optionalFeatures = (1 << 5);
param.web_domain = "https://zoom.us";
SDKError initializeError = CZoomSDKeDotNetWrap.Instance.Initialize(param);
if (SDKError.SDKERR_SUCCESS == initializeError)
{
// Console.WriteLine("Zoom Initialize: Success");
}
else
{
RequestManager.ReportError("Zoom", $"Zoom Initialize: {initializeError}");
//Console.WriteLine($"Zoom Initialize: {initializeError}");
}
}
public void Deinitialize()
{
//Console.WriteLine("Zoom Deinitialize");
CZoomSDKeDotNetWrap.Instance.CleanUp();
m_Instance = null;
}
public void Auth(ZoomInfo zoomInfo)
{
RegisterZoomAuthCallbacks();
RegisterMeetingCallbacks();
InitializeCamera();
InitializeAudio();
if (zoomInfo == null) return;
AuthParam authParam = new AuthParam
{
appKey = zoomInfo.appKey,
appSecret = zoomInfo.appSecret
};
SDKError authResult = CZoomSDKeDotNetWrap.Instance.GetAuthServiceWrap().SDKAuth(authParam);
if (authResult == SDKError.SDKERR_SUCCESS)
{
Console.WriteLine("authResult: Success");
//Hide();
}
else
{
RequestManager.ReportError("Zoom", $"Zoom Auth: {authResult}");
}
}
private void RegisterMeetingCallbacks()
{
CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().Add_CB_onMeetingStatusChanged(OnMeetingStatusChanged);
//CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingConfiguration().EnableInputMeetingPasswordDlg(true);
CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingConfiguration().Add_CB_onInputMeetingPasswordAndScreenNameNotification(OnInputMeetingPasswordAndScreenNameNotification);
CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingParticipantsController().Add_CB_onHostChangeNotification(OnHostChangeNotification);
CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingParticipantsController().Add_CB_onLowOrRaiseHandStatusChanged(OnLowOrRaiseHandStatusChanged);
CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingParticipantsController().Add_CB_onUserJoin(OnUserJoin);
CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingParticipantsController().Add_CB_onUserLeft(OnUserLeft);
CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingParticipantsController().Add_CB_onUserNameChanged(OnUserNameChanged);
CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingAudioController().Add_CB_onUserAudioStatusChange(OnUserAudioStatusChange);
}
private void RegisterZoomAuthCallbacks()
{
CZoomSDKeDotNetWrap.Instance.GetAuthServiceWrap().Add_CB_onAuthenticationReturn(OnAuthenticationReturn);
CZoomSDKeDotNetWrap.Instance.GetAuthServiceWrap().Add_CB_onLoginRet(OnLoginRet);
CZoomSDKeDotNetWrap.Instance.GetAuthServiceWrap().Add_CB_onLogout(OnLogout);
}
private void OnUserAudioStatusChange(IUserAudioStatusDotNetWrap[] lstAudioStatusChange)
{
//foreach (var status in lstAudioStatusChange)
//{
// //ErrorLogger.Instance.LogDebug("OnUserAudioStatusChange", status.GetUserId() + ": " + status.GetStatus() + " type: " + status.GetAudioType() );
//}
}
private void OnMeetingStatusChanged(MeetingStatus status, int iResult)
{
switch (status)
{
case MeetingStatus.MEETING_STATUS_CONNECTING:
{
//var uiWrapper = CZoomSDKeDotNetWrap.Instance.GetCustomizedUIMgrWrap();
Console.WriteLine("MEETING_STATUS_CONNECTING");
InitializeCamera();
InitializeAudio();
//Console.WriteLine(uiWrapper.HasLicense());
}
break;
case MeetingStatus.MEETING_STATUS_LOCKED:
Console.WriteLine("MEETING_STATUS_LOCKED");
break;
case MeetingStatus.MEETING_STATUS_IN_WAITING_ROOM:
Console.WriteLine("MEETING_STATUS_IN_WAITING_ROOM");
break;
case MeetingStatus.MEETING_STATUS_JOIN_BREAKOUT_ROOM:
Console.WriteLine("MEETING_STATUS_JOIN_BREAKOUT_ROOM");
break;
case MeetingStatus.MEETING_STATUS_IDLE:
Console.WriteLine("MEETING_STATUS_IDLE");
break;
case MeetingStatus.MEETING_STATUS_INMEETING:
Console.WriteLine("MEETING_STATUS_INMEETING");
break;
case MeetingStatus.MEETING_STATUS_UNLOCKED:
Console.WriteLine("MEETING_STATUS_UNLOCKED");
break;
case MeetingStatus.MEETING_STATUS_ENDED:
Console.WriteLine("MEETING_STATUS_ENDED");
break;
case MeetingStatus.MEETING_STATUS_FAILED:
Console.WriteLine("MEETING_STATUS_FAILED");
break;
default:
break;
}
}
private void OnUserJoin(Array lstUserID)
{
if (null == lstUserID) return;
for (int i = lstUserID.GetLowerBound(0); i <= lstUserID.GetUpperBound(0); i++)
{
uint userid = (uint)lstUserID.GetValue(i);
IUserInfoDotNetWrap user = CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingParticipantsController().GetUserByUserID(userid);
if (null != user)
{
string joinedUserName = user.GetUserNameW();
Console.Write($"User joined: {joinedUserName}");
}
}
}
private void OnUserLeft(Array lstUserID)
{
Console.WriteLine($"Users left: {lstUserID}");
}
private void OnHostChangeNotification(uint userId)
{
Console.WriteLine($"Meeting host changed to {userId}");
}
private void OnLowOrRaiseHandStatusChanged(bool bLow, UInt32 userId)
{
Console.WriteLine($"User {userId} raised hand: {bLow}");
}
private void OnUserNameChanged(UInt32 userId, string userName)
{
Console.WriteLine($"User {userId} changed userName to {userName}");
}
private void OnAuthenticationReturn(AuthResult authResult) {
if (AuthResult.AUTHRET_SUCCESS == authResult)
{
Console.WriteLine($"onAuthenticationReturn: Success");
}
else
{
RequestManager.ReportError("Zoom", "Zoom Auth Failure: " + authResult);
}
}
private void OnLoginRet(LOGINSTATUS ret, IAccountInfo pAccountInfo)
{
Console.WriteLine($"OnLoginReturn: {ret} with displayName: {pAccountInfo?.GetDisplayName()}");
}
private void OnLogout()
{
Console.WriteLine($"OnLogout");
}
private void OnComputerCamDeviceChanged(ICameraInfoDotNetWrap[] newCameras)
{
Console.WriteLine($"new cameras {newCameras}");
}
private void OnInputMeetingPasswordAndScreenNameNotification(IMeetingPasswordAndScreenNameHandler handler)
{
Console.WriteLine("onInputMeetingPasswordAndScreenNameNotification");
//Console.WriteLine(handler.GetRequiredInfoType());
var result = handler.InputMeetingPasswordAndScreenName(ViewModel.Singleton.LiveSession?.ZoomInfo?.meetingPassword ?? "", TeacherToken.Current?.Nickname ?? "");
//Console.WriteLine(result);
}
public void JoinMeeting(ZoomInfo zoomInfo, bool withoutLogin = true)
{
ScanDevices();
if (zoomInfo == null) return;
JoinParam param = new JoinParam();
if (withoutLogin)
{
JoinParam4WithoutLogin join_api_param = new JoinParam4WithoutLogin
{
meetingNumber = zoomInfo.meetingId,
userName = zoomInfo.displayName,
isVideoOff = ZOOM_VIDEO_OFF,
isAudioOff = ZOOM_AUDIO_OFF,
psw = zoomInfo.meetingPassword,
userZAK = zoomInfo.userZak
};
param.withoutloginJoin = join_api_param;
param.userType = SDKUserType.SDK_UT_WITHOUT_LOGIN;
}
else
{
JoinParam4NormalUser joinParamForUser = new JoinParam4NormalUser
{
meetingNumber = zoomInfo.meetingId,
participantId = zoomInfo.userId,
psw = zoomInfo.meetingPassword,
userName = zoomInfo.displayName,
isVideoOff = ZOOM_VIDEO_OFF,
isAudioOff = ZOOM_AUDIO_OFF
};
param.normaluserJoin = joinParamForUser;
param.userType = SDKUserType.SDK_UT_NORMALUSER;
}
SDKError joinMeetingResult = CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().Join(param);
if (joinMeetingResult == SDKError.SDKERR_SUCCESS)
{
Console.WriteLine("joinMeetingResult: Success");
}
else
{
Console.WriteLine("joinMeetingResult: " + joinMeetingResult);
}
}
public void StartMeeting(ZoomInfo zoomInfo, bool withoutLogin = true)
{
if (zoomInfo == null) return;
StartParam param = new StartParam();
if (withoutLogin)
{
StartParam4WithoutLogin startParam4WithoutLogin = new StartParam4WithoutLogin
{
meetingNumber = zoomInfo.meetingId,
participantId = zoomInfo.userId,
userZAK = zoomInfo.userZak,
userName = zoomInfo.displayName,
isAudioOff = ZOOM_AUDIO_OFF,
isVideoOff = ZOOM_VIDEO_OFF,
zoomuserType = ZoomUserType.ZoomUserType_APIUSER
};
param.withoutloginStart = startParam4WithoutLogin;
param.userType = SDKUserType.SDK_UT_WITHOUT_LOGIN;
}
else
{
StartParam4NormalUser startParam4NormalUser = new StartParam4NormalUser
{
meetingNumber = zoomInfo.meetingId,
participantId = zoomInfo.userId,
isAudioOff = ZOOM_AUDIO_OFF,
isVideoOff = ZOOM_VIDEO_OFF
};
param.normaluserStart = startParam4NormalUser;
param.userType = SDKUserType.SDK_UT_NORMALUSER;
}
SDKError startMeetingResult = CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().Start(param);
if (startMeetingResult == SDKError.SDKERR_SUCCESS)
{
Console.WriteLine("startMeetingResult: Success");
//Hide();
}
else
{
Console.WriteLine("startMeetingResult: " + startMeetingResult);
}
}
public void StopMeeting()
{
SDKError stopRecordingResult = CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().GetMeetingRecordingController().StopCloudRecording();
SDKError leaveMeetingResult = CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().Leave(LeaveMeetingCmd.END_MEETING);
}
public void InitializeCamera()
{
var settings = CZoomSDKeDotNetWrap.Instance.GetSettingServiceWrap().GetVideoSettings();
settings.EnableAlwaysShowNameOnVideo(false);
settings.EnableHDVideo(true);
settings.EnableHideNoVideoUsersOnWallView(true);
settings.EnableAutoTurnOffVideoWhenJoinMeeting(false);
settings.EnableAlwaysUse16v9(true);
}
public void InitializeAudio()
{
var settings = CZoomSDKeDotNetWrap.Instance.GetSettingServiceWrap().GetAudioSettings();
settings.EnableAlwaysMuteMicWhenJoinVoip(false);
settings.EnableAutoJoinAudio(true);
settings.EnableAutoAdjustMic(true);
settings.EnableMicOriginalInput(true);
}
public static string ExtractDeviceCode(string str)
{
if (str == null) return str;
string firstString = @"{";
string lastString = @"}";
int pos1 = str.LastIndexOf(firstString);
int pos2 = str.LastIndexOf(lastString);
if (pos1 == -1 || pos2 == -1 || pos2 <= pos1) return str;
return str.Substring(pos1, pos2 - pos1 + 1);
}
public static string ExtractCameraPid(string str)
{
if (str == null) return str;
string firstString = @"\\?\";
//string lastString = @"{";
int pos1 = str.IndexOf(firstString);
//int pos2 = str.Substring(pos1).IndexOf(lastString);
if (pos1 == -1) return str;
return str.Substring(pos1);
}
public void SetDevices()
{
//Console.WriteLine("HP+");
//Console.WriteLine(HardwarePreferences.Singleton.SelectedVideoCaptureDevice?.Moniker);
//Console.WriteLine(HardwarePreferences.Singleton.SelectedVideoCaptureDevice?.Name);
//Console.WriteLine("HP-");
var videoMoniker = HardwarePreferences.Singleton.SelectedVideoCaptureDevice?.Moniker;
var audioMoniker = HardwarePreferences.Singleton.SelectedAudioCaptureDevice?.Moniker;
if (videoMoniker != null && videoMoniker.Length > 0)
{
var cameraId = ExtractCameraPid(videoMoniker);
//Console.WriteLine("Extracted Camera ID:" + cameraId);
var matchCamera = VideoCaptureDevices.First(camera => camera.Moniker.ToLower().Contains(cameraId.ToLower()));
//Console.WriteLine("Match Camera:" + matchCamera?.Name);
var selectedCamera = matchCamera ?? VideoCaptureDevices.FirstOrDefault();
var videoSettings = CZoomSDKeDotNetWrap.Instance.GetSettingServiceWrap().GetVideoSettings();
var selectCameraResult = videoSettings.SelectCamera(selectedCamera.Moniker);
//Console.WriteLine($"Select camera Result: {selectCameraResult}");
}
//ErrorLogger.Instance.LogDebug("AudioMonikerSettings", audioMoniker);
if (audioMoniker != null && audioMoniker.Length > 0)
{
var audioId = ExtractDeviceCode(audioMoniker);
//ErrorLogger.Instance.LogDebug("extracted audioId", audioId);
//Console.WriteLine("Extracted Mic ID:" + audioId);
var matchAudio = AudioCaptureDevices.First(audio => audio.Moniker.ToLower().Contains(audioId.ToLower()));
//ErrorLogger.Instance.LogDebug("matchAudio", matchAudio.Moniker + " : " + matchAudio.Name);
//Console.WriteLine("Match Audio:" + matchAudio?.Name);
var selectedAudio = matchAudio ?? AudioCaptureDevices.FirstOrDefault();
//ErrorLogger.Instance.LogDebug("selectedAudio ", selectedAudio.Moniker + " : " + selectedAudio.Name);
var audioSettings = CZoomSDKeDotNetWrap.Instance.GetSettingServiceWrap().GetAudioSettings();
var selectAudioResult = audioSettings.SelectMic(selectedAudio.Moniker, selectedAudio.Name);
//ErrorLogger.Instance.LogDebug( "Zoom",$"Select audio Result: {selectAudioResult}");
}
}
public List<CaptureDevice> AudioCaptureDevices { get; } = new List<CaptureDevice> { };
public List<CaptureDevice> VideoCaptureDevices { get; } = new List<CaptureDevice> { };
public void ScanDevices()
{
AudioCaptureDevices.Clear();
VideoCaptureDevices.Clear();
var videoSettings = CZoomSDKeDotNetWrap.Instance.GetSettingServiceWrap().GetVideoSettings();
var audioSettings = CZoomSDKeDotNetWrap.Instance.GetSettingServiceWrap().GetAudioSettings();
// Console.WriteLine("Zoom Scan");
var cameraList = videoSettings?.GetCameraList();
videoSettings.Add_CB_onComputerCamDeviceChanged(OnComputerCamDeviceChanged);
foreach (var camera in cameraList)
{
var device = new CaptureDevice(camera.GetDeviceId(), camera.GetDeviceName());
VideoCaptureDevices.Add(device);
//if (camera.IsSelectedDevice())
//{
// Console.WriteLine("Selected camera: " + camera.GetDeviceName() + " |:| " + camera.GetDeviceId());
//}
// Console.WriteLine(camera.GetDeviceName());
//string devId = camera.GetDeviceId();
// Console.WriteLine(devId);
}
var audioList = audioSettings?.GetMicList();
// Console.WriteLine("AudioScan+");
foreach (var audio in audioList)
{
var device = new CaptureDevice(audio.GetDeviceId(), audio.GetDeviceName());
Console.Write(audio.GetDeviceId());
Console.Write(audio.GetDeviceName());
//ErrorLogger.Instance.LogDebug("Scanned Mic Item: ", audio.GetDeviceId() + " : " + audio.GetDeviceName());
AudioCaptureDevices.Add(device);
//if (audio.IsSelectedDevice())
//{
// Console.WriteLine("Selected audio: " + audio.GetDeviceName() + " |:| " + audio.GetDeviceId());
//}
}
//Console.WriteLine("AudioScan-");
SetDevices();
}
}
public class ZoomInfo
{
public string appKey;
public string appSecret;
public ulong meetingId;
public string meetingPassword;
public string userId;
public string userZak;
public ZoomInfo(string appKey, string appSecret, ulong meetingId, string meetingPassword, string userId, string userZak)
{
this.appKey = appKey;
this.appSecret = appSecret;
this.meetingId = meetingId;
this.meetingPassword = meetingPassword;
this.userId = userId;
this.userZak = userZak;
}
public string displayName => TeacherToken.Current.Nickname;
}
}
- Im justing using default Zoom UI and when i open up the screen sharing view and select some particular screen or window to share it show me 105035 error msg .
In addition i integrate this sdk to my own wpf project . So is there something to do with my application ?
Thank you so much for the help