diff options
Diffstat (limited to 'src/de/danoeh/antennapod/util/playback/PlaybackController.java')
-rw-r--r-- | src/de/danoeh/antennapod/util/playback/PlaybackController.java | 44 |
1 files changed, 29 insertions, 15 deletions
diff --git a/src/de/danoeh/antennapod/util/playback/PlaybackController.java b/src/de/danoeh/antennapod/util/playback/PlaybackController.java index 0781800aa..1992fce2c 100644 --- a/src/de/danoeh/antennapod/util/playback/PlaybackController.java +++ b/src/de/danoeh/antennapod/util/playback/PlaybackController.java @@ -15,7 +15,7 @@ import android.view.View.OnClickListener; import android.widget.ImageButton; import android.widget.SeekBar; import android.widget.TextView; -import de.danoeh.antennapod.AppConfig; +import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.R; import de.danoeh.antennapod.feed.Chapter; import de.danoeh.antennapod.feed.FeedMedia; @@ -114,7 +114,7 @@ public abstract class PlaybackController { * example in the activity's onStop() method. */ public void release() { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Releasing PlaybackController"); try { @@ -160,7 +160,7 @@ public abstract class PlaybackController { * as the arguments of the launch intent. */ private void bindToService() { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Trying to connect to service"); AsyncTask<Void, Void, Intent> intentLoader = new AsyncTask<Void, Void, Intent>() { @Override @@ -173,7 +173,7 @@ public abstract class PlaybackController { boolean bound = false; if (!PlaybackService.started) { if (serviceIntent != null) { - if (AppConfig.DEBUG) Log.d(TAG, "Calling start service"); + if (BuildConfig.DEBUG) Log.d(TAG, "Calling start service"); activity.startService(serviceIntent); bound = activity.bindService(serviceIntent, mConnection, 0); } else { @@ -182,13 +182,13 @@ public abstract class PlaybackController { handleStatus(); } } else { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "PlaybackService is running, trying to connect without start command."); bound = activity.bindService(new Intent(activity, PlaybackService.class), mConnection, 0); } - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Result for service binding: " + bound); } }; @@ -200,7 +200,7 @@ public abstract class PlaybackController { * played media or null if no last played media could be found. */ private Intent getPlayLastPlayedMediaIntent() { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Trying to restore last played media"); SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(activity.getApplicationContext()); @@ -229,7 +229,7 @@ public abstract class PlaybackController { return serviceIntent; } } - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "No last played media found"); return null; } @@ -242,7 +242,7 @@ public abstract class PlaybackController { || (positionObserverFuture != null && positionObserverFuture .isDone()) || positionObserverFuture == null) { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Setting up position observer"); positionObserver = new MediaPositionObserver(); positionObserverFuture = schedExecutor.scheduleWithFixedDelay( @@ -255,7 +255,7 @@ public abstract class PlaybackController { private void cancelPositionObserver() { if (positionObserverFuture != null) { boolean result = positionObserverFuture.cancel(true); - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "PositionObserver cancelled. Result: " + result); } } @@ -268,7 +268,7 @@ public abstract class PlaybackController { .getService(); if (!released) { queryService(); - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Connection to Service established"); } else { Log.i(TAG, "Connection to playback service has been established, but controller has already been released"); @@ -278,7 +278,7 @@ public abstract class PlaybackController { @Override public void onServiceDisconnected(ComponentName name) { playbackService = null; - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Disconnected from Service"); } @@ -287,7 +287,7 @@ public abstract class PlaybackController { protected BroadcastReceiver statusUpdate = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Received statusUpdate Intent."); if (isConnectedToPlaybackService()) { PlaybackServiceMediaPlayer.PSMPInfo info = playbackService.getPSMPInfo(); @@ -345,7 +345,7 @@ public abstract class PlaybackController { } } else { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Bad arguments. Won't handle intent"); } } else { @@ -422,12 +422,16 @@ public abstract class PlaybackController { checkMediaInfoLoaded(); cancelPositionObserver(); updatePlayButtonAppearance(playResource, playText); + if (PlaybackService.getCurrentMediaType() == MediaType.VIDEO) { + setScreenOn(false); + } break; case PLAYING: clearStatusMsg(); checkMediaInfoLoaded(); if (PlaybackService.getCurrentMediaType() == MediaType.VIDEO) { onAwaitingVideoSurface(); + setScreenOn(true); } setupPositionObserver(); updatePlayButtonAppearance(pauseResource, pauseText); @@ -487,7 +491,7 @@ public abstract class PlaybackController { * information has to be refreshed */ void queryService() { - if (AppConfig.DEBUG) + if (BuildConfig.DEBUG) Log.d(TAG, "Querying service info"); if (playbackService != null) { status = playbackService.getStatus(); @@ -551,6 +555,16 @@ public abstract class PlaybackController { } } + /** + * Should be implemented by classes that show a video. The default implementation + * does nothing + * + * @param enable True if the screen should be kept on, false otherwise + */ + protected void setScreenOn(boolean enable) { + + } + public OnClickListener newOnPlayButtonClickListener() { return new OnClickListener() { @Override |