2014-03-25 58 views
0

這裏是我的IO異常錯誤的logcat ....如何解決通過媒體播放器播放任何音頻/視頻文件的錯誤?

03-25 09:41:17.950: D/dalvikvm(10906): GC_FOR_ALLOC freed 42K, 7% free 2629K/2800K, paused 54ms, total 60ms 
03-25 09:41:17.962: I/dalvikvm-heap(10906): Grow heap (frag case) to 3.167MB for 512016-byte allocation 
03-25 09:41:18.030: D/dalvikvm(10906): GC_FOR_ALLOC freed 2K, 6% free 3126K/3304K, paused 64ms, total 64ms 
03-25 09:41:18.149: D/dalvikvm(10906): GC_CONCURRENT freed <1K, 6% free 3126K/3304K, paused 12ms+8ms, total 119ms 
03-25 09:41:18.289: D/dalvikvm(10906): GC_FOR_ALLOC freed <1K, 6% free 3126K/3304K, paused 36ms, total 36ms 
03-25 09:41:18.349: I/dalvikvm-heap(10906): Grow heap (frag case) to 6.637MB for 3640620-byte allocation 
03-25 09:41:18.439: D/dalvikvm(10906): GC_CONCURRENT freed 0K, 3% free 6681K/6860K, paused 30ms+5ms, total 99ms 
03-25 09:41:19.089: D/gralloc_goldfish(10906): Emulator without GPU emulation detected. 
03-25 09:41:24.129: D/dalvikvm(10906): GC_CONCURRENT freed 515K, 8% free 7537K/8172K, paused 6ms+7ms, total 301ms 
03-25 09:41:28.030: D/++++++++++++length++++++++++(10906): 3 
03-25 09:41:28.479: I/Choreographer(10906): Skipped 570 frames! The application may be doing too much work on its main thread. 
03-25 09:41:29.730: I/Choreographer(10906): Skipped 96 frames! The application may be doing too much work on its main thread. 
03-25 09:41:32.980: E/MediaPlayer(10906): error (1, -2147483648) 
03-25 09:41:33.000: W/System.err(10906): java.io.IOException: Prepare failed.: status=0x1 
03-25 09:41:33.011: W/System.err(10906): at android.media.MediaPlayer.prepare(Native Method) 
03-25 09:41:33.020: W/System.err(10906): at com.example.assetsfolderaccess.PlayFromAssetsActivity$1.onItemClick(PlayFromAssetsActivity.java:80) 
03-25 09:41:33.030: W/System.err(10906): at android.widget.AdapterView.performItemClick(AdapterView.java:298) 
03-25 09:41:33.030: W/System.err(10906): at android.widget.AbsListView.performItemClick(AbsListView.java:1100) 
03-25 09:41:33.039: W/System.err(10906): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2749) 
03-25 09:41:33.049: W/System.err(10906): at android.widget.AbsListView$1.run(AbsListView.java:3423) 
03-25 09:41:33.049: W/System.err(10906): at android.os.Handler.handleCallback(Handler.java:725) 
03-25 09:41:33.059: W/System.err(10906): at android.os.Handler.dispatchMessage(Handler.java:92) 
03-25 09:41:33.069: W/System.err(10906): at android.os.Looper.loop(Looper.java:137) 
03-25 09:41:33.069: W/System.err(10906): at android.app.ActivityThread.main(ActivityThread.java:5041) 
03-25 09:41:33.079: W/System.err(10906): at java.lang.reflect.Method.invokeNative(Native Method) 
03-25 09:41:33.089: W/System.err(10906): at java.lang.reflect.Method.invoke(Method.java:511) 
03-25 09:41:33.089: W/System.err(10906): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
03-25 09:41:33.099: W/System.err(10906): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
03-25 09:41:33.109: W/System.err(10906): at dalvik.system.NativeStart.main(Native Method) 
03-25 09:44:43.119: D/dalvikvm(11364): GC_FOR_ALLOC freed 46K, 7% free 2629K/2804K, paused 284ms, total 288ms 
03-25 09:44:43.129: I/dalvikvm-heap(11364): Grow heap (frag case) to 3.167MB for 512016-byte allocation 
03-25 09:44:43.349: D/dalvikvm(11364): GC_FOR_ALLOC freed 2K, 6% free 3126K/3308K, paused 218ms, total 218ms 
03-25 09:44:43.519: D/dalvikvm(11364): GC_CONCURRENT freed <1K, 6% free 3126K/3308K, paused 32ms+18ms, total 170ms 
03-25 09:44:43.749: D/dalvikvm(11364): GC_FOR_ALLOC freed <1K, 6% free 3126K/3308K, paused 70ms, total 70ms 
03-25 09:44:43.829: I/dalvikvm-heap(11364): Grow heap (frag case) to 6.637MB for 3640620-byte allocation 
03-25 09:44:44.049: D/dalvikvm(11364): GC_CONCURRENT freed 0K, 3% free 6681K/6864K, paused 91ms+9ms, total 224ms 
03-25 09:44:44.689: D/gralloc_goldfish(11364): Emulator without GPU emulation detected. 
03-25 09:47:09.600: D/dalvikvm(11364): GC_CONCURRENT freed 515K, 8% free 7534K/8172K, paused 78ms+142ms, total 459ms 
03-25 09:47:14.040: D/++++++++++++length++++++++++(11364): 3 
03-25 09:47:14.080: I/Choreographer(11364): Skipped 598 frames! The application may be doing too much work on its main thread. 
03-25 09:47:15.039: I/Choreographer(11364): Skipped 85 frames! The application may be doing too much work on its main thread. 
03-25 09:47:20.260: D/-----path----(11364): arti.mp3 
03-25 09:47:20.299: E/MediaPlayer(11364): error (1, -2147483648) 
03-25 09:47:20.319: W/System.err(11364): java.io.IOException: Prepare failed.: status=0x1 
03-25 09:47:20.330: W/System.err(11364): at android.media.MediaPlayer.prepare(Native Method) 
03-25 09:47:20.330: W/System.err(11364): at com.example.assetsfolderaccess.PlayFromAssetsActivity$1.onItemClick(PlayFromAssetsActivity.java:82) 
03-25 09:47:20.339: W/System.err(11364): at android.widget.AdapterView.performItemClick(AdapterView.java:298) 
03-25 09:47:20.339: W/System.err(11364): at android.widget.AbsListView.performItemClick(AbsListView.java:1100) 
03-25 09:47:20.350: W/System.err(11364): at android.widget.AbsListView$PerformClick.run(AbsListView.java:2749) 
03-25 09:47:20.350: W/System.err(11364): at android.widget.AbsListView$1.run(AbsListView.java:3423) 
03-25 09:47:20.350: W/System.err(11364): at android.os.Handler.handleCallback(Handler.java:725) 
03-25 09:47:20.371: W/System.err(11364): at android.os.Handler.dispatchMessage(Handler.java:92) 
03-25 09:47:20.371: W/System.err(11364): at android.os.Looper.loop(Looper.java:137) 
03-25 09:47:20.379: W/System.err(11364): at android.app.ActivityThread.main(ActivityThread.java:5041) 
03-25 09:47:20.390: W/System.err(11364): at java.lang.reflect.Method.invokeNative(Native Method) 
03-25 09:47:20.390: W/System.err(11364): at java.lang.reflect.Method.invoke(Method.java:511) 
03-25 09:47:20.399: W/System.err(11364): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
03-25 09:47:20.399: W/System.err(11364): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
03-25 09:47:20.399: W/System.err(11364): at dalvik.system.NativeStart.main(Native Method) 

