gpt4 book ai didi

java - exoplayer 2.11.* 版本在 android 5.0/5.1(Lollipop) 设备中引发渲染器错误

转载 作者:行者123 更新时间:2023-12-03 11:20:17 28 4
gpt4 key购买 nike

我正在使用 exoplayer用于从 firebase storage 流式传输我的音频文件到我的安卓应用程序。 exoplayer>= 6.0 的 android 版本中效果很好.但是在 Android 5.0/5.1(Lollipop)设备,exoplayer给我一个 Renderer error .
这是我得到的错误:

E/AudioTrack: AudioFlinger could not create track, status: -12
E/AudioTrack-JNI: Error -12 initializing AudioTrack
E/android.media.AudioTrack: Error code -20 when initializing AudioTrack.
E/ExoPlayerImplInternal: Renderer error: index=1, type=audio, format=Format(null, null, null, audio/mpeg, null, -1, null, [-1, -1, -1.0], [2, 32000]), rendererSupport=YES
com.google.android.exoplayer2.ExoPlaybackException: com.google.android.exoplayer2.audio.AudioSink$InitializationException: AudioTrack init failed: 0, Config(32000, 12, 32000)
at com.google.android.exoplayer2.BaseRenderer.createRendererException(BaseRenderer.java:359)
at com.google.android.exoplayer2.audio.MediaCodecAudioRenderer.processOutputBuffer(MediaCodecAudioRenderer.java:831)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1590)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:721)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:599)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:329)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by: com.google.android.exoplayer2.audio.AudioSink$InitializationException: AudioTrack init failed: 0, Config(32000, 12, 32000)
at com.google.android.exoplayer2.audio.DefaultAudioSink$Configuration.buildAudioTrack(DefaultAudioSink.java:1428)
at com.google.android.exoplayer2.audio.DefaultAudioSink.initialize(DefaultAudioSink.java:527)
at com.google.android.exoplayer2.audio.DefaultAudioSink.handleBuffer(DefaultAudioSink.java:608)
at com.google.android.exoplayer2.audio.MediaCodecAudioRenderer.processOutputBuffer(MediaCodecAudioRenderer.java:824)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1590) 
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:721) 
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:599) 
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:329) 
at android.os.Handler.dispatchMessage(Handler.java:98) 
at android.os.Looper.loop(Looper.java:135) 
at android.os.HandlerThread.run(HandlerThread.java:61) 
I/System.out: Player Error::com.google.android.exoplayer2.ExoPlaybackException: com.google.android.exoplayer2.audio.AudioSink$InitializationException: AudioTrack init failed: 0, Config(32000, 12, 32000)
E/Render TAG: TYPE_RENDERER: AudioTrack init failed: 0, Config(32000, 12, 32000)
这是我的流式音频代码:
//Setting Up Exoplayer
private void SetupPlayer(){
// Create a data source factory.
dataSourceFactory =
new DefaultHttpDataSourceFactory(Util.getUserAgent(this
, getApplicationInfo().loadLabel(getPackageManager()).toString()));
loadControl = new DefaultLoadControl.Builder()
.setBufferDurationsMs(MIN_BUFFER_DURATION, MAX_BUFFER_DURATION, MIN_PLAYBACK_START_BUFFER, MIN_PLAYBACK_RESUME_BUFFER).createDefaultLoadControl();

@DefaultRenderersFactory.ExtensionRendererMode int extensionRendererMode = DefaultRenderersFactory.EXTENSION_RENDERER_MODE_PREFER;

renderersFactory = new DefaultRenderersFactory(this) .setExtensionRendererMode(extensionRendererMode);

// Create a progressive media source pointing to a stream uri.
mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(audio_url));
// Create a player instance.
simpleExoPlayer = new SimpleExoPlayer.Builder(this,renderersFactory).setLoadControl(loadControl).build();
// Prepare the player with the media source.
simpleExoPlayer.prepare(mediaSource, true, true);
}
我搜索了 Stack Overflow,但找不到任何答案。 exoplayer 的版本我使用的是 2.11.8 .我不知道如何解决这个错误。请帮助我提供一些解决方案来修复 Android 5.0 设备中的此错误。

最佳答案

我最近遇到了与 API <23 和 ExoPlayer 2.13.2 完全相同的问题,并且在深入研究时在 ExoPlayer developers web-site 上找到了此注释:

Android’s official emulator (...) supports ExoPlayer provided the system image has an API level of at least 23. System images with earlier API levels do not support ExoPlayer.


不幸的是,我没有支持 API-21 的设备。我仍然会为后代留下这张纸条。

关于java - exoplayer 2.11.* 版本在 android 5.0/5.1(Lollipop) 设备中引发渲染器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63682951/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com