Videoview Seekbar的Runnable接口中的空指针异常

时间:2016-05-10 06:07:38

标签: android nullpointerexception android-recyclerview android-videoview

我在SeekBar列表的VideoView中使用了自定义RecyclerView。当我按下后退按钮并再次启动活动时,它会抛出Null pointer exception。 NPE位于Runnable界面,应用程序崩溃。

E/AndroidRuntime: FATAL EXCEPTION: main
Process: exoplayer.com.youtubesurfaceviewplayer, PID: 16750
java.lang.NullPointerException
    at adapter.VideoRecyclerAdapter$13$1.run(VideoRecyclerAdapter.java:531)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:149)
    at android.app.ActivityThread.main(ActivityThread.java:5045)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610)
    at dalvik.system.NativeStart.main(Native Method)

-

Runnable onEverySecond = new Runnable() {
    public void run() {
        long Duration = mediaPlayer.getDuration();//Throws NPE in this line
        long current = mediaPlayer.getCurrentPosition();//Throws NPE in this line
        // Displaying Total Duration time
        lblDuration.setText("" + utils.stringForTime(Duration));
        // Displaying time completed playing
        lblCurrentPosition.setText(utils.stringForTime(current));
        // Updating progress bar
        int progress = (int) (utils.getProgressPercentage(currentDuration, totalDuration));
        long remainingTime = (Duration - current);
        lblRemainingPosition.setText("-"+utils.stringForTime(remainingTime));
        mediacontroller_progress.setProgress(progress);
        // Running this thread after 100 milliseconds
        handler.postDelayed(this, 100);
    }
};

0 个答案:

没有答案