Close media player if no more episodes are available for playback
This commit is contained in:
parent
aeebcab202
commit
3e4fd8e518
|
@ -128,6 +128,11 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity
|
|||
public void onShutdownNotification() {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaybackEnd() {
|
||||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue