Android的MediaPlayer的是preparing太长 [英] Android MediaPlayer is preparing too long

查看:355
本文介绍了Android的MediaPlayer的是preparing太长的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿, 我使用的MediaPlayer播放常规Shoutcast的流。在code是简单的用prepareAsync()和处理程序,开始播放。虽然它完美的作品与像DI.FM或ETN.FM(http://u10.di.fm:80/di_progressive)某些流,与其他人(http://mp3.wpsu.org:8000/)它赢得了牛逼晃过prepare状态。没有其他的侦听器或者叫做。

Hey, I'm using MediaPlayer to play a regular ShoutCast stream. The code is straightforward with prepareAsync() and a handler to start the playback. While it works flawlessly with some streams like DI.FM or ETN.FM (http://u10.di.fm:80/di_progressive), with others (http://mp3.wpsu.org:8000/) it won't go past the prepare state. No other listeners are called either.

//Uri streamUri = Uri.parse("http://u10.di.fm:80/di_progressive"); /* works */
Uri streamUri = Uri.parse("http://mp3.wpsu.org:8000/"); /* stuck on prepare state */
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setOnPreparedListener(new OnPreparedListener() {
    public void onPrepared(MediaPlayer mp) {
        mp.start();
    }
});
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(this.getBaseContext(), streamUri);
mediaPlayer.prepareAsync();

任何反馈AP preciated!

Any feedback is appreciated!

推荐答案

我认为有与服务器端的一些兼容性问题。 这是很奇怪的,因为模拟器处理它在我的情况好 - 只是没有在我的升级Froyo的Galaxy S,即使是相同的API版本

I think that there are some compatibility problems with the server end. This is rather strange since the emulator handles it ok in my case - just not on my Froyo Galaxy S, even though it is the same API version.

这可能是一个codeC问题,HTTP流的问题,我不知道。 但是,所有失败的服务器往往是旧的,以版权1998至2004年,在底部...不完全是最近的,最新的,你会觉得

It could be a codec issue, http streaming issue, I do not know. But all the servers that fail tend to be old ones, with "Copyright 1998 - 2004" at the bottom... Not exactly recent or up to date you would think.

一个潜在的解决方法(我还没有尝试过)会使用<一个href="http://$c$c.google.com/p/npr-android-app/source/browse/trunk/Npr/src/org/npr/android/news/StreamProxy.java"相对=nofollow> StreamProxy ,这样也会使2.1甚至更早版本太贵code兼容。在额外的工作,额外的code中的成本,毫无疑问额外的错误...

One potential workaround (which I have not tried yet) would be to use the StreamProxy, which would also make your code compatible with 2.1 and possibly earlier versions too. At the cost of extra work, extra code, and without doubt extra bugs...

在情况下,你都没有意识到这一点,还有另一名球员的bug报告2.2这可能是相关的太: <一href="http://stackoverflow.com/questions/3937610/basic-streaming-audio-works-in-2-1-but-not-in-2-2">Basic音频流工作在2.1,但不是在2.2

In case you are not aware of it, there is another player bug report for 2.2 which may be relevant too: Basic streaming audio works in 2.1 but not in 2.2

这篇关于Android的MediaPlayer的是preparing太长的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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