在播放歌曲时(下载后),我在mplayer.setDataSource(fis.getFD());
. 为什么我在这里遇到异常?
while (isDownloading)
{
try
{
String filePath = PATH + sponser;
FileInputStream fis = new FileInputStream(filePath);
mplayer.setDataSource(fis.getFD() );
mplayer.setOnPreparedListener(new OnPreparedListener()
{
@Override
public void onPrepared(MediaPlayer mp) {
}
});
mplayer.prepare();
mplayer.start();
mplayer.setOnCompletionListener(new OnCompletionListener()
{
@Override
public void onCompletion(MediaPlayer mp)
{
}
});
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
isDownloading = false;
}
}
日志猫:
03-07 17:20:14.400: W/System.err(3942): java.lang.NullPointerException
03-07 17:20:14.400: W/System.err(3942): at com.nelitemusic.MyMixes$CustomAdapter$1.onClick(MyMixes.java:399)
03-07 17:20:14.410: W/System.err(3942): at android.view.View.performClick(View.java:3127)
03-07 17:20:14.410: W/System.err(3942): at android.view.View$PerformClick.run(View.java:12025)
03-07 17:20:14.410: W/System.err(3942): at android.os.Handler.handleCallback(Handler.java:587)
03-07 17:20:14.410: W/System.err(3942): at android.os.Handler.dispatchMessage(Handler.java:92)
03-07 17:20:14.420: W/System.err(3942): at android.os.Looper.loop(Looper.java:132)
03-07 17:20:14.420: W/System.err(3942): at android.app.ActivityThread.main(ActivityThread.java:4126)
03-07 17:20:14.420: W/System.err(3942): at java.lang.reflect.Method.invokeNative(Native Method)
03-07 17:20:14.420: W/System.err(3942): at java.lang.reflect.Method.invoke(Method.java:491)
03-07 17:20:14.420: W/System.err(3942): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
03-07 17:20:14.420: W/System.err(3942): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
03-07 17:20:14.420: W/System.err(3942): at dalvik.system.NativeStart.main(Native Method)