summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2013-03-10 19:27:22 +0100
committerdaniel oeh <daniel.oeh@gmail.com>2013-03-10 19:27:22 +0100
commit3e4fd8e518446ebdb20c8833f942bf968d0dd10f (patch)
tree419e759ebd68b85401e2f55f484a7a309a9dbf90 /src
parentaeebcab2020df0aff8b74e153f6d86bbc6c2a5d1 (diff)
downloadAntennaPod-3e4fd8e518446ebdb20c8833f942bf968d0dd10f.zip
Close media player if no more episodes are available for playback
Diffstat (limited to 'src')
-rw-r--r--src/de/danoeh/antennapod/activity/MediaplayerActivity.java5
-rw-r--r--src/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java12
-rw-r--r--src/de/danoeh/antennapod/service/PlaybackService.java34
-rw-r--r--src/de/danoeh/antennapod/util/playback/PlaybackController.java5
4 files changed, 45 insertions, 11 deletions
diff --git a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java
index 10a879c06..6d27a82e0 100644
--- a/src/de/danoeh/antennapod/activity/MediaplayerActivity.java
+++ b/src/de/danoeh/antennapod/activity/MediaplayerActivity.java
@@ -128,6 +128,11 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity
public void onShutdownNotification() {
finish();
}
+
+ @Override
+ public void onPlaybackEnd() {
+ finish();
+ }
};
}
diff --git a/src/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java b/src/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java
index 94aa2b0fc..1b7d77193 100644
--- a/src/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java
+++ b/src/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java
@@ -162,6 +162,18 @@ public class ExternalPlayerFragment extends SherlockFragment {
}
}
+
+ @Override
+ public void onPlaybackEnd() {
+ if (fragmentLayout != null) {
+ fragmentLayout.setVisibility(View.GONE);
+ }
+ controller = setupPlaybackController();
+ if (butPlay != null) {
+ butPlay.setOnClickListener(controller
+ .newOnPlayButtonClickListener());
+ }
+ }
};
}
diff --git a/src/de/danoeh/antennapod/service/PlaybackService.java b/src/de/danoeh/antennapod/service/PlaybackService.java
index c596b6938..811b02535 100644
--- a/src/de/danoeh/antennapod/service/PlaybackService.java
+++ b/src/de/danoeh/antennapod/service/PlaybackService.java
@@ -103,6 +103,8 @@ public class PlaybackService extends Service {
public static final int NOTIFICATION_TYPE_SLEEPTIMER_UPDATE = 4;
public static final int NOTIFICATION_TYPE_BUFFER_START = 5;
public static final int NOTIFICATION_TYPE_BUFFER_END = 6;
+ /** No more episodes are going to be played. */
+ public static final int NOTIFICATION_TYPE_PLAYBACK_END = 7;
/**
* Returned by getPositionSafe() or getDurationSafe() if the playbackService
@@ -493,7 +495,9 @@ public class PlaybackService extends Service {
player.release();
player = createMediaPlayer();
status = PlayerStatus.STOPPED;
- initMediaplayer();
+ if (media != null) {
+ initMediaplayer();
+ }
}
public void notifyVideoSurfaceAbandoned() {
@@ -727,24 +731,32 @@ public class PlaybackService extends Service {
} else {
if (AppConfig.DEBUG)
Log.d(TAG,
- "No more episodes available to play; Reloading current episode");
+ "No more episodes available to play");
+ media = null;
prepareImmediately = startWhenPrepared = false;
stopForeground(true);
stopWidgetUpdater();
}
int notificationCode = 0;
- shouldStream = !media.localFileAvailable();
- if (media.getMediaType() == MediaType.AUDIO) {
- notificationCode = EXTRA_CODE_AUDIO;
- playingVideo = false;
- } else if (media.getMediaType() == MediaType.VIDEO) {
- notificationCode = EXTRA_CODE_VIDEO;
+ if (media != null) {
+ shouldStream = !media.localFileAvailable();
+ if (media.getMediaType() == MediaType.AUDIO) {
+ notificationCode = EXTRA_CODE_AUDIO;
+ playingVideo = false;
+ } else if (media.getMediaType() == MediaType.VIDEO) {
+ notificationCode = EXTRA_CODE_VIDEO;
+ }
}
writePlaybackPreferences();
- resetVideoSurface();
- refreshRemoteControlClientState();
- sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, notificationCode);
+ if (media != null) {
+ resetVideoSurface();
+ refreshRemoteControlClientState();
+ sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, notificationCode);
+ } else {
+ sendNotificationBroadcast(NOTIFICATION_TYPE_PLAYBACK_END, 0);
+ stopSelf();
+ }
}
public void setSleepTimer(long waitingTime) {
diff --git a/src/de/danoeh/antennapod/util/playback/PlaybackController.java b/src/de/danoeh/antennapod/util/playback/PlaybackController.java
index ce66ac8ea..331e2bf0c 100644
--- a/src/de/danoeh/antennapod/util/playback/PlaybackController.java
+++ b/src/de/danoeh/antennapod/util/playback/PlaybackController.java
@@ -320,6 +320,9 @@ public abstract class PlaybackController {
case PlaybackService.NOTIFICATION_TYPE_BUFFER_END:
onBufferEnd();
break;
+ case PlaybackService.NOTIFICATION_TYPE_PLAYBACK_END:
+ onPlaybackEnd();
+ break;
}
} else {
@@ -357,6 +360,8 @@ public abstract class PlaybackController {
public abstract void onSleepTimerUpdate();
public abstract void handleError(int code);
+
+ public abstract void onPlaybackEnd();
/**
* Is called whenever the PlaybackService changes it's status. This method