您尚未登录

登录

您尚未登录

登录

推荐您使用PC浏览器访问

确定
  • 开发者中心
  • >
  • 云游戏
  • >
  • 快速入门
  • >
  • 启动关闭云游戏
  • >
  • Android

启动关闭云游戏

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();
}
×

本篇文章对你是否有帮助?

更多建议

请输入您的建议