From 906f85da07ff7b1225f947a9bc4cf97e1755bf09 Mon Sep 17 00:00:00 2001 From: daniel oeh Date: Thu, 6 Sep 2012 17:47:47 +0200 Subject: [PATCH] Reset VideoSurface of Videoplayer after it has been destroyed --- .../activity/VideoplayerActivity.java | 1 + .../antennapod/service/PlaybackService.java | 18 ++++++++++++------ .../antennapod/util/PlaybackController.java | 6 ++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/de/danoeh/antennapod/activity/VideoplayerActivity.java b/src/de/danoeh/antennapod/activity/VideoplayerActivity.java index d8a03b9d9..79bb60522 100644 --- a/src/de/danoeh/antennapod/activity/VideoplayerActivity.java +++ b/src/de/danoeh/antennapod/activity/VideoplayerActivity.java @@ -195,6 +195,7 @@ public class VideoplayerActivity extends MediaplayerActivity implements if (AppConfig.DEBUG) Log.d(TAG, "Videosurface was destroyed"); videoSurfaceCreated = false; + controller.notifyVideoSurfaceAbandoned(); } @Override diff --git a/src/de/danoeh/antennapod/service/PlaybackService.java b/src/de/danoeh/antennapod/service/PlaybackService.java index 4b7999561..c6de3e68c 100644 --- a/src/de/danoeh/antennapod/service/PlaybackService.java +++ b/src/de/danoeh/antennapod/service/PlaybackService.java @@ -32,16 +32,13 @@ import de.danoeh.antennapod.PodcastApp; import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.AudioplayerActivity; import de.danoeh.antennapod.activity.VideoplayerActivity; -import de.danoeh.antennapod.asynctask.FeedImageLoader; import de.danoeh.antennapod.feed.Feed; -import de.danoeh.antennapod.feed.FeedImage; import de.danoeh.antennapod.feed.FeedItem; import de.danoeh.antennapod.feed.FeedManager; import de.danoeh.antennapod.feed.FeedMedia; import de.danoeh.antennapod.feed.SimpleChapter; import de.danoeh.antennapod.receiver.MediaButtonReceiver; import de.danoeh.antennapod.receiver.PlayerWidget; -import de.danoeh.antennapod.util.Converter; /** Controls the MediaPlayer that plays a FeedMedia-file */ public class PlaybackService extends Service { @@ -233,7 +230,8 @@ public class PlaybackService extends Service { if (AppConfig.DEBUG) Log.d(TAG, "Gained audio focus"); if (pausedBecauseOfTransientAudiofocusLoss) { - audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_RAISE, 0); + audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, + AudioManager.ADJUST_RAISE, 0); play(); } break; @@ -365,8 +363,12 @@ public class PlaybackService extends Service { } /** Called when the surface holder of the mediaplayer has to be changed. */ - public void resetVideoSurface() { - positionSaver.cancel(true); + private void resetVideoSurface() { + if (AppConfig.DEBUG) + Log.d(TAG, "Resetting video surface"); + if (positionSaver != null) { + positionSaver.cancel(true); + } player.setDisplay(null); player.reset(); player.release(); @@ -381,6 +383,10 @@ public class PlaybackService extends Service { setupMediaplayer(); } + public void notifyVideoSurfaceAbandoned() { + resetVideoSurface(); + } + /** Called after service has extracted the media it is supposed to play. */ private void setupMediaplayer() { if (AppConfig.DEBUG) diff --git a/src/de/danoeh/antennapod/util/PlaybackController.java b/src/de/danoeh/antennapod/util/PlaybackController.java index 34c9be140..2285730e7 100644 --- a/src/de/danoeh/antennapod/util/PlaybackController.java +++ b/src/de/danoeh/antennapod/util/PlaybackController.java @@ -574,4 +574,10 @@ public abstract class PlaybackController { } return false; } + + public void notifyVideoSurfaceAbandoned() { + if (playbackService != null) { + playbackService.notifyVideoSurfaceAbandoned(); + } + } }