use of com.herewhite.sdk.WhiteSdk in project whiteboard-android by netless-io.
the class WindowTestActivity method joinRoom.
private void joinRoom(String uuid, String token) {
logRoomInfo("room uuid: " + uuid + "\nroom token: " + token);
WhiteSdkConfiguration configuration = new WhiteSdkConfiguration(demoAPI.getAppId(), true);
/*显示用户头像*/
configuration.setUserCursor(true);
// 动态 ppt 需要的自定义字体,如果没有使用,无需调用
configuration.setFonts(new MapBuilder<String, String>().put("宋体", "https://your-cdn.com/Songti.ttf").build());
// configuration.setEnableSyncedStore(true);
configuration.setUseMultiViews(true);
mWhiteSdk = new WhiteSdk(mWhiteboardView, this, configuration);
mWhiteSdk.setCommonCallbacks(new CommonCallback() {
@Override
public void onLogger(JSONObject object) {
logAction(object.toString());
}
});
/* 设置自定义全局状态,在后续回调中 GlobalState 直接进行类型转换即可 */
WhiteDisplayerState.setCustomGlobalStateClass(GlobalState.class);
// 如需支持用户头像,请在设置 WhiteSdkConfiguration 后,再调用 setUserPayload 方法,传入符合用户信息
RoomParams roomParams = new RoomParams(uuid, token, DemoAPI.DEFAULT_UID);
HashMap<String, String> styleMap = new HashMap<>();
styleMap.put("backgroundColor", "red");
styleMap.put("top", "12px");
styleMap.put("left", "60px");
styleMap.put("position", "fixed");
// String darkMode = darkModeStyle();
WindowParams windowParams = new WindowParams().setContainerSizeRatio(3f / 4).setChessboard(true).setDebug(true).setCollectorStyles(styleMap);
// optional
roomParams.setWindowParams(windowParams);
mWhiteSdk.joinRoom(roomParams, new RoomListener() {
@Override
public void onPhaseChanged(RoomPhase phase) {
logRoomInfo("onPhaseChanged: " + phase.name());
showToast(phase.name());
}
@Override
public void onDisconnectWithError(Exception e) {
}
@Override
public void onKickedWithReason(String s) {
}
@Override
public void onRoomStateChanged(RoomState roomState) {
if (roomState.getWindowBoxState() != null) {
logRoomInfo("WindowBoxState " + roomState.getWindowBoxState());
}
}
@Override
public void onCanUndoStepsUpdate(long l) {
}
@Override
public void onCanRedoStepsUpdate(long l) {
}
@Override
public void onCatchErrorWhenAppendFrame(long l, Exception e) {
}
@Override
public void onAttributesUpdate(String valueOf) {
state = gson.fromJson(valueOf, UserSyncedState.class);
logRoomInfo("onAttributesUpdate:" + state);
updateDragView();
}
}, new Promise<Room>() {
@Override
public void then(Room room) {
mRoom = room;
}
@Override
public void catchEx(SDKError sdkError) {
}
});
}
use of com.herewhite.sdk.WhiteSdk in project whiteboard-android by netless-io.
the class PptOldActivity method joinRoom.
// region room
private void joinRoom(String uuid, String token) {
logRoomInfo("room uuid: " + uuid + "\nroom token: " + token);
// 存档一下,方便重连
this.uuid = uuid;
this.token = token;
WhiteSdkConfiguration configuration = new WhiteSdkConfiguration(demoAPI.getAppId(), true);
/*显示用户头像*/
configuration.setUserCursor(true);
// 动态 ppt 需要的自定义字体,如果没有使用,无需调用
configuration.setFonts(new MapBuilder<String, String>().put("宋体", "https://your-cdn.com/Songti.ttf").build());
mWhiteSdk = new WhiteSdk(mWhiteboardView, this, configuration);
// 图片替换 API,需要在 whiteSDKConfig 中先行调用 setHasUrlInterrupterAPI,进行设置,否则不会被回调。
mWhiteSdk.setCommonCallbacks(new CommonCallback() {
@Override
public String urlInterrupter(String sourceUrl) {
return sourceUrl;
}
@Override
public void onMessage(JSONObject message) {
Log.d(TAG, message.toString());
}
@Override
public void sdkSetupFail(SDKError error) {
Log.e(TAG, "sdkSetupFail " + error.toString());
}
@Override
public void throwError(Object args) {
Log.e(TAG, "throwError " + args);
}
@Override
public void onPPTMediaPlay() {
logAction();
}
@Override
public void onPPTMediaPause() {
logAction();
}
@Override
public void onLogger(JSONObject object) {
logAction(object.toString());
}
});
// 如需支持用户头像,请在设置 WhiteSdkConfiguration 后,再调用 setUserPayload 方法,传入符合用户信息
RoomParams roomParams = new RoomParams(uuid, token, DemoAPI.DEFAULT_UID);
roomParams.setDisableNewPencil(false);
roomParams.setWritable(true);
final Date joinDate = new Date();
logRoomInfo("native join " + joinDate);
mWhiteSdk.joinRoom(roomParams, new RoomCallbacks() {
@Override
public void onCanUndoStepsUpdate(long canUndoSteps) {
mRoomCallbackHock.onCanUndoStepsUpdate(canUndoSteps);
logRoomInfo("canUndoSteps: " + canUndoSteps);
}
@Override
public void onCanRedoStepsUpdate(long canRedoSteps) {
mRoomCallbackHock.onCanRedoStepsUpdate(canRedoSteps);
logRoomInfo("onCanRedoStepsUpdate: " + canRedoSteps);
}
@Override
public void onCatchErrorWhenAppendFrame(long userId, Exception error) {
mRoomCallbackHock.onCatchErrorWhenAppendFrame(userId, error);
logRoomInfo("onCatchErrorWhenAppendFrame: " + userId + " error " + error.getMessage());
}
@Override
public void onPhaseChanged(RoomPhase phase) {
mRoomCallbackHock.onPhaseChanged(phase);
// 在此处可以处理断连后的重连逻辑
logRoomInfo("onPhaseChanged: " + phase.name());
showToast(phase.name());
}
@Override
public void onDisconnectWithError(Exception e) {
mRoomCallbackHock.onDisconnectWithError(e);
logRoomInfo("onDisconnectWithError: " + e.getMessage());
}
@Override
public void onKickedWithReason(String reason) {
mRoomCallbackHock.onKickedWithReason(reason);
logRoomInfo("onKickedWithReason: " + reason);
}
@Override
public void onRoomStateChanged(RoomState modifyState) {
mRoomCallbackHock.onRoomStateChanged(modifyState);
logRoomInfo("onRoomStateChanged:" + gson.toJson(modifyState));
}
}, new Promise<Room>() {
@Override
public void then(Room room) {
// 记录加入房间消耗的时长
logRoomInfo("native join in room duration: " + (System.currentTimeMillis() - joinDate.getTime()) / 1000f + "s");
mRoom = room;
addCustomEventListener();
testMarkIdling(true);
}
@Override
public void catchEx(SDKError t) {
logRoomInfo("native join fail: " + t.getMessage());
showToast(t.getMessage());
}
});
}
use of com.herewhite.sdk.WhiteSdk in project whiteboard-android by netless-io.
the class PptResourceCacheActivity method joinRoom.
private void joinRoom(String uuid, String token) {
logRoomInfo("room uuid: " + uuid + "\nroom token: " + token);
// 存档一下,方便重连
this.uuid = uuid;
this.token = token;
WhiteSdkConfiguration configuration = new WhiteSdkConfiguration(demoAPI.getAppId(), true);
/*显示用户头像*/
configuration.setUserCursor(true);
// 动态 ppt 需要的自定义字体,如果没有使用,无需调用
configuration.setFonts(new MapBuilder<String, String>().put("宋体", "https://your-cdn.com/Songti.ttf").build());
mWhiteSdk = new WhiteSdk(mWhiteboardView, this, configuration);
// 图片替换 API,需要在 whiteSDKConfig 中先行调用 setHasUrlInterrupterAPI,进行设置,否则不会被回调。
mWhiteSdk.setCommonCallbacks(new CommonCallbacks() {
@Override
public String urlInterrupter(String sourceUrl) {
return sourceUrl;
}
@Override
public void onMessage(JSONObject message) {
Log.d(TAG, message.toString());
}
@Override
public void sdkSetupFail(SDKError error) {
Log.e(TAG, "sdkSetupFail " + error.toString());
}
@Override
public void throwError(Object args) {
Log.e(TAG, "throwError " + args);
}
@Override
public void onPPTMediaPlay() {
logAction();
}
@Override
public void onPPTMediaPause() {
logAction();
}
});
FontFace fontFace = new FontFace("example", "url(https://white-pan.oss-cn-shanghai.aliyuncs.com/Pacifico-Regular.ttf)");
// mWhiteSdk.setupFontFaces(new FontFace[]{fontFace});
mWhiteSdk.loadFontFaces(new FontFace[] { fontFace }, new Promise<JSONObject>() {
@Override
public void then(JSONObject object) {
logRoomInfo("loadFontFaces");
}
@Override
public void catchEx(SDKError t) {
}
});
/**
* 设置自定义全局状态,在后续回调中 GlobalState 直接进行类型转换即可
*/
WhiteDisplayerState.setCustomGlobalStateClass(MyGlobalState.class);
// 如需支持用户头像,请在设置 WhiteSdkConfiguration 后,再调用 setUserPayload 方法,传入符合用户信息
RoomParams roomParams = new RoomParams(uuid, token, DemoAPI.DEFAULT_UID);
final Date joinDate = new Date();
logRoomInfo("native join " + joinDate);
mWhiteSdk.joinRoom(roomParams, new RoomCallbacks() {
@Override
public void onCanUndoStepsUpdate(long canUndoSteps) {
mRoomCallbackHock.onCanUndoStepsUpdate(canUndoSteps);
logRoomInfo("canUndoSteps: " + canUndoSteps);
}
@Override
public void onCanRedoStepsUpdate(long canRedoSteps) {
mRoomCallbackHock.onCanRedoStepsUpdate(canRedoSteps);
logRoomInfo("onCanRedoStepsUpdate: " + canRedoSteps);
}
@Override
public void onCatchErrorWhenAppendFrame(long userId, Exception error) {
mRoomCallbackHock.onCatchErrorWhenAppendFrame(userId, error);
logRoomInfo("onCatchErrorWhenAppendFrame: " + userId + " error " + error.getMessage());
}
@Override
public void onPhaseChanged(RoomPhase phase) {
mRoomCallbackHock.onPhaseChanged(phase);
// 在此处可以处理断连后的重连逻辑
logRoomInfo("onPhaseChanged: " + phase.name());
showToast(phase.name());
}
@Override
public void onDisconnectWithError(Exception e) {
mRoomCallbackHock.onDisconnectWithError(e);
logRoomInfo("onDisconnectWithError: " + e.getMessage());
}
@Override
public void onKickedWithReason(String reason) {
mRoomCallbackHock.onKickedWithReason(reason);
logRoomInfo("onKickedWithReason: " + reason);
}
@Override
public void onRoomStateChanged(RoomState modifyState) {
mRoomCallbackHock.onRoomStateChanged(modifyState);
logRoomInfo("onRoomStateChanged:" + gson.toJson(modifyState));
pptResourceManager.updateRoomState(modifyState);
}
}, new Promise<Room>() {
@Override
public void then(Room room) {
// 记录加入房间消耗的时长
logRoomInfo("native join in room duration: " + (System.currentTimeMillis() - joinDate.getTime()) / 1000f + "s");
mRoom = room;
addCustomEventListener();
pptResourceManager.updateRoomState(mRoom.getRoomState());
testMarkIdling(true);
}
@Override
public void catchEx(SDKError t) {
logRoomInfo("native join fail: " + t.getMessage());
showToast(t.getMessage());
}
});
}
use of com.herewhite.sdk.WhiteSdk in project whiteboard-android by netless-io.
the class RatioChangeActivity method joinRoom.
private void joinRoom(String uuid, String token) {
logRoomInfo("room uuid: " + uuid + "\nroom token: " + token);
WhiteSdkConfiguration configuration = new WhiteSdkConfiguration(demoAPI.getAppId(), true);
/*显示用户头像*/
configuration.setUserCursor(true);
// 动态 ppt 需要的自定义字体,如果没有使用,无需调用
configuration.setFonts(new MapBuilder<String, String>().put("宋体", "https://your-cdn.com/Songti.ttf").build());
mWhiteSdk = new WhiteSdk(mWhiteboardView, this, configuration);
// 图片替换 API,需要在 whiteSDKConfig 中先行调用 setHasUrlInterrupterAPI,进行设置,否则不会被回调。
mWhiteSdk.setCommonCallbacks(new CommonCallbacks() {
@Override
public String urlInterrupter(String sourceUrl) {
return sourceUrl;
}
@Override
public void onMessage(JSONObject message) {
Log.d(TAG, message.toString());
}
@Override
public void sdkSetupFail(SDKError error) {
Log.e(TAG, "sdkSetupFail " + error.toString());
}
@Override
public void throwError(Object args) {
Log.e(TAG, "throwError " + args);
}
@Override
public void onPPTMediaPlay() {
logAction();
}
@Override
public void onPPTMediaPause() {
logAction();
}
});
FontFace fontFace = new FontFace("example", "url(https://white-pan.oss-cn-shanghai.aliyuncs.com/Pacifico-Regular.ttf)");
// mWhiteSdk.setupFontFaces(new FontFace[]{fontFace});
mWhiteSdk.loadFontFaces(new FontFace[] { fontFace }, new Promise<JSONObject>() {
@Override
public void then(JSONObject object) {
logRoomInfo("loadFontFaces");
}
@Override
public void catchEx(SDKError t) {
}
});
/**
* 设置自定义全局状态,在后续回调中 GlobalState 直接进行类型转换即可
*/
WhiteDisplayerState.setCustomGlobalStateClass(MyGlobalState.class);
// 如需支持用户头像,请在设置 WhiteSdkConfiguration 后,再调用 setUserPayload 方法,传入符合用户信息
RoomParams roomParams = new RoomParams(uuid, token, DemoAPI.DEFAULT_UID);
final Date joinDate = new Date();
logRoomInfo("native join " + joinDate);
mWhiteSdk.joinRoom(roomParams, new AbstractRoomCallbacks() {
}, new Promise<Room>() {
@Override
public void then(Room room) {
// 记录加入房间消耗的时长
logRoomInfo("native join in room duration: " + (System.currentTimeMillis() - joinDate.getTime()) / 1000f + "s");
mRoom = room;
}
@Override
public void catchEx(SDKError t) {
logRoomInfo("native join fail: " + t.getMessage());
showToast(t.getMessage());
}
});
}
use of com.herewhite.sdk.WhiteSdk in project whiteboard-android by netless-io.
the class ScenesActivity method joinRoom.
// region room
private void joinRoom(String uuid, String token) {
logRoomInfo("room uuid: " + uuid + "\nroom token: " + token);
WhiteSdkConfiguration configuration = new WhiteSdkConfiguration(demoAPI.getAppId(), true);
mWhiteSdk = new WhiteSdk(mWhiteboardView, this, configuration);
RoomParams roomParams = new RoomParams(uuid, token, DemoAPI.DEFAULT_UID);
roomParams.setDisableNewPencil(false);
roomParams.setWritable(true);
mWhiteSdk.joinRoom(roomParams, new RoomCallbacks() {
@Override
public void onCanUndoStepsUpdate(long canUndoSteps) {
}
@Override
public void onCanRedoStepsUpdate(long canRedoSteps) {
}
@Override
public void onCatchErrorWhenAppendFrame(long userId, Exception error) {
}
@Override
public void onPhaseChanged(RoomPhase phase) {
logRoomInfo("onPhaseChanged: " + phase.name());
showToast(phase.name());
}
@Override
public void onDisconnectWithError(Exception e) {
logRoomInfo("onDisconnectWithError: " + e.getMessage());
}
@Override
public void onKickedWithReason(String reason) {
logRoomInfo("onKickedWithReason: " + reason);
}
@Override
public void onRoomStateChanged(RoomState modifyState) {
logRoomInfo("onRoomStateChanged: " + modifyState);
if (modifyState.getSceneState() != null) {
// callback when sceneState changed
SceneState sceneState = modifyState.getSceneState();
logRoomInfo("sceneState changed " + sceneState.toString());
}
}
}, new Promise<Room>() {
@Override
public void then(Room room) {
mRoom = room;
}
@Override
public void catchEx(SDKError t) {
showToast(t.getMessage());
}
});
}
Aggregations