我正在開發一個Android媒體播放器流媒體應用程序。我得到以下異常:媒體播放器拋出異常
12-11 11:12:06.298: INFO/StagefrightPlayer(34): setDataSource('10.0.2.2\a.mp3')
12-11 11:12:06.308: DEBUG/mp(618): starting
12-11 11:12:06.308: ERROR/MediaPlayer(618): start called in state 4
12-11 11:12:06.308: ERROR/MediaPlayer(618): error (-38, 0)
12-11 11:12:06.328: ERROR/MediaPlayer(618): error (1, -2147483648)
12-11 11:12:06.328: ERROR/MediaPlayer(618): Error (-38,0)
12-11 11:12:06.409: ERROR/MediaPlayer(618): Error (1,-2147483648)
String url = "10.0.2.2\\a.mp3"; // your URL here MediaPlayer mediaPlayer = new MediaPlayer(); mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { mediaPlayer.setDataSource(url); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { mediaPlayer.prepareAsync(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } Log.d("mp","starting"); mediaPlayer.start();
當使用mediaPlayer.prepare
我收到以下錯誤信息:
12-11 12:08:42.367: ERROR/MediaPlayer(980): error (1, -2147483648)
12-11 12:08:42.367: WARN/System.err(980): java.io.IOException: Prepare failed.: status=0x1
12-11 12:08:42.378: WARN/System.err(980): at android.media.MediaPlayer.prepare(Native Method)
12-11 12:08:42.378: WARN/System.err(980): at mobiledo.pjct.Voicesms.onCreate(Voicesms.java:52)
12-11 12:08:42.387: WARN/System.err(980): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
12-11 12:08:42.387: WARN/System.err(980): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
12-11 12:08:42.387: WARN/System.err(980): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
12-11 12:08:42.387: WARN/System.err(980): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
12-11 12:08:42.387: WARN/System.err(980): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
12-11 12:08:42.387: WARN/System.err(980): at android.os.Handler.dispatchMessage(Handler.java:99)
12-11 12:08:42.418: WARN/System.err(980): at android.os.Looper.loop(Looper.java:123)
12-11 12:08:42.418: WARN/System.err(980): at android.app.ActivityThread.main(ActivityThread.java:3683)
12-11 12:08:42.418: WARN/System.err(980): at java.lang.reflect.Method.invokeNative(Native Method)
12-11 12:08:42.418: WARN/System.err(980): at java.lang.reflect.Method.invoke(Method.java:507)
12-11 12:08:42.418: WARN/System.err(980): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-11 12:08:42.418: WARN/System.err(980): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-11 12:08:42.418: WARN/System.err(980): at dalvik.system.NativeStart.main(Native Method)
不工作表示錯誤 – sajith
十二月12日至11日:05:33.027:INFO/StagefrightPlayer(34):的setDataSource('10 .0.2.2 \ a.mp3 ') 12-11 12:05:33.047:錯誤/ MediaPlayer(867):錯誤(1,-2147483648) 12-11 12:05:33.127:錯誤/ MediaPlayer(867):錯誤(1,-2147483648) – sajith
@sajith - 請發佈完整的錯誤。另外,你是否刪除了對'mediaPlayer.start()'的調用? – MByD