1

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

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) - “谷歌播放音乐”和“视频播放器”都失败并出现相同的错误代码:

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)

任何建议将不胜感激。

-德米特里

4

1 回答 1

0

异步播放器?http://developer.android.com/reference/android/media/AsyncPlayer.html

AsyncPlayer ap=new AsyncPlayer("Player"); 
ap.play(this, Uri.parse(url), true, AudioManager.STREAM_MUSIC);
于 2012-12-04T18:52:28.607 回答