這裏是我的代碼.....

itemlist.setOnItemClickListener(new OnItemClickListener() { 

    @Override 
    public void onItemClick(AdapterView<?> parent, 
      View v, int pos, long id) { 
     // TODO Auto-generated method stub 
     String path = parent.getItemAtPosition(pos).toString(); 

     Toast.makeText(getApplicationContext(), path, 
       Toast.LENGTH_SHORT).show(); 

     Log.d("-----path----","" +path); 
     mp=new MediaPlayer(); 
     try { 

      mp.reset(); 
      mp.setDataSource(path); 
      /*mp.setOnPreparedListener(new OnPreparedListener() { 
       @Override 
       public void onPrepared(MediaPlayer mp) { 
        // TODO Auto-generated method stub 
       } 
      });*/ 
      mp.prepare(); 
      mp.start(); 
     } catch (Exception e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
    } 
}); 

回答

0

錯誤顯示:

The application may be doing too much work on its main thread. 

出現此錯誤當用戶在主線程中執行繁重的操作時,請記住Android是單線程系統,其中有單個主線程,其中所有其他子系統都會掛接以執行任務,如活動,服務,內容供應商。這就是爲什麼當你在主線程上直接執行網絡操作時,你會得到這樣的信息。

0

器Rstart您的AVD,你可以試試這個

itemlist.setOnItemClickListener(new OnItemClickListener() { 
    @Override 
    public void onItemClick(AdapterView<?> parent, 
      View v, int pos, long id) { 
     // TODO Auto-generated method stub 
     String path = parent.getItemAtPosition(pos).toString(); 

     Toast.makeText(getApplicationContext(), path, 
       Toast.LENGTH_SHORT).show(); 

     // Log.d("-----path----","" +path); 
     mp=new MediaPlayer(); 
     try { 
      AssetFileDescriptor descriptor; 
      descriptor = yourclassName.this.getAssets().openFd(test.mp3); 
      mp.setDataSource(descriptor.getFileDescriptor(),descriptor.getStartOffset(),descriptor.getLength()); 
      descriptor.close(); 
      mp.prepare(); 
      mp.start 

     } catch (Exception e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
     } 
    } 
}); 
相關問題