版本4.2的Android音频流问题

时间:2012-12-04 17:10:45

标签: android audio-streaming

我正在构建音频流应用。这是我用来启动媒体播放器的代码:

Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse("http://wunh.org:8000/"), "audio/*");
startActivity(intent);

代码在我的Droid手机(Android 2.3.4)上工作正常 - 它会调出手机媒体播放器并播放电台......

但它无法在Nexus 7(Android 4.2)上运行 - “Google播放音乐”和“视频播放器”都失败并出现相同的错误代码:

  

12-04 11:49:25.373:E / MediaPlayer(13331):错误(1,-1004)

UPD:这里是所有相关的logcat条目:

12-04 14:04:21.573: D/MediaPlayer(17933): Couldn't open file on client side, trying server side
12-04 14:04:21.573: I/AwesomePlayer(128): setDataSource_l(URL suppressed)
12-04 14:04:21.583: V/ChromiumHTTPDataSource(128): connect on behalf of uid 10036
12-04 14:04:21.583: I/ChromiumHTTPDataSource(128): connect to <URL suppressed> @0
12-04 14:04:21.633: I/ActivityManager(481): Displayed com.google.android.music/.AudioPreview: +83ms
12-04 14:05:24.733: I/ChromiumHTTPDataSourceSupport(128): Request failed with status 4 and os_error -118
12-04 14:05:24.733: I/AwesomePlayer(128): mConnectingDataSource->connect() returned -1004
12-04 14:05:24.733: E/MediaPlayer(17933): error (1, -1004)
12-04 14:05:24.733: E/MediaPlayer(17933): Error (1,-1004)

任何建议都将不胜感激。

-Dmitry

1 个答案:

答案 0 :(得分:0)

AsyncPlayer? http://developer.android.com/reference/android/media/AsyncPlayer.html

AsyncPlayer ap=new AsyncPlayer("Player"); 
ap.play(this, Uri.parse(url), true, AudioManager.STREAM_MUSIC);