启动关闭云游戏
1 启动游戏
初始化成功后,调用 hmcpVideoView.play(bundle) 开始游戏
boolean isPortraitOrientation = false; // 是否竖屏
ScreenOrientation orientaion = isPortraitOrientation ? ScreenOrientation.PORTRAIT : ScreenOrientation.LANDSCAPE;
int playTime = 6000 * 1000;
int priority = 100;
int appId = 123;
String packageNameGame = "com.yodo1tier1.skizgfTV.cmcc";
String appChannel = "";
String cToken = CryptoUtils.generateCToken(packageNameGame, userId, userToken, accessKeyID, channelID, accessKey);
Bundle bundle = new Bundle();
bundle.putSerializable(HmcpVideoView.ORIENTATION, orientaion);
bundle.putInt(HmcpVideoView.PLAY_TIME, playTime);
bundle.putInt(HmcpVideoView.PRIORITY, priority);
bundle.putInt(HmcpVideoView.APP_ID, appId);
bundle.putString(HmcpVideoView.APP_NAME, packageName);
bundle.putString(HmcpVideoView.APP_CHANNEL, appChannel);
bundle.putString(HmcpVideoView.C_TOKEN, cToken);
hmcpVideoView.play(bundle);
2 关闭云游戏
退出游戏时需要在 Activity 方法重载 onPause()、onDestroy()
示例代码
@Override
protected void onPause() {
super.onPause();
hmcpVideoView.onPause();
}
@Override
protected void onDestroy() {
if (hmcpVideoView!= null) {
hmcpVideoView. onDestroy();
}
super.onDestroy();
}