EnableMic
to control other players to enable their mic to speak. If a player is dead and doesn't need to listen to room members or speak with a mic, the host use the ForbidUserOperation
API to forbid the player from manipulating devices.ITMG_MAIN_EVNET_TYPE_ROOM_MANAGEMENT_OPERATOR
. For callback details, see Processing Callbacks.Type | API |
Capturing control APIs | EnableMic, EnableAudioCaptureDevice, and EnableAudioSend |
Playback control APIs | EnableSpeaker, EnableAudioPlayDevice, and EnableAudioRecv |
Device status acquisition APIs | GetMicState and GetSpeakerState |
Sensitive APIs | ForbidUserOperation |
EnableMic
is equivalent to calling both EnableAudioSend
and EnableAudioCaptureDevice
.public abstract int EnableMic(boolean isEnabled,String receiverID);
-(QAVResult)EnableMic:(BOOL)enable Receiver:(NSString *)receiverID;
Parameter | Type | Description |
enable | BOOL | YES : Enable the mic for a user; NO : Disable the mic for a user |
receiverID | NSString* | Specifies the OpenId of the user |
public abstract int EnableAudioSend(boolean isEnabled,String receiverID);
-(QAVResult)EnableAudioSend:(BOOL)enable Receiver:(NSString *)receiverID;
Parameter | Type | Description |
enable | BOOL | YES : Enable upstreaming for a user; NO : Disable upstreaming for a user |
receiverID | NSString* | Specifies the OpenId of the user |
public abstract int EnableAudioCaptureDevice(boolean isEnabled,String receiverID);
-(QAVResult)EnableAudioCaptureDevice:(BOOL)enabled Receiver:(NSString *)receiverID;
Parameter | Type | Description |
enable | BOOL | YES : Enable the audio capturing device for a user; NO : Disable the audio capturing device for a user |
receiverID | NSString* | Specifies the OpenId of the user |
EnableSpeaker
is equivalent to calling both EnableAudioRecv
and EnableAudioPlayDevice
.public abstract int EnableSpeaker(boolean isEnabled,String receiverID);
-(QAVResult)EnableSpeaker:(BOOL)enable Receiver:(NSString *)receiverID;
Parameter | Type | Description |
enable | BOOL | YES : Enable the speaker for a user; NO : Disable the speaker for a user |
receiverID | NSString* | Specifies the OpenId of the user |
public abstract int EnableAudioRecv(boolean isEnabled,String receiverID);
-(QAVResult)EnableAudioRecv:(BOOL)enabled Receiver:(NSString *)receiverID;
Parameter | Type | Description |
enable | BOOL | YES : Enable audio downstreaming for a user; NO : Disable audio downstreaming for a user |
receiverID | NSString* | Specifies the OpenId of the user |
public abstract int EnableAudioPlayDevice(boolean isEnabled,String receiverID);
-(QAVResult)EnableAudioPlayDevice:(BOOL)enabled Receiver:(NSString *)receiverID;
Parameter | Type | Description |
enable | BOOL | YES : Enable the audio playback device for a user; NO : Disable the audio playback device for a user |
receiverID | NSString* | Specifies the OpenId of the user |
public abstract int GetMicState(String receiverID);
-(QAVResult)GetMicState:(NSString *)receiverID;
Parameter | Type | Description |
receiverID | NSString* | Specifies the OpenId of the user |
public abstract int GetSpeakerState(String receiverID);
-(QAVResult)GetSpeakerState:(NSString *)receiverID;
public abstract int ForbidUserOperation(boolean isEnabled,String receiverID);
-(QAVResult)ForbidUserOperation:(BOOL)enable Receiver:(NSString *)receiverID;
Parameter | Type | Description |
enable | BOOL | YES : Disable the devices for a user; NO : Enable the devices for a user |
receiverID | NSString* | Specifies the OpenId of the user |
OnEvent
with an event named ITMG_MAIN_EVNET_TYPE_ROOM_MANAGEMENT_OPERATOR
. This event returns a parameter structure as shown below:Parameter | Type | Description |
SenderID | NSString | ID of the event sender. If it's the same as your own OpenId , the sender is your client. |
ReceiverID | NSString | ID of the event receiver. If it's the same as your own OpenId , the receiver is your client. |
OperateType | NSNumber | Event Type |
Result | NSNumber | Event result. 0 indicates success. |
OperateValue | NSNumber | Command details |
Value | Event Type | Description |
0 | ITMG_ROOM_MANAGEMENT_CAPTURE_OP | The capturing device was controlled. |
1 | ITMG_ROOM_MANAGEMENT_PLAY_OP | The playback device was controlled. |
2 | ITMG_ROOM_MANAGEMENT_AUDIO_SEND_OP | Audio upstreaming was controlled. |
3 | ITMG_ROOM_MANAGEMENT_AUDIO_REC_OP | Audio downstreaming was controlled. |
4 | ITMG_ROOM_MANAGEMENT_MIC_OP | The mic was controlled. |
5 | ITMG_ROOM_MANAGEMENT_PLAY_OP | The speaker was controlled. |
6 | ITMG_ROOM_MANAGEMENT_GET_MIC_STATE | The mic status was obtained. |
7 | ITMG_ROOM_MANAGEMENT_GET_SPEAKER_STATE | The speaker status was obtained. |
8 | ITMG_ROOM_MANAGERMENT_FOBIN_OP | The mic and speaker were disabled. |
Member | Description |
boolValue | 0 : Disable; 1 : Enable. |
public void OnEvent(ITMGContext.ITMG_MAIN_EVENT_TYPE type, Intent data) {if (ITMGContext.ITMG_MAIN_EVENT_TYPE.ITMG_MAIN_EVNET_TYPE_ROOM_MANAGEMENT_OPERATOR== type) {ArrayList<String> operatorArr = new ArrayList<String>();operatorArr.add("Capture");operatorArr.add("Play back");operatorArr.add("Upstream");operatorArr.add("Downstream");operatorArr.add("Capture and upstream");operatorArr.add("Play back and downstream");operatorArr.add("Mic status");operatorArr.add("Speaker status");operatorArr.add("Disable the mic/speaker");String SenderID = data.getStringExtra("SenderID");String ReceiverID = data.getStringExtra("ReceiverID");int OperateType = data.getIntExtra("OperateType",-1000);int Result =data.getIntExtra("Result",-1000);boolean OperateValue = data.getBooleanExtra("OperateValue",false);if (OperateType == -1000 ||Result == -1000) {return;}if (SenderID.equals(identifier)) {if (OperateType == ITMGContext.ITMG_ROOM_MANAGEMENT_GET_MIC_STATE || OperateType == ITMGContext.ITMG_ROOM_MANAGEMENT_GET_SPEAKER_STATE) {Toast.makeText(getActivity(), String.format("Sent ID %s the result of the %s operation: %s", ReceiverID, operatorArr.get(OperateType), OperateValue ? "on" : "off"), Toast.LENGTH_LONG).show();} else {Toast.makeText(getActivity(), String.format("Sent ID %s the result of the %s%s operation: %d", ReceiverID, operatorArr.get(OperateType), OperateValue ? "on" : "off", Result), Toast.LENGTH_LONG).show();}} else if (ReceiverID.equals(identifier)||ReceiverID.equals("ALL")) {if (Result == 0) {switch (OperateType) {case ITMGContext.ITMG_ROOM_MANAGEMENT_CAPTURE_OP:{if (!OperateValue) {mSwitchCapture.setChecked(OperateValue);} else {AlertDialog.Builder dialog = new AlertDialog.Builder (getActivity()); // Create an objectdialog.setTitle("Whether to enable device capturing");dialog.setMessage("");dialog.setCancelable(false);dialog.setPositiveButton("On", new DialogInterface.OnClickListener() {// Set the click event of the **OK** button@Overridepublic void onClick(DialogInterface dialog, int which) {mSwitchCapture.setChecked(true);ITMGContext.GetInstance(getActivity()).GetAudioCtrl().EnableAudioCaptureDevice(true);}});dialog.setNegativeButton("Off", new DialogInterface.OnClickListener() {// Set the click event of the **Cancel** button@Overridepublic void onClick(DialogInterface dialog, int which) {}});dialog.show();}}break;case ITMGContext.ITMG_ROOM_MANAGEMENT_PLAY_OP:{mSwitchPlayDevice.setChecked(OperateValue);}break;case ITMGContext.ITMG_ROOM_MANAGEMENT_AUDIO_SEND_OP:{if (!OperateValue) {mSwitchSend.setChecked(OperateValue);} else {AlertDialog.Builder dialog = new AlertDialog.Builder (getActivity()); // Create an objectdialog.setTitle("Whether to enable upstreaming");dialog.setMessage("");dialog.setCancelable(false);dialog.setPositiveButton("On", new DialogInterface.OnClickListener() {// Set the click event of the **OK** button@Overridepublic void onClick(DialogInterface dialog, int which) {mSwitchSend.setChecked(true);ITMGContext.GetInstance(getActivity()).GetAudioCtrl().EnableAudioSend(true);}});dialog.setNegativeButton("Off", new DialogInterface.OnClickListener() {// Set the click event of the **Cancel** button@Overridepublic void onClick(DialogInterface dialog, int which) {}});dialog.show();}}break;case ITMGContext.ITMG_ROOM_MANAGEMENT_AUDIO_REC_OP:{mSwitchRecv.setChecked(OperateValue);}break;case ITMGContext.ITMG_ROOM_MANAGEMENT_MIC_OP:{if (!OperateValue) {mSwitchCapture.setChecked(OperateValue);mSwitchSend.setChecked(OperateValue);} else {AlertDialog.Builder dialog = new AlertDialog.Builder (getActivity()); // Create an objectdialog.setTitle("Whether to enable capturing and upstreaming");dialog.setMessage("");dialog.setCancelable(false);dialog.setPositiveButton("On", new DialogInterface.OnClickListener() {// Set the click event of the **OK** button@Overridepublic void onClick(DialogInterface dialog, int which) {mSwitchCapture.setChecked(true);mSwitchSend.setChecked(true);ITMGContext.GetInstance(getActivity()).GetAudioCtrl().EnableMic(true);}});dialog.setNegativeButton("Off", new DialogInterface.OnClickListener() {// Set the click event of the **Cancel** button@Overridepublic void onClick(DialogInterface dialog, int which) {}});dialog.show();}}break;case ITMGContext.ITMG_ROOM_MANAGEMENT_SPEAKER_OP:{mSwitchPlayDevice.setChecked(OperateValue);mSwitchRecv.setChecked(OperateValue);}break;}}if (OperateType == ITMGContext.ITMG_ROOM_MANAGEMENT_GET_MIC_STATE || OperateType == ITMGContext.ITMG_ROOM_MANAGEMENT_GET_SPEAKER_STATE){Toast.makeText(getActivity(), String.format("Received from the ID %s the result of the %s operation: %s",SenderID,operatorArr.get(OperateType),OperateValue?"on":"off"), Toast.LENGTH_LONG).show();}else if (OperateType == ITMGContext.ITMG_ROOM_MANAGEMENT_SPEAKER_OP || OperateType == ITMGContext.ITMG_ROOM_MANAGEMENT_AUDIO_REC_OP|| OperateType == ITMGContext.ITMG_ROOM_MANAGEMENT_PLAY_OP|| OperateType == ITMGContext.ITMG_ROOM_MANAGERMENT_FOBIN_OP){Toast.makeText(getActivity(), String.format("Received from ID %s the result of the %s%s operation: %d",SenderID,operatorArr.get(OperateType),OperateValue?"on":"off",Result), Toast.LENGTH_LONG).show();} else if (OperateValue == false) {Toast.makeText(getActivity(), String.format("Received from ID %s the result of the %s%s operation: %d",SenderID,operatorArr.get(OperateType),OperateValue?"on":"off",Result), Toast.LENGTH_LONG).show();}}}
-(void)OnEvent:(ITMG_MAIN_EVENT_TYPE)eventType data:(NSDictionary *)data{NSString* log =[NSString stringWithFormat:@"OnEvent:%d,data:%@", (int)eventType, data];[self showLog:log];NSLog(@"====%@====",log);switch (eventType) {case ITMG_MAIN_EVNET_TYPE_ROOM_MANAGEMENT_OPERATOR:{NSArray *operatorArr = @[@"capture",@"play back",@"upstream",@"downstream",@"capture and upstream",@"play back and downstream",@"remove user",@"mic status",@"speaker status",@"disable mic/speaker"];// _openIdNSString *SenderID = [data objectForKey:@"SenderID"];NSString *ReceiverID = [data objectForKey:@"ReceiverID"];NSNumber *OperateType = [data objectForKey:@"OperateType"];NSNumber *Result = [data objectForKey:@"Result"];NSNumber *OperateValue = [data objectForKey:@"OperateValue"];// Request sentif ([SenderID isEqualToString:_openId]) {if (OperateType.intValue == ITMG_ROOM_MANAGEMENT_GET_MIC_STATE || OperateType.intValue == ITMG_ROOM_MANAGEMENT_GET_SPEAKER_STATE) {NSString *alterString = [NSString stringWithFormat:@"%@ request sent to id:%@; result :%@",ReceiverID,operatorArr[OperateType.intValue],OperateValue.boolValue?@"enable":@"disable"];UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"room management operation" message:alterString delegate:NULL cancelButtonTitle:@"OK" otherButtonTitles:nil];[alert show];}else{NSString *alterString = [NSString stringWithFormat:@"%@%@ request sent to id:%@; result :%@", ReceiverID,OperateValue.boolValue?@"enable":@"disable",operatorArr[OperateType.intValue],Result];UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"room management operation" message:alterString delegate:NULL cancelButtonTitle:@"OK" otherButtonTitles:nil];[alert show];}}else if([ReceiverID isEqualToString:_openId] ){ // Request receivedif (Result.intValue == 0) {switch (OperateType.intValue) {case ITMG_ROOM_MANAGEMENT_CAPTURE_OP:{[_micSwitch setOn:OperateValue.boolValue animated:true];}break;case ITMG_ROOM_MANAGEMENT_PLAY_OP:{[_speakerSwitch setOn:OperateValue.boolValue animated:true];}break;case ITMG_ROOM_MANAGEMENT_AUDIO_SEND_OP:{[_sendSwitch setOn:OperateValue.boolValue animated:true];}break;case ITMG_ROOM_MANAGEMENT_AUDIO_REC_OP:{[_recvSwitch setOn:OperateValue.boolValue animated:true];}break;case ITMG_ROOM_MANAGEMENT_MIC_OP:{[_micSwitch setOn:OperateValue.boolValue animated:true];[_sendSwitch setOn:OperateValue.boolValue animated:true];}break;case ITMG_ROOM_MANAGEMENT_SPEAKER_OP:{[_speakerSwitch setOn:OperateValue.boolValue animated:true];[_recvSwitch setOn:OperateValue.boolValue animated:true];}break;default:break;}if (OperateType.intValue == ITMG_ROOM_MANAGEMENT_GET_MIC_STATE || OperateType.intValue == ITMG_ROOM_MANAGEMENT_GET_SPEAKER_STATE) {NSString *alterString = [NSString stringWithFormat:@"%@ request received from id:%@; result :%@",SenderID,operatorArr[OperateType.intValue],OperateValue.boolValue?@"enable":@"disable"];UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"room management operation" message:alterString delegate:NULL cancelButtonTitle:@"OK" otherButtonTitles:nil];[alert show];}else{NSString *alterString = [NSString stringWithFormat:@"%@%@ request received from id:%@; result :%@",SenderID,OperateValue.boolValue?@"enable":@"disable",operatorArr[OperateType.intValue],Result];UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"room management operation" message:alterString delegate:NULL cancelButtonTitle:@"OK" otherButtonTitles:nil];[alert show];}}}}break;}
Was this page helpful?