diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2014-03-28 20:38:01 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2014-03-28 20:38:01 +0100 |
commit | 1048939f69a1924a8a9509b493a2f0ed46648941 (patch) | |
tree | 876791608cebb6232b5c912b3ac5d49c1dd8c15d /src | |
parent | ae09dbffb6746641a5658750085af08f5ff60e47 (diff) | |
download | AntennaPod-1048939f69a1924a8a9509b493a2f0ed46648941.zip |
Enable screen timeout when video is paused. closes #368
Diffstat (limited to 'src')
3 files changed, 41 insertions, 4 deletions
diff --git a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java index 27ac7afd8..8e659af14 100644 --- a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java +++ b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java @@ -135,6 +135,12 @@ public abstract class MediaplayerActivity extends ActionBarActivity public void onPlaybackSpeedChange() { MediaplayerActivity.this.onPlaybackSpeedChange(); } + + @Override + protected void setScreenOn(boolean enable) { + super.setScreenOn(enable); + MediaplayerActivity.this.setScreenOn(enable); + } }; } @@ -151,6 +157,9 @@ public abstract class MediaplayerActivity extends ActionBarActivity setTheme(UserPreferences.getTheme()); } + protected void setScreenOn(boolean enable) { + } + @Override protected void onCreate(Bundle savedInstanceState) { chooseTheme(); @@ -243,7 +252,8 @@ public abstract class MediaplayerActivity extends ActionBarActivity menu.findItem(R.id.support_item).setVisible( media != null && media.getPaymentLink() != null && (media instanceof FeedMedia) && - ((FeedMedia) media).getItem().getFlattrStatus().flattrable()); + ((FeedMedia) media).getItem().getFlattrStatus().flattrable() + ); menu.findItem(R.id.share_link_item).setVisible( media != null && media.getWebsiteLink() != null); menu.findItem(R.id.visit_website_item).setVisible( @@ -285,7 +295,8 @@ public abstract class MediaplayerActivity extends ActionBarActivity dialog.dismiss(); controller.disableSleepTimer(); } - }); + } + ); stDialog.setNegativeButton(R.string.cancel_label, new DialogInterface.OnClickListener() { @@ -294,7 +305,8 @@ public abstract class MediaplayerActivity extends ActionBarActivity int which) { dialog.dismiss(); } - }); + } + ); stDialog.create().show(); } break; @@ -451,7 +463,8 @@ public abstract class MediaplayerActivity extends ActionBarActivity dialog.dismiss(); finish(); } - }); + } + ); errorDialog.create().show(); } diff --git a/src/de/danoeh/antennapod/activity/VideoplayerActivity.java b/src/de/danoeh/antennapod/activity/VideoplayerActivity.java index 489d57340..a3a542753 100644 --- a/src/de/danoeh/antennapod/activity/VideoplayerActivity.java +++ b/src/de/danoeh/antennapod/activity/VideoplayerActivity.java @@ -337,4 +337,14 @@ public class VideoplayerActivity extends MediaplayerActivity { return R.layout.videoplayer_activity; } + + @Override + protected void setScreenOn(boolean enable) { + super.setScreenOn(enable); + if (enable) { + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + } else { + getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + } + } } diff --git a/src/de/danoeh/antennapod/util/playback/PlaybackController.java b/src/de/danoeh/antennapod/util/playback/PlaybackController.java index 0781800aa..2e1abecd6 100644 --- a/src/de/danoeh/antennapod/util/playback/PlaybackController.java +++ b/src/de/danoeh/antennapod/util/playback/PlaybackController.java @@ -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); @@ -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 |