com.google.android.exoplayer2.util.Util.getAudioUsageForStreamType()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(197)

本文整理了Java中com.google.android.exoplayer2.util.Util.getAudioUsageForStreamType()方法的一些代码示例,展示了Util.getAudioUsageForStreamType()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.getAudioUsageForStreamType()方法的具体详情如下:
包路径:com.google.android.exoplayer2.util.Util
类名称:Util
方法名:getAudioUsageForStreamType

Util.getAudioUsageForStreamType介绍

[英]Returns the C.AudioUsage corresponding to the specified C.StreamType.
[中]返回与指定的C.StreamType对应的C.AudioUsage。

代码示例

代码示例来源:origin: google/ExoPlayer

  1. /**
  2. * Sets the stream type for audio playback, used by the underlying audio track.
  3. * <p>
  4. * Setting the stream type during playback may introduce a short gap in audio output as the audio
  5. * track is recreated. A new audio session id will also be generated.
  6. * <p>
  7. * Calling this method overwrites any attributes set previously by calling
  8. * {@link #setAudioAttributes(AudioAttributes)}.
  9. *
  10. * @deprecated Use {@link #setAudioAttributes(AudioAttributes)}.
  11. * @param streamType The stream type for audio playback.
  12. */
  13. @Deprecated
  14. public void setAudioStreamType(@C.StreamType int streamType) {
  15. @C.AudioUsage int usage = Util.getAudioUsageForStreamType(streamType);
  16. @C.AudioContentType int contentType = Util.getAudioContentTypeForStreamType(streamType);
  17. AudioAttributes audioAttributes =
  18. new AudioAttributes.Builder().setUsage(usage).setContentType(contentType).build();
  19. setAudioAttributes(audioAttributes);
  20. }

代码示例来源:origin: brianwernick/ExoMedia

  1. public void setAudioStreamType(int streamType) {
  2. @C.AudioUsage
  3. int usage = Util.getAudioUsageForStreamType(streamType);
  4. @C.AudioContentType
  5. int contentType = Util.getAudioContentTypeForStreamType(streamType);
  6. AudioAttributes audioAttributes = new AudioAttributes.Builder()
  7. .setUsage(usage)
  8. .setContentType(contentType)
  9. .build();
  10. sendMessage(C.TRACK_TYPE_AUDIO, C.MSG_SET_AUDIO_ATTRIBUTES, audioAttributes);
  11. }

相关文章