英文:
exoplayer 2.11.* version throws Renderer error in android 5.0/5.1(Lollipop) devices
问题
我正在使用exoplayer
从firebase存储
流式传输我的音频文件到我的安卓应用程序。在安卓版本>= 6.0
中,exoplayer
运行良好。但是在Android 5.0/5.1(棒棒糖)
设备上,exoplayer
抛出一个Renderer错误
。
以下是我收到的错误:
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)
...
E/Render TAG: TYPE_RENDERER: AudioTrack init failed: 0, Config(32000, 12, 32000)
以下是我的音频流式传输代码:
//设置Exoplayer
private void SetupPlayer(){
// 创建数据源工厂。
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);
// 创建指向流媒体uri的渐进式媒体源。
mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(audio_url));
// 创建播放器实例。
simpleExoPlayer = new SimpleExoPlayer.Builder(this,renderersFactory).setLoadControl(loadControl).build();
// 使用媒体源准备播放器。
simpleExoPlayer.prepare(mediaSource, true, true);
}
我在Stack Overflow上搜索过,但没有找到任何答案。我使用的exoplayer
版本是2.11.8
。我不知道如何修复这个错误。请帮我提供一些解决方案,以修复在Android 5.0设备上的这个错误。
英文:
I am using exoplayer
for streaming my audio file from firebase storage
to my android app. exoplayer
works great in android versions which is >= 6.0
. But in Android 5.0/5.1(Lollipop)
devices, exoplayer
throws me a Renderer error
.
Here's the Error i got:
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)
Here's my Code for streaming audio:
//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);
}
I searched Stack Overflow but unable to find any answers. The version of exoplayer
i am using was 2.11.8
. I don't know how to fix this error. Please help me with some solutions to fix this error in Android 5.0 devices.
答案1
得分: 1
我最近遇到了与 API <23 和 ExoPlayer 2.13.2 相同的问题,当我深入研究时,在 ExoPlayer 开发者网站 上找到了这个说明:
Android 的官方模拟器(...)支持 ExoPlayer,前提是系统镜像至少具有 API 级别 23。具有较早 API 级别的系统镜像不支持 ExoPlayer。
不幸的是,我没有一台搭载 API-21 的设备。尽管如此,我将留下这个说明供将来的用户参考。
英文:
I've got the exact same issue recently with API <23 and ExoPlayer 2.13.2 and while digging in found this note on 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.
Unfortunately, I don't have an API-21-powered device. Still I will leave this note for future generations.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论