您尚未登录

登录

推荐您使用PC浏览器访问

确定
  • 开发者中心
  • >
  • 云游戏
  • >
  • 快速入门
  • >
  • 清晰度切换
  • >
  • Android

清晰度切换

1 在海马云游戏管理平台进行配置游戏的清晰度参数(高清、超清、流畅);

2 调用开始游戏后,如果成功会有 sceneId = “play” 的场景回调

   onSceneChanged ===> {"extraInfo":{"cur_rate":"200"},"sceneId":"play"}

3 SDK 调用 HmcpManager.getInstance().getResolutionData() 获取当前游戏的清晰度列表;

   "resolution":[
     {"bitRate":"9600000","defaultChoice":"0","frameRate":60,"id":"4","name":"1080P","resolution":"1920x1080"},
     {"bitRate":"4000000","defaultChoice":"0","frameRate":60,"id":"2","name":"标清","resolution":"960x540"},
     {"bitRate":"3200000","defaultChoice":"1","frameRate":60,"id":"3","name":"高清","resolution":"1280x720"},
     {"bitRate":"2400000","defaultChoice":"0","frameRate":60,"id":"1","name":"流畅","resolution":"848x480"}
   ]

4 监听回调函数onSceneChanged 并收到 sceneId=”crtp” 消息:

   onSceneChanged ===> {"extraInfo": {"delay_less_minimum":"0","minimum":0},"sceneId":"crtp"}
字段 类型 说明
delay_less_minimum String 当前码率是否是最低码率 否-“0” 是-“1”
minimum Int 当前码率是否低于下限 否 - 0 是 - 1

5 开始切换码率:

   // 发起切换码率
   recordSceneEvent ===> crst{"des":"1024","method":0,"source":"50000"}
   // 切换码率时回调
   onSceneChanged ===> 
   {"extraInfo":{"des":"1024","method":0,"source":"50000"},"sceneId":"crst"}
参数 类型 说明
method int 切换码率模式
0 :手动切换码率
1 :自动切换码率
des String 目标码率 ID

5.1 果手动调用 onSwitchResolution() 切换码率;

5.2 onSceneChanged 接收到切换码率的消息回调 scenedId=”crst”

6 onSceneChanged 收到scenedId=”cred”切换码率后结果:

   recordSceneEvent ===> cred {"cur_rate":"500","result":1}
字段 类型 说明
cur_rate String 当前码率是否是最低码率 否-“0” 是-“1”
result Int 0 :失败 1 :成功
×

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

更多建议

请输入您的建议