Prevent NPE

This commit is contained in:
Martin Fietz 2016-06-03 11:47:04 +02:00
parent 1048735327
commit c97fb13361
1 changed files with 4 additions and 4 deletions

View File

@ -112,7 +112,7 @@ public class VideoplayerActivity extends MediaplayerActivity {
@Override @Override
protected boolean loadMediaInfo() { protected boolean loadMediaInfo() {
if (!super.loadMediaInfo()) { if (!super.loadMediaInfo() || controller == null) {
return false; return false;
} }
Playable media = controller.getMedia(); Playable media = controller.getMedia();
@ -152,7 +152,7 @@ public class VideoplayerActivity extends MediaplayerActivity {
@Override @Override
protected void onAwaitingVideoSurface() { protected void onAwaitingVideoSurface() {
if (videoSurfaceCreated) { if (videoSurfaceCreated && controller != null) {
Log.d(TAG, "Videosurface already created, setting videosurface now"); Log.d(TAG, "Videosurface already created, setting videosurface now");
Pair<Integer, Integer> videoSize = controller.getVideoSize(); Pair<Integer, Integer> videoSize = controller.getVideoSize();
@ -240,7 +240,7 @@ public class VideoplayerActivity extends MediaplayerActivity {
public void surfaceCreated(SurfaceHolder holder) { public void surfaceCreated(SurfaceHolder holder) {
Log.d(TAG, "Videoview holder created"); Log.d(TAG, "Videoview holder created");
videoSurfaceCreated = true; videoSurfaceCreated = true;
if (controller.getStatus() == PlayerStatus.PLAYING) { if (controller != null && controller.getStatus() == PlayerStatus.PLAYING) {
if (controller.serviceAvailable()) { if (controller.serviceAvailable()) {
controller.setVideoSurface(holder); controller.setVideoSurface(holder);
} else { } else {
@ -254,7 +254,7 @@ public class VideoplayerActivity extends MediaplayerActivity {
public void surfaceDestroyed(SurfaceHolder holder) { public void surfaceDestroyed(SurfaceHolder holder) {
Log.d(TAG, "Videosurface was destroyed"); Log.d(TAG, "Videosurface was destroyed");
videoSurfaceCreated = false; videoSurfaceCreated = false;
if (!destroyingDueToReload) { if (controller != null && !destroyingDueToReload) {
controller.notifyVideoSurfaceAbandoned(); controller.notifyVideoSurfaceAbandoned();
} }
} }