jiyong3998

导航

 

While sending a focus request is recommended, it isn't enforced by the system.

The vehicle shouldn't depend on the focus system for operation of the audio subsystem.

交互行为

There are three types of interactions:

  • Exclusive: The incoming request is returned with AUDIOFOCUS_REQUEST_GRANTED while the current focus holder receives a focus change event with a loss status;
  • Reject: The incoming request is always receives AUDIOFOCUS_REQUEST_FAILED;
  • Concurrent:The incoming request request AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK and  returns with AUDIOFOCUS_REQUEST_GRANTED. The current focus holder has receivce AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK

We strongly recommend that CarAudioContext's that are allowed to play concurrently should be routed to different output devices.

 交互矩阵

 

 多音区焦点管理

For vehicles with multiple audio zones, audio focus is managed independently for each zone

 A focus request’s audio zone is determined by its associated UserId or UID - getZoneIdForUidLocked(int uid)

 如果一个应用想在多个音区播放音频,则需要在每个单独是音区独立申请焦点并带上AUDIOFOCUS_EXTRA_REQUEST_ZONE_ID属性。

 

 

 1 //Create attribute with bundle and AUDIOFOCUS_EXTRA_REQUEST_ZONE_ID
 2 Bundle bundle = new Bundle();
 3 bundle.putInt(CarAudioManager.AUDIOFOCUS_EXTRA_REQUEST_ZONE_ID,
 4                zoneId);
 5 
 6 AudioAttributes attributesWithZone = new AudioAttributes.Builder()
 7      .setUsage(AudioAttributes.USAGE_MEDIA)
 8      .addBundle(bundle)
 9      .build();
10 
11 //Create focus request using built attributesWithZone

 

 

 

 

 

 

posted on 2024-02-06 15:50  jiyong3998  阅读(30)  评论(0)    收藏  举报