Android的MediaPlayer的需要很长的时间,以prepare和缓冲液 [英] Android MediaPlayer takes long time to prepare and buffer

查看:1325
本文介绍了Android的MediaPlayer的需要很长的时间,以prepare和缓冲液的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要很长的时间来prepare和缓冲音频流。我已经阅读了这个问题<一href="http://stackoverflow.com/questions/6582908/why-does-it-take-so-long-for-androids-mediaplayer-to-$p$ppare-some-live-streams">Why要花这么长的时间Android的MediaPlayer的,以prepare一些实时流播放?的,但它只是说的人都经历过这个问题,但没有说明如何改善这一问​​题。

My application takes a long time to prepare and buffer an audio stream. I have read this question Why does it take so long for Android's MediaPlayer to prepare some live streams for playback?, however it just says people have experienced this issue, it does not state how to improve the problem.

我遇到这在所有Android版本,从2.2测试 - 4.1.2。

I am experiencing this in all versions of Android, tested from 2.2 - 4.1.2.

的流是在一个合适的比特率用于移动和3G连接。相同的流花费不到一秒钟开始缓冲在等效iOS应用

The streams are in a suitable bit-rate for mobile and 3G connection. The same stream takes less than a second to start buffering in the equivalent iOS app.

有没有一种方法,以指定的时间应该缓冲多少?我知道,收听广播的应用程序提供此功能(<一href="https://play.google.com/store/apps/details?id=tunein.player">https://play.google.com/store/apps/details?id=tunein.player )。

Is there a way to specify the amount of time that should be buffered? I know that the Tune In radio application offers this feature ( https://play.google.com/store/apps/details?id=tunein.player ).

感谢。

编辑:我再次测试,发现它只是发生在运行姜饼及以上(> = 2.3)的设备。我知道Android修改了底层架构的的OpenCore到StageFright。那么,如何优化媒体框架?这似乎只是错误的,旧的HTC野火可以prepare,流播放,硬是比全新的HTC One X的和Nexus 7快10倍。

I've tested again and found that it only happens on devices running Gingerbread and above (>=2.3). I know that Android changed the underlying framework from OpenCore to StageFright. So how can I optimise the media framework? It just seems wrong that the old HTC Wildfire can prepare, stream and play, literally 10x faster than the brand new HTC One X and Nexus 7.

推荐答案

真的是没有什么可以做,因为在Android的MediaPlayer类不提供获得较低级别的设置,如缓冲区的大小。唯一的选择是使用AudioTrack和像FFmpeg的图书馆做解码,使自己的播放器。

There really isn't much you can do since the Android MediaPlayer class doesn't provide access to lower level settings such as buffer size. The only alternative would be to make your own player using AudioTrack and a library like FFmpeg to do the decoding.

这篇关于Android的MediaPlayer的需要很长的时间,以prepare和缓冲液的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