主頁 > 服務(wù)與支持 > 開發(fā)平臺(tái) > 客戶端SDK參考 > Android Native SDK > 會(huì)議 桌面協(xié)同與共享
更新時(shí)間:2019-11-20
描述
會(huì)議中,移動(dòng)與會(huì)者主動(dòng)共享屏幕,觀看屏幕或程序共享。
前提條件
業(yè)務(wù)流程
在調(diào)用開始屏幕共享startScreenShare()方法之前,UI側(cè)需要先調(diào)用MediaProjectionManager.createScreenCaptureIntent()方法向系統(tǒng)申請(qǐng)截屏權(quán)限。
在申請(qǐng)截屏權(quán)限成功的回調(diào)onActivityResult中再調(diào)用startScreenShare()方法開始共享屏幕。
代碼示例:
//Java code public int startScreenShare(Context context, Intent data){ if (null == currentConference) { Log.e(TAG, "start screen share failed, currentConference is null "); return -1; } int result = currentConference.startScreenShare(context,data); return result; } |
代碼示例:
//Java code public void onEvtAsStateChange(TsdkConference conference, TsdkConfAppShareType shareType,TsdkConfAsStateInfo asStateInfo) { Log.i(TAG, "handleAsStateChange"); switch (TsdkConfShareState.enumOf(asStateInfo.getState())) { // 開始共享 case TSDK_E_CONF_AS_STATE_VIEW: isShareAs = true; mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.START_DATA_CONF_SHARE, asStateInfo); break; // 結(jié)束共享 case TSDK_E_CONF_AS_STATE_NULL: isShareAs = false; if ((0 == documentId.size() || null == documentId)) { mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.END_DATA_CONF_SHARE, asStateInfo); } break; default: break; } } |
代碼示例:
//Java code public void OnEvtAsOwnerChange(TsdkConference conference,TsdkConfAsActionType actionType, TsdkAttendee owner){ Log.i(TAG, "handleAsOwnerChange"); if (owner==null||self==null){ return; } switch (actionType){ case TSDK_E_CONF_AS_ACTION_ADD: if (owner.getBaseInfo().getNumber().equals(self.getNumber())){ mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.SCREEN_SHARE_STATE, actionType); }else { stopScreenShare(); mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.SCREEN_SHARE_STATE, TsdkConfAsActionType.TSDK_E_CONF_AS_ACTION_MODIFY); } break; case TSDK_E_CONF_AS_ACTION_DELETE: mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.SCREEN_SHARE_STATE, actionType); break; } } |
代碼示例:
//Java code public void stopScreenShare(){ if (null == currentConference) { Log.e(TAG, "stop screen share failed, currentConference is null "); return ; } currentConference.stopScreenShare(); } |
代碼示例:
//Java code public void onEvtAsStateChange(TsdkConference conference, TsdkConfAppShareType shareType,TsdkConfAsStateInfo asStateInfo) { Log.i(TAG, "handleAsStateChange"); switch (TsdkConfShareState.enumOf(asStateInfo.getState())) { // 開始共享 case TSDK_E_CONF_AS_STATE_VIEW: isShareAs = true; mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.START_DATA_CONF_SHARE, asStateInfo); break; // 結(jié)束共享 case TSDK_E_CONF_AS_STATE_NULL: isShareAs = false; if ((0 == documentId.size() || null == documentId)) { mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.END_DATA_CONF_SHARE, asStateInfo); } break; default: break; } } |
代碼示例:
//Java code public void OnEvtAsOwnerChange(TsdkConference conference,TsdkConfAsActionType actionType, TsdkAttendee owner){ Log.i(TAG, "handleAsOwnerChange"); if (owner==null||self==null){ return; } switch (actionType){ case TSDK_E_CONF_AS_ACTION_ADD: if (owner.getBaseInfo().getNumber().equals(self.getNumber())){ mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.SCREEN_SHARE_STATE, actionType); }else { stopScreenShare(); mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.SCREEN_SHARE_STATE, TsdkConfAsActionType.TSDK_E_CONF_AS_ACTION_MODIFY); } break; case TSDK_E_CONF_AS_ACTION_DELETE: mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.SCREEN_SHARE_STATE, actionType); break; } } |
UI調(diào)用TsdkConference對(duì)象中的attachSurfaceView()方法綁定視圖,刷新共享顯示區(qū)域。
//Java code public void attachSurfaceView(ViewGroup container, Context context) { if (null == currentConference) { Log.e(TAG, "attach surface view failed, currentConference is null "); return; } currentConference.attachSurfaceView(container, context); } |
共享狀態(tài)可參考枚舉類TsdkConfShareState,其中TsdkConfShareState.TSDK_E_CONF_AS_STATE_NULL為結(jié)束程序或者屏幕共享狀態(tài)。
//Java code public void handleAsStateChange(TsdkConfAsStateInfo asStateInfo) { switch (asStateInfo.getState()) { case 0: mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.END_AS_SHARE, asStateInfo); break; default: break; } } |
attendee 為被邀者號(hào)碼。
actionType 為共享行為類型。TSDK_E_CONF_AS_ACTION_ADD 為邀請(qǐng)共享,TSDK_E_CONF_AS_ACTION_DELETE 為取消共享。
代碼示例:
//Java code public int setAsOwner(String attendee, TsdkConfAsActionType actionType){ if (null == currentConference) { Log.e(TAG, "clear annotation failed, currentConference is null "); return -1; } return currentConference.setAsOwner(attendee, actionType); } |
代碼示例:
//Java code public void OnEvtAsOwnerChange(TsdkConference conference,TsdkConfAsActionType actionType, TsdkAttendee owner){ Log.i(TAG, "handleAsOwnerChange"); if (owner==null||getCurrentConferenceSelf()==null){ return; } switch (actionType){ case TSDK_E_CONF_AS_ACTION_ADD: if (owner.getBaseInfo().getNumber().equals(getCurrentConferenceSelf().getNumber())){ mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.SCREEN_SHARE_STATE, actionType); }else { mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.SCREEN_SHARE_STATE, TsdkConfAsActionType.TSDK_E_CONF_AS_ACTION_MODIFY); } break; case TSDK_E_CONF_AS_ACTION_DELETE: case TSDK_E_CONF_AS_ACTION_REQUEST: mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.SCREEN_SHARE_STATE, actionType); break; } } |
同意可以調(diào)用startScreenShare方法開始共享,拒絕可以調(diào)用setAsOwner方法取消共享。
在調(diào)用開始屏幕共享startScreenShare()方法之前,UI側(cè)需要先調(diào)用MediaProjectionManager.createScreenCaptureIntent()方法向系統(tǒng)申請(qǐng)截屏權(quán)限。
在申請(qǐng)截屏權(quán)限成功的回調(diào)onActivityResult中再調(diào)用startScreenShare()方法開始共享屏幕。
代碼示例:
//Java code public int startScreenShare(Context context, Intent data){ if (null == currentConference) { Log.e(TAG, "start screen share failed, currentConference is null "); return -1; } int result = currentConference.startScreenShare(context,data); return result; } |
代碼示例:
//Java code public void onEvtAsStateChange(TsdkConference conference, TsdkConfAppShareType shareType,TsdkConfAsStateInfo asStateInfo) { Log.i(TAG, "handleAsStateChange"); switch (TsdkConfShareState.enumOf(asStateInfo.getState())) { // 開始共享 case TSDK_E_CONF_AS_STATE_VIEW: isShareAs = true; mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.START_DATA_CONF_SHARE, asStateInfo); break; // 結(jié)束共享 case TSDK_E_CONF_AS_STATE_NULL: isShareAs = false; if ((0 == documentId.size() || null == documentId)) { mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.END_DATA_CONF_SHARE, asStateInfo); } break; default: break; } } |
代碼示例:
//Java code public void OnEvtAsOwnerChange(TsdkConference conference,TsdkConfAsActionType actionType, TsdkAttendee owner){ Log.i(TAG, "handleAsOwnerChange"); if (owner==null||getCurrentConferenceSelf()==null){ return; } switch (actionType){ case TSDK_E_CONF_AS_ACTION_ADD: if (owner.getBaseInfo().getNumber().equals(getCurrentConferenceSelf().getNumber())){ mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.SCREEN_SHARE_STATE, actionType); }else { mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.SCREEN_SHARE_STATE, TsdkConfAsActionType.TSDK_E_CONF_AS_ACTION_MODIFY); } break; case TSDK_E_CONF_AS_ACTION_DELETE: case TSDK_E_CONF_AS_ACTION_REQUEST: mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.SCREEN_SHARE_STATE, actionType); break; } } |
//Java code public int setAsOwner(String attendee, TsdkConfAsActionType actionType){ if (null == currentConference) { Log.e(TAG, "clear annotation failed, currentConference is null "); return -1; } return currentConference.setAsOwner(attendee, actionType); } |
代碼示例:
//Java code public void OnEvtAsOwnerChange(TsdkConference conference,TsdkConfAsActionType actionType, TsdkAttendee owner){ Log.i(TAG, "handleAsOwnerChange"); if (owner==null||self==null){ return; } switch (actionType){ case TSDK_E_CONF_AS_ACTION_ADD: if (owner.getBaseInfo().getNumber().equals(self.getNumber())){ mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.SCREEN_SHARE_STATE, actionType); }else { stopScreenShare(); mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.SCREEN_SHARE_STATE, TsdkConfAsActionType.TSDK_E_CONF_AS_ACTION_MODIFY); } break; case TSDK_E_CONF_AS_ACTION_DELETE: mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.SCREEN_SHARE_STATE, actionType); break; } |
注意事項(xiàng)
無。
描述
會(huì)議中,移動(dòng)與會(huì)者觀看文檔或白板共享。
移動(dòng)應(yīng)用程序暫不具備共享文檔和白板的能力,文檔或白板的共享者為PC應(yīng)用程序。
前提條件
業(yè)務(wù)流程
//Java code public void attachSurfaceView(ViewGroup container, Context context) { if (null == currentConference) { Log.e(TAG, "attach surface view failed, currentConference is null "); return; } currentConference.attachSurfaceView(container, context); } |
如果共享側(cè)新建一個(gè)空的白板文檔,移動(dòng)側(cè)SDK下載到一個(gè)白板文檔頭后,通過TsdkNotify對(duì)象中onEvtWbDocNew()方法向UI上報(bào)新建一個(gè)白板文檔事件。
Java code public void handleWbDocNew(TsdkDocBaseInfo docBaseInfo) { if (null == docBaseInfo) { return; } documentId.add(docBaseInfo.getDocumentId()); mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.START_DATA_CONF_SHARE, docBaseInfo); } |
Java code public void handleDsDocNew(TsdkDocBaseInfo docBaseInfo) { if (null == docBaseInfo) { return; } documentId.add(docBaseInfo.getDocumentId()); mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.START_DATA_CONF_SHARE, docBaseInfo); } |
PC端用戶在進(jìn)行文檔或者白板共享中結(jié)束共享文檔或白板。
如果移動(dòng)側(cè)SDK通過TsdkNotify對(duì)象中的onEvtDsDocDel()方法向UI上報(bào)文檔被刪除通知消息,UI關(guān)閉文檔共享顯示窗口。
如果移動(dòng)側(cè)SDK通過TsdkNotify對(duì)象中的onEvtWbDocDel()方法向UI上報(bào)白板被刪除通知消息,UI關(guān)閉白板共享顯示窗口。
代碼示例:
//Java code public void handleDsDocDel(TsdkDocShareDelDocInfo docShareDelDocInfo) { if (null == docShareDelDocInfo) { return; } Iterator<Integer> iterator = documentId.iterator(); while (iterator.hasNext()) { if (iterator.next() == docShareDelDocInfo.getDocBaseInfo().getDocumentId()) { iterator.remove(); } } if (0 == documentId.size() && !isShareAs) { mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.END_DATA_CONF_SHARE, docShareDelDocInfo); } } |
//Java code public void handleWbDocDel(TsdkWbDelDocInfo wbDelDocInfo) { if (null == wbDelDocInfo) { return; } Iterator<Integer> iterator = documentId.iterator(); while (iterator.hasNext()) { if (iterator.next() == wbDelDocInfo.getWbBaseInfo().getDocumentId()) { iterator.remove(); } } if (0 == documentId.size() && !isShareAs) { mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.END_DATA_CONF_SHARE, wbDelDocInfo); } } |
注意事項(xiàng)
無。
描述
在屏幕共享中,與會(huì)者間可以通過標(biāo)注功能在共享界面進(jìn)行遠(yuǎn)程交流。
前提條件
正在進(jìn)行屏幕共享。
代碼示例:
//Java code public int startAnnotation( ){ if (null == currentConference) { Log.e(TAG, "start annotation failed, currentConference is null "); return -1; } int result = currentConference.startAnnotation(); return result; } |
代碼示例:
//Java code public void onEvtAsStateChange(TsdkConference conference, TsdkConfAppShareType shareType,TsdkConfAsStateInfo asStateInfo) { Log.i(TAG, "handleAsStateChange"); switch (TsdkConfShareState.enumOf(asStateInfo.getState())) { // 開始共享 case TSDK_E_CONF_AS_STATE_VIEW: isShareAs = true; mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.START_DATA_CONF_SHARE, asStateInfo); break; // 結(jié)束共享 case TSDK_E_CONF_AS_STATE_NULL: isShareAs = false; if ((0 == documentId.size() || null == documentId)) { mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.END_DATA_CONF_SHARE, asStateInfo); } break; default: break; } } |
代碼示例:
//Java code public void setAnnotationPen(int penColor, int penWidth) { if (null == currentConference) { Log.e(TAG, "set annotation pen failed, currentConference is null "); return; } currentConference.setAnnotationPen(penColor, penWidth); } |
代碼示例:
//Java code public void setAnnotationLocalStatus(boolean enable) { if (null == currentConference) { Log.e(TAG, "set annotation local status failed, currentConference is null "); return; } currentConference.setAnnotationLocalStatus(enable); } |
代碼示例:
//Java code public void setAnnotationLocalStatus(boolean enable) { if (null == currentConference) { Log.e(TAG, "set annotation local status failed, currentConference is null "); return; } currentConference.setAnnotationLocalStatus(enable); } |
代碼示例:
//Java code public int stopAnnotation(){ if (null == currentConference) { Log.e(TAG, "stop annotation failed, currentConference is null "); return -1; } int result = currentConference.stopAnnotation(); return result; } |
代碼示例:
//Java code public void onEvtAsStateChange(TsdkConference conference, TsdkConfAppShareType shareType,TsdkConfAsStateInfo asStateInfo) { Log.i(TAG, "handleAsStateChange"); switch (TsdkConfShareState.enumOf(asStateInfo.getState())) { // 開始共享 case TSDK_E_CONF_AS_STATE_VIEW: isShareAs = true; mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.START_DATA_CONF_SHARE, asStateInfo); break; // 結(jié)束共享 case TSDK_E_CONF_AS_STATE_NULL: isShareAs = false; if ((0 == documentId.size() || null == documentId)) { mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.END_DATA_CONF_SHARE, asStateInfo); } break; default: break; } } |
注意事項(xiàng)
無。
描述
會(huì)議中,所有人可以收到其他與會(huì)者發(fā)送的聊天消息內(nèi)容。
前提條件
加入數(shù)據(jù)會(huì)議成功。
業(yè)務(wù)流程
//Java code public void sendConfMessage(String message) { if (null == currentConference) { Log.e(TAG, "send chat failed, currentConference is null "); return; } TsdkConfChatMsgInfo chatMsgInfo = new TsdkConfChatMsgInfo(); chatMsgInfo.setChatType(TsdkConfChatType.TSDK_E_CONF_CHAT_PUBLIC); chatMsgInfo.setChatMsg(message); chatMsgInfo.setSenderDisplayName(self.getDisplayName()); currentConference.sendChatMsg(chatMsgInfo); } |
//Java code public void handleRecvChatMsg(TsdkConfChatMsgInfo confChatMsgInfo) { mConfNotification.onConfEventNotify(ConfConstant.CONF_EVENT.CONF_CHAT_MSG, confChatMsgInfo); } |
注意事項(xiàng)
無。