The way the app works is that I have a list of videos. The video view will play the videos and the user can swipe left or right to move from video to video.
The app works bug-free in all other devices I have tested on. (Samsung Galaxy Tab 7, Samsung Galaxy Player, Acer Iconia A500, Nook Color, LG Optimus, Kindle Fire)
Then I tested on the Nook Tablet. I am getting a NullPointerException. This occurs when I swipe in one direction (vid1 > vid2), then swipe back the other direction (vid2 > vid1).
Here is the section of the code that crashed:
private void playVideo(ViewFlipper flipper){
LinearLayout flipperchild = (LinearLayout) flipper.getCurrentView();
VideoView video = (VideoView) flipperchild.getChildAt(0);
if(preVideoView != null){
preVideoView.stopPlayback();
preVideoView.setVisibility(View.INVISIBLE);
}
// Current Video
nextVideoView = video;
// Current Video for pausing
pauseVideoView = nextVideoView;
nextVideoView.setVisibility(View.VISIBLE);
nextVideoView.requestFocus();
nextVideoView.start();
// Stores the current video, so when I change videos this
// becomes the previous video
preVideoView = nextVideoView;
isPlaying = true;
nextVideoView.setOnTouchListener(videoViewTouch);
}
Here is the log I took:
E/AndroidRuntime(27744): FATAL EXCEPTION: main
E/AndroidRuntime(27744): java.lang.NullPointerException
E/AndroidRuntime(27744): at android.widget.VideoView.openVideo(VideoView.java:330)
E/AndroidRuntime(27744): at android.widget.VideoView.access$2600(VideoView.java:60)
E/AndroidRuntime(27744): at android.widget.VideoView$6.surfaceCreated(VideoView.java:604)
E/AndroidRuntime(27744): at android.view.SurfaceView.updateWindow(SurfaceView.java:547)
E/AndroidRuntime(27744): at android.view.SurfaceView.setVisibility(SurfaceView.java:221)
E/AndroidRuntime(27744): at com.selectsoft.gymnasticskids.VideoChapter.playVideo(VideoChapter.java:407)
E/AndroidRuntime(27744): at com.selectsoft.gymnasticskids.VideoChapter.access$2(VideoChapter.java:397)
E/AndroidRuntime(27744): at com.selectsoft.gymnasticskids.VideoChapter$OnTouchViewFlipper.onTouch(VideoChapter.java:376)
E/AndroidRuntime(27744): at android.view.View.dispatchTouchEvent(View.java:3882)
E/AndroidRuntime(27744): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:914)
E/AndroidRuntime(27744): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
E/AndroidRuntime(27744): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
E/AndroidRuntime(27744): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
E/AndroidRuntime(27744): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
E/AndroidRuntime(27744): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
E/AndroidRuntime(27744): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
E/AndroidRuntime(27744): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1852)
E/AndroidRuntime(27744): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1271)
E/AndroidRuntime(27744): at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
E/AndroidRuntime(27744): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1836)
E/AndroidRuntime(27744): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2198)
E/AndroidRuntime(27744): at android.view.ViewRoot.handleMessage(ViewRoot.java:1882)
E/AndroidRuntime(27744): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(27744): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime(27744): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime(27744): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(27744): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(27744): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime(27744): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime(27744): at dalvik.system.NativeStart.main(Native Method)
I am not sure what's causing the null pointer, but I have tried using both
setContentView();
VideoView video = (VideoView) findViewById(R.id.chapterVideoView);
But they didn't work out. At this point I am pretty stumped, and would like some help.
Regards,
Jaime