Direct play from the lists
subsequent play of the next feed item from the queue now works
This commit is contained in:
parent
247ef778aa
commit
42e118626e
|
@ -51,7 +51,7 @@ public class DefaultActionButtonCallback implements ActionButtonCallback {
|
||||||
if (item.hasMedia() && item.getMedia().isCurrentlyPlaying()) {
|
if (item.hasMedia() && item.getMedia().isCurrentlyPlaying()) {
|
||||||
context.sendBroadcast(new Intent(PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE));
|
context.sendBroadcast(new Intent(PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE));
|
||||||
}
|
}
|
||||||
else if (item.hasMedia() && item.getMedia().isPlaying()) {
|
else if (item.hasMedia() && item.getMedia().isCurrentlyPaused()) {
|
||||||
context.sendBroadcast(new Intent(PlaybackService.ACTION_RESUME_PLAY_CURRENT_EPISODE));
|
context.sendBroadcast(new Intent(PlaybackService.ACTION_RESUME_PLAY_CURRENT_EPISODE));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -129,10 +129,20 @@ public class FeedMedia extends FeedFile implements Playable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads playback preferences to determine whether this FeedMedia object is
|
* Reads playback preferences to determine whether this FeedMedia object is
|
||||||
* currently being played and the player status is playing.
|
* currently being played and the current player status is playing.
|
||||||
*/
|
*/
|
||||||
public boolean isCurrentlyPlaying() {
|
public boolean isCurrentlyPlaying() {
|
||||||
return isPlaying() && PlaybackPreferences.getPlayerStatusIsPlaying();
|
return isPlaying() &&
|
||||||
|
((PlaybackPreferences.getCurrentPlayerStatus() == PlaybackPreferences.PLAYER_STATUS_PLAYING));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads playback preferences to determine whether this FeedMedia object is
|
||||||
|
* currently being played and the current player status is paused.
|
||||||
|
*/
|
||||||
|
public boolean isCurrentlyPaused() {
|
||||||
|
return isPlaying() &&
|
||||||
|
((PlaybackPreferences.getCurrentPlayerStatus() == PlaybackPreferences.PLAYER_STATUS_PAUSED));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,18 +44,27 @@ public class PlaybackPreferences implements
|
||||||
/** True if last played media was a video. */
|
/** True if last played media was a video. */
|
||||||
public static final String PREF_CURRENT_EPISODE_IS_VIDEO = "de.danoeh.antennapod.preferences.lastIsVideo";
|
public static final String PREF_CURRENT_EPISODE_IS_VIDEO = "de.danoeh.antennapod.preferences.lastIsVideo";
|
||||||
|
|
||||||
/** True if player status is playing. */
|
/** The current player status as int. */
|
||||||
public static final String PREF_PLAYER_STATUS_IS_PLAYING = "de.danoeh.antennapod.preferences.playerStatusIsPlaying";
|
public static final String PREF_CURRENT_PLAYER_STATUS = "de.danoeh.antennapod.preferences.currentPlayerStatus";
|
||||||
|
|
||||||
/** Value of PREF_CURRENTLY_PLAYING_MEDIA if no media is playing. */
|
/** Value of PREF_CURRENTLY_PLAYING_MEDIA if no media is playing. */
|
||||||
public static final long NO_MEDIA_PLAYING = -1;
|
public static final long NO_MEDIA_PLAYING = -1;
|
||||||
|
|
||||||
|
/** Value of PREF_CURRENT_PLAYER_STATUS if media player status is playing. */
|
||||||
|
public static final int PLAYER_STATUS_PLAYING = 1;
|
||||||
|
|
||||||
|
/** Value of PREF_CURRENT_PLAYER_STATUS if media player status is paused. */
|
||||||
|
public static final int PLAYER_STATUS_PAUSED = 2;
|
||||||
|
|
||||||
|
/** Value of PREF_CURRENT_PLAYER_STATUS if media player status is neither playing nor paused. */
|
||||||
|
public static final int PLAYER_STATUS_OTHER = 3;
|
||||||
|
|
||||||
private long currentlyPlayingFeedId;
|
private long currentlyPlayingFeedId;
|
||||||
private long currentlyPlayingFeedMediaId;
|
private long currentlyPlayingFeedMediaId;
|
||||||
private long currentlyPlayingMedia;
|
private long currentlyPlayingMedia;
|
||||||
private boolean currentEpisodeIsStream;
|
private boolean currentEpisodeIsStream;
|
||||||
private boolean currentEpisodeIsVideo;
|
private boolean currentEpisodeIsVideo;
|
||||||
private boolean playerStatusIsPlaying;
|
private int currentPlayerStatus;
|
||||||
|
|
||||||
private static PlaybackPreferences instance;
|
private static PlaybackPreferences instance;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
@ -92,7 +101,8 @@ public class PlaybackPreferences implements
|
||||||
NO_MEDIA_PLAYING);
|
NO_MEDIA_PLAYING);
|
||||||
currentEpisodeIsStream = sp.getBoolean(PREF_CURRENT_EPISODE_IS_STREAM, true);
|
currentEpisodeIsStream = sp.getBoolean(PREF_CURRENT_EPISODE_IS_STREAM, true);
|
||||||
currentEpisodeIsVideo = sp.getBoolean(PREF_CURRENT_EPISODE_IS_VIDEO, false);
|
currentEpisodeIsVideo = sp.getBoolean(PREF_CURRENT_EPISODE_IS_VIDEO, false);
|
||||||
playerStatusIsPlaying = sp.getBoolean(PREF_PLAYER_STATUS_IS_PLAYING, false);
|
currentPlayerStatus = sp.getInt(PREF_CURRENT_PLAYER_STATUS,
|
||||||
|
PLAYER_STATUS_OTHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -115,9 +125,9 @@ public class PlaybackPreferences implements
|
||||||
currentlyPlayingFeedMediaId = sp.getLong(
|
currentlyPlayingFeedMediaId = sp.getLong(
|
||||||
PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID, NO_MEDIA_PLAYING);
|
PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID, NO_MEDIA_PLAYING);
|
||||||
}
|
}
|
||||||
else if (key.equals(PREF_PLAYER_STATUS_IS_PLAYING)) {
|
else if (key.equals(PREF_CURRENT_PLAYER_STATUS)) {
|
||||||
playerStatusIsPlaying = sp.getBoolean(
|
currentPlayerStatus = sp.getInt(PREF_CURRENT_PLAYER_STATUS,
|
||||||
PREF_PLAYER_STATUS_IS_PLAYING, false);
|
PLAYER_STATUS_OTHER);
|
||||||
EventDistributor.getInstance().sendPlayerStatusUpdateBroadcast();
|
EventDistributor.getInstance().sendPlayerStatusUpdateBroadcast();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,9 +164,9 @@ public class PlaybackPreferences implements
|
||||||
return instance.currentEpisodeIsVideo;
|
return instance.currentEpisodeIsVideo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getPlayerStatusIsPlaying() {
|
public static int getCurrentPlayerStatus() {
|
||||||
instanceAvailable();
|
instanceAvailable();
|
||||||
return instance.playerStatusIsPlaying;
|
return instance.currentPlayerStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -653,11 +653,26 @@ public class PlaybackService extends Service {
|
||||||
editor.putLong(
|
editor.putLong(
|
||||||
PlaybackPreferences.PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID,
|
PlaybackPreferences.PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID,
|
||||||
PlaybackPreferences.NO_MEDIA_PLAYING);
|
PlaybackPreferences.NO_MEDIA_PLAYING);
|
||||||
editor.putBoolean(
|
editor.putInt(
|
||||||
PlaybackPreferences.PREF_PLAYER_STATUS_IS_PLAYING, false);
|
PlaybackPreferences.PREF_CURRENT_PLAYER_STATUS,
|
||||||
|
PlaybackPreferences.PLAYER_STATUS_OTHER);
|
||||||
editor.commit();
|
editor.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getCurrentPlayerStatusAsInt(PlayerStatus playerStatus) {
|
||||||
|
int playerStatusAsInt;
|
||||||
|
switch (playerStatus) {
|
||||||
|
case PLAYING:
|
||||||
|
playerStatusAsInt = PlaybackPreferences.PLAYER_STATUS_PLAYING;
|
||||||
|
break;
|
||||||
|
case PAUSED:
|
||||||
|
playerStatusAsInt = PlaybackPreferences.PLAYER_STATUS_PAUSED;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
playerStatusAsInt = PlaybackPreferences.PLAYER_STATUS_OTHER;
|
||||||
|
}
|
||||||
|
return playerStatusAsInt;
|
||||||
|
}
|
||||||
|
|
||||||
private void writePlaybackPreferences() {
|
private void writePlaybackPreferences() {
|
||||||
if (BuildConfig.DEBUG)
|
if (BuildConfig.DEBUG)
|
||||||
|
@ -668,7 +683,7 @@ public class PlaybackService extends Service {
|
||||||
PlaybackServiceMediaPlayer.PSMPInfo info = mediaPlayer.getPSMPInfo();
|
PlaybackServiceMediaPlayer.PSMPInfo info = mediaPlayer.getPSMPInfo();
|
||||||
MediaType mediaType = mediaPlayer.getCurrentMediaType();
|
MediaType mediaType = mediaPlayer.getCurrentMediaType();
|
||||||
boolean stream = mediaPlayer.isStreaming();
|
boolean stream = mediaPlayer.isStreaming();
|
||||||
boolean isPlaying = (info.playerStatus == PlayerStatus.PLAYING);
|
int playerStatus = getCurrentPlayerStatusAsInt(info.playerStatus);
|
||||||
|
|
||||||
if (info.playable != null) {
|
if (info.playable != null) {
|
||||||
editor.putLong(PlaybackPreferences.PREF_CURRENTLY_PLAYING_MEDIA,
|
editor.putLong(PlaybackPreferences.PREF_CURRENTLY_PLAYING_MEDIA,
|
||||||
|
@ -705,8 +720,8 @@ public class PlaybackService extends Service {
|
||||||
PlaybackPreferences.PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID,
|
PlaybackPreferences.PREF_CURRENTLY_PLAYING_FEEDMEDIA_ID,
|
||||||
PlaybackPreferences.NO_MEDIA_PLAYING);
|
PlaybackPreferences.NO_MEDIA_PLAYING);
|
||||||
}
|
}
|
||||||
editor.putBoolean(
|
editor.putInt(
|
||||||
PlaybackPreferences.PREF_PLAYER_STATUS_IS_PLAYING, isPlaying);
|
PlaybackPreferences.PREF_CURRENT_PLAYER_STATUS, playerStatus);
|
||||||
|
|
||||||
editor.commit();
|
editor.commit();
|
||||||
}
|
}
|
||||||
|
@ -718,10 +733,10 @@ public class PlaybackService extends Service {
|
||||||
SharedPreferences.Editor editor = PreferenceManager
|
SharedPreferences.Editor editor = PreferenceManager
|
||||||
.getDefaultSharedPreferences(getApplicationContext()).edit();
|
.getDefaultSharedPreferences(getApplicationContext()).edit();
|
||||||
PlaybackServiceMediaPlayer.PSMPInfo info = mediaPlayer.getPSMPInfo();
|
PlaybackServiceMediaPlayer.PSMPInfo info = mediaPlayer.getPSMPInfo();
|
||||||
boolean isPlaying = (info.playerStatus == PlayerStatus.PLAYING);
|
int playerStatus = getCurrentPlayerStatusAsInt(info.playerStatus);
|
||||||
|
|
||||||
editor.putBoolean(
|
editor.putInt(
|
||||||
PlaybackPreferences.PREF_PLAYER_STATUS_IS_PLAYING, isPlaying);
|
PlaybackPreferences.PREF_CURRENT_PLAYER_STATUS, playerStatus);
|
||||||
|
|
||||||
editor.commit();
|
editor.commit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,8 @@ public class PlaybackServiceMediaPlayer {
|
||||||
|
|
||||||
|
|
||||||
if (media != null) {
|
if (media != null) {
|
||||||
if (!forceReset && media.getIdentifier().equals(playable.getIdentifier())) {
|
if (!forceReset && media.getIdentifier().equals(playable.getIdentifier())
|
||||||
|
&& playerStatus == PlayerStatus.PLAYING) {
|
||||||
// episode is already playing -> ignore method call
|
// episode is already playing -> ignore method call
|
||||||
if (BuildConfig.DEBUG)
|
if (BuildConfig.DEBUG)
|
||||||
Log.d(TAG, "Method call to playMediaObject was ignored: media file already playing.");
|
Log.d(TAG, "Method call to playMediaObject was ignored: media file already playing.");
|
||||||
|
|
Loading…
Reference in New Issue