summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hennen <TomHennen@users.noreply.github.com>2015-09-26 15:20:08 -0400
committerTom Hennen <TomHennen@users.noreply.github.com>2015-09-26 15:20:08 -0400
commita6ddb1319c78121d8b954183705cb3200d9c1e13 (patch)
tree28be9152abd9515cff6eab403847df99f2ef4805
parentfc4d9225bfa9dabf7945cfeb9b8dfc96c19e4976 (diff)
parentc097b672d628cf893d103b7e582748b1152c937c (diff)
downloadAntennaPod-a6ddb1319c78121d8b954183705cb3200d9c1e13.zip
Merge pull request #1214 from TomHennen/update_playback_notification
Update playback notification
-rw-r--r--app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java30
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java33
-rw-r--r--app/src/main/res/xml/preferences.xml8
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java5
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java169
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java53
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java1
-rw-r--r--core/src/main/res/values/strings.xml2
8 files changed, 163 insertions, 138 deletions
diff --git a/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java b/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java
index 133d4152a..96bcd6452 100644
--- a/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java
+++ b/app/src/androidTest/java/de/test/antennapod/service/playback/PlaybackServiceMediaPlayerTest.java
@@ -183,7 +183,7 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase {
}
@Override
- public boolean endPlayback(boolean playNextEpisode) {
+ public boolean endPlayback(boolean playNextEpisode, boolean wasSkipped) {
return false;
}
@@ -252,7 +252,7 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase {
}
@Override
- public boolean endPlayback(boolean playNextEpisode) {
+ public boolean endPlayback(boolean playNextEpisode, boolean wasSkipped) {
return false;
}
};
@@ -324,7 +324,7 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase {
}
@Override
- public boolean endPlayback(boolean playNextEpisode) {
+ public boolean endPlayback(boolean playNextEpisode, boolean wasSkipped) {
return false;
}
};
@@ -397,7 +397,7 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase {
}
@Override
- public boolean endPlayback(boolean playNextEpisode) {
+ public boolean endPlayback(boolean playNextEpisode, boolean wasSkipped) {
return false;
}
@@ -464,7 +464,7 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase {
}
@Override
- public boolean endPlayback(boolean playNextEpisode) {
+ public boolean endPlayback(boolean playNextEpisode, boolean wasSkipped) {
return false;
}
@@ -532,7 +532,7 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase {
}
@Override
- public boolean endPlayback(boolean playNextEpisode) {
+ public boolean endPlayback(boolean playNextEpisode, boolean wasSkipped) {
return false;
}
};
@@ -602,7 +602,7 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase {
}
@Override
- public boolean endPlayback(boolean playNextEpisode) {
+ public boolean endPlayback(boolean playNextEpisode, boolean wasSkipped) {
return false;
}
};
@@ -675,7 +675,7 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase {
}
@Override
- public boolean endPlayback(boolean playNextEpisode) {
+ public boolean endPlayback(boolean playNextEpisode, boolean wasSkipped) {
return false;
}
};
@@ -713,9 +713,7 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase {
}
@Override
- public boolean onMediaPlayerInfo(int code) {
- return false;
- }
+ public boolean onMediaPlayerInfo(int code) { return false; }
@Override
public boolean onMediaPlayerError(Object inObj, int what, int extra) {
@@ -723,7 +721,7 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase {
}
@Override
- public boolean endPlayback(boolean playNextEpisode) {
+ public boolean endPlayback(boolean playNextEpisode, boolean wasSkipped) {
return false;
}
};
@@ -795,7 +793,7 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase {
}
@Override
- public boolean endPlayback(boolean playNextEpisode) {
+ public boolean endPlayback(boolean playNextEpisode, boolean wasSkipped) {
return false;
}
};
@@ -901,7 +899,7 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase {
}
@Override
- public boolean endPlayback(boolean playNextEpisode) {
+ public boolean endPlayback(boolean playNextEpisode, boolean wasSkipped) {
return false;
}
};
@@ -982,7 +980,7 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase {
}
@Override
- public boolean endPlayback(boolean playNextEpisode) {
+ public boolean endPlayback(boolean playNextEpisode, boolean wasSkipped) {
return false;
}
};
@@ -1076,7 +1074,7 @@ public class PlaybackServiceMediaPlayerTest extends InstrumentationTestCase {
}
@Override
- public boolean endPlayback(boolean playNextEpisode) {
+ public boolean endPlayback(boolean playNextEpisode, boolean wasSkipped) {
return false;
}
};
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java
index 634c3c546..85e0e45ca 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/ExternalPlayerFragment.java
@@ -141,26 +141,12 @@ public class ExternalPlayerFragment extends Fragment {
@Override
public void onShutdownNotification() {
- if (fragmentLayout != null) {
- fragmentLayout.setVisibility(View.GONE);
- }
- controller = setupPlaybackController();
- if (butPlay != null) {
- butPlay.setOnClickListener(controller
- .newOnPlayButtonClickListener());
- }
+ playbackDone();
}
@Override
public void onPlaybackEnd() {
- if (fragmentLayout != null) {
- fragmentLayout.setVisibility(View.GONE);
- }
- controller = setupPlaybackController();
- if (butPlay != null) {
- butPlay.setOnClickListener(controller
- .newOnPlayButtonClickListener());
- }
+ playbackDone();
}
@Override
@@ -192,6 +178,21 @@ public class ExternalPlayerFragment extends Fragment {
}
}
+ private void playbackDone() {
+ if (fragmentLayout != null) {
+ fragmentLayout.setVisibility(View.GONE);
+ }
+ if (controller != null) {
+ controller.release();
+ }
+ controller = setupPlaybackController();
+ if (butPlay != null) {
+ butPlay.setOnClickListener(controller
+ .newOnPlayButtonClickListener());
+ }
+ controller.init();
+ }
+
private boolean loadMediaInfo() {
Log.d(TAG, "Loading media info");
if (controller != null && controller.serviceAvailable()) {
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index af20eddfd..30381162c 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -83,7 +83,7 @@
android:summary="@string/pref_unpauseOnHeadsetReconnect_sum"
android:title="@string/pref_unpauseOnHeadsetReconnect_title"/>
<CheckBoxPreference
- android:defaultValue="false"
+ android:defaultValue="true"
android:enabled="true"
android:key="prefFollowQueue"
android:summary="@string/pref_followQueue_sum"
@@ -91,6 +91,12 @@
<CheckBoxPreference
android:defaultValue="false"
android:enabled="true"
+ android:key="prefSkipRemovesFromQueue"
+ android:summary="@string/pref_skip_removes_from_queue_sum"
+ android:title="@string/pref_skip_removes_from_queue_title"/>
+ <CheckBoxPreference
+ android:defaultValue="false"
+ android:enabled="true"
android:key="prefAutoDelete"
android:summary="@string/pref_auto_delete_sum"
android:title="@string/pref_auto_delete_title"/>
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
index e6a2a2464..0aa9f2876 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/UserPreferences.java
@@ -57,6 +57,7 @@ public class UserPreferences {
public static final String PREF_PAUSE_ON_HEADSET_DISCONNECT = "prefPauseOnHeadsetDisconnect";
public static final String PREF_UNPAUSE_ON_HEADSET_RECONNECT = "prefUnpauseOnHeadsetReconnect";
public static final String PREF_FOLLOW_QUEUE = "prefFollowQueue";
+ public static final String PREF_SKIP_REMOVES = "prefSkipRemovesFromQueue";
public static final String PREF_AUTO_DELETE = "prefAutoDelete";
public static final String PREF_SMART_MARK_AS_PLAYED_SECS = "prefSmartMarkAsPlayedSecs";
public static final String PREF_PLAYBACK_SPEED_ARRAY = "prefPlaybackSpeedArray";
@@ -213,9 +214,11 @@ public class UserPreferences {
public static boolean isFollowQueue() {
- return prefs.getBoolean(PREF_FOLLOW_QUEUE, false);
+ return prefs.getBoolean(PREF_FOLLOW_QUEUE, true);
}
+ public static boolean shouldSkipRemoveFromQueue() { return prefs.getBoolean(PREF_SKIP_REMOVES, false); }
+
public static boolean isAutoDelete() {
return prefs.getBoolean(PREF_AUTO_DELETE, false);
}
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
index 9b6d17b98..a040ee157 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java
@@ -2,6 +2,7 @@ package de.danoeh.antennapod.core.service.playback;
import android.annotation.SuppressLint;
import android.app.Notification;
+import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.bluetooth.BluetoothA2dp;
@@ -14,12 +15,12 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.AudioManager;
import android.media.MediaPlayer;
-import android.media.RemoteControlClient;
import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
+import android.support.v4.media.session.MediaSessionCompat;
import android.util.Log;
import android.util.Pair;
import android.view.KeyEvent;
@@ -48,6 +49,7 @@ import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.receiver.MediaButtonReceiver;
import de.danoeh.antennapod.core.storage.DBTasks;
import de.danoeh.antennapod.core.storage.DBWriter;
+import de.danoeh.antennapod.core.util.IntList;
import de.danoeh.antennapod.core.util.QueueAccess;
import de.danoeh.antennapod.core.util.flattr.FlattrUtils;
import de.danoeh.antennapod.core.util.playback.Playable;
@@ -163,7 +165,6 @@ public class PlaybackService extends Service {
private static final int NOTIFICATION_ID = 1;
- private RemoteControlClient remoteControlClient;
private PlaybackServiceMediaPlayer mediaPlayer;
private PlaybackServiceTaskManager taskManager;
@@ -342,6 +343,8 @@ public class PlaybackService extends Service {
break;
case KeyEvent.KEYCODE_MEDIA_NEXT:
+ mediaPlayer.endPlayback(true);
+ break;
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
mediaPlayer.seekDelta(UserPreferences.getFastFowardSecs() * 1000);
break;
@@ -541,13 +544,13 @@ public class PlaybackService extends Service {
}
@Override
- public boolean endPlayback(boolean playNextEpisode) {
- PlaybackService.this.endPlayback(true);
+ public boolean endPlayback(boolean playNextEpisode, boolean wasSkipped) {
+ PlaybackService.this.endPlayback(playNextEpisode, wasSkipped);
return true;
}
};
- private void endPlayback(boolean playNextEpisode) {
+ private void endPlayback(boolean playNextEpisode, boolean wasSkipped) {
Log.d(TAG, "Playback ended");
final Playable playable = mediaPlayer.getPlayable();
@@ -574,7 +577,7 @@ public class PlaybackService extends Service {
e.printStackTrace();
// isInQueue remains false
}
- if (isInQueue) {
+ if (isInQueue && (!wasSkipped || UserPreferences.shouldSkipRemoveFromQueue())) {
DBWriter.removeQueueItem(PlaybackService.this, item, true);
}
DBWriter.addItemToPlaybackHistory(media);
@@ -821,80 +824,94 @@ public class PlaybackService extends Service {
final int smallIcon = ClientConfig.playbackServiceCallbacks.getNotificationIconResource(getApplicationContext());
if (!Thread.currentThread().isInterrupted() && started && info.playable != null) {
- String contentText = info.playable.getFeedTitle();
- String contentTitle = info.playable.getEpisodeTitle();
+ String contentText = info.playable.getEpisodeTitle();
+ String contentTitle = info.playable.getFeedTitle();
Notification notification = null;
- if (android.os.Build.VERSION.SDK_INT >= 16) {
- Intent pauseButtonIntent = new Intent( // pause button intent
- PlaybackService.this, PlaybackService.class);
- pauseButtonIntent.putExtra(
- MediaButtonReceiver.EXTRA_KEYCODE,
- KeyEvent.KEYCODE_MEDIA_PAUSE);
- PendingIntent pauseButtonPendingIntent = PendingIntent
- .getService(PlaybackService.this, 0,
- pauseButtonIntent,
- PendingIntent.FLAG_UPDATE_CURRENT);
- Intent playButtonIntent = new Intent( // play button intent
- PlaybackService.this, PlaybackService.class);
- playButtonIntent.putExtra(
- MediaButtonReceiver.EXTRA_KEYCODE,
- KeyEvent.KEYCODE_MEDIA_PLAY);
- PendingIntent playButtonPendingIntent = PendingIntent
- .getService(PlaybackService.this, 1,
- playButtonIntent,
- PendingIntent.FLAG_UPDATE_CURRENT);
- Intent stopButtonIntent = new Intent( // stop button intent
- PlaybackService.this, PlaybackService.class);
- stopButtonIntent.putExtra(
- MediaButtonReceiver.EXTRA_KEYCODE,
- KeyEvent.KEYCODE_MEDIA_STOP);
- PendingIntent stopButtonPendingIntent = PendingIntent
- .getService(PlaybackService.this, 2,
- stopButtonIntent,
- PendingIntent.FLAG_UPDATE_CURRENT);
- Notification.Builder notificationBuilder = new Notification.Builder(
- PlaybackService.this)
- .setContentTitle(contentTitle)
- .setContentText(contentText)
- .setOngoing(true)
- .setContentIntent(pIntent)
- .setLargeIcon(icon)
- .setSmallIcon(smallIcon)
- .setPriority(UserPreferences.getNotifyPriority()); // set notification priority
- if (playerStatus == PlayerStatus.PLAYING) {
- notificationBuilder.addAction(android.R.drawable.ic_media_pause, //pause action
- getString(R.string.pause_label),
- pauseButtonPendingIntent);
- } else {
- notificationBuilder.addAction(android.R.drawable.ic_media_play, //play action
- getString(R.string.play_label),
- playButtonPendingIntent);
- }
- if (UserPreferences.isPersistNotify()) {
- notificationBuilder.addAction(android.R.drawable.ic_menu_close_clear_cancel, // stop action
- getString(R.string.stop_label),
- stopButtonPendingIntent);
- }
- if (Build.VERSION.SDK_INT >= 21) {
- notificationBuilder.setStyle(new Notification.MediaStyle()
- .setMediaSession((android.media.session.MediaSession.Token) mediaPlayer.getSessionToken().getToken())
- .setShowActionsInCompactView(0))
- .setVisibility(Notification.VISIBILITY_PUBLIC)
- .setColor(Notification.COLOR_DEFAULT);
- }
+ Intent pauseButtonIntent = new Intent( // pause button intent
+ PlaybackService.this, PlaybackService.class);
+ pauseButtonIntent.putExtra(
+ MediaButtonReceiver.EXTRA_KEYCODE,
+ KeyEvent.KEYCODE_MEDIA_PAUSE);
+ PendingIntent pauseButtonPendingIntent = PendingIntent
+ .getService(PlaybackService.this, 0,
+ pauseButtonIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT);
+ Intent playButtonIntent = new Intent( // play button intent
+ PlaybackService.this, PlaybackService.class);
+ playButtonIntent.putExtra(
+ MediaButtonReceiver.EXTRA_KEYCODE,
+ KeyEvent.KEYCODE_MEDIA_PLAY);
+ PendingIntent playButtonPendingIntent = PendingIntent
+ .getService(PlaybackService.this, 1,
+ playButtonIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT);
+ Intent stopButtonIntent = new Intent( // stop button intent
+ PlaybackService.this, PlaybackService.class);
+ stopButtonIntent.putExtra(
+ MediaButtonReceiver.EXTRA_KEYCODE,
+ KeyEvent.KEYCODE_MEDIA_STOP);
+ PendingIntent stopButtonPendingIntent = PendingIntent
+ .getService(PlaybackService.this, 2,
+ stopButtonIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT);
+ Intent skipButtonIntent = new Intent(
+ PlaybackService.this, PlaybackService.class);
+ skipButtonIntent.putExtra(
+ MediaButtonReceiver.EXTRA_KEYCODE,
+ KeyEvent.KEYCODE_MEDIA_NEXT);
+ PendingIntent skipButtonPendingIntent = PendingIntent
+ .getService(PlaybackService.this, 3,
+ skipButtonIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT);
+ NotificationCompat.Builder notificationBuilder = new android.support.v7.app.NotificationCompat.Builder(
+ PlaybackService.this)
+ .setContentTitle(contentTitle)
+ .setContentText(contentText)
+ .setOngoing(false)
+ .setContentIntent(pIntent)
+ .setLargeIcon(icon)
+ .setSmallIcon(smallIcon)
+ .setWhen(0) // we don't need the time
+ .setPriority(UserPreferences.getNotifyPriority()); // set notification priority
+ IntList actionList = new IntList();
+ if (playerStatus == PlayerStatus.PLAYING) {
+ notificationBuilder.addAction(android.R.drawable.ic_media_pause, //pause action
+ getString(R.string.pause_label),
+ pauseButtonPendingIntent);
+ actionList.add(actionList.size());
+ } else {
+ notificationBuilder.addAction(android.R.drawable.ic_media_play, //play action
+ getString(R.string.play_label),
+ playButtonPendingIntent);
+ actionList.add(actionList.size());
+ }
+ if (UserPreferences.isFollowQueue()) {
+ notificationBuilder.addAction(android.R.drawable.ic_media_next,
+ getString(R.string.skip_episode_label),
+ skipButtonPendingIntent);
+ actionList.add(actionList.size());
+ }
+
+ notificationBuilder.setStyle(new android.support.v7.app.NotificationCompat.MediaStyle()
+ .setMediaSession(mediaPlayer.getSessionToken())
+ .setShowActionsInCompactView(actionList.toArray())
+ .setShowCancelButton(true)
+ .setCancelButtonIntent(stopButtonPendingIntent))
+ .setVisibility(Notification.VISIBILITY_PUBLIC)
+ .setColor(Notification.COLOR_DEFAULT);
+
+ notification = notificationBuilder.build();
- notification = notificationBuilder.build();
+ if (playerStatus == PlayerStatus.PLAYING ||
+ playerStatus == PlayerStatus.PREPARING ||
+ playerStatus == PlayerStatus.SEEKING) {
+ startForeground(NOTIFICATION_ID, notification);
} else {
- NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(
- PlaybackService.this)
- .setContentTitle(contentTitle)
- .setContentText(contentText).setOngoing(true)
- .setContentIntent(pIntent).setLargeIcon(icon)
- .setSmallIcon(smallIcon);
- notification = notificationBuilder.build();
+ stopForeground(false);
+ NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ mNotificationManager.notify(NOTIFICATION_ID, notification);
}
- startForeground(NOTIFICATION_ID, notification);
Log.d(TAG, "Notification set up");
}
}
@@ -1071,7 +1088,7 @@ public class PlaybackService extends Service {
public void onReceive(Context context, Intent intent) {
if (StringUtils.equals(intent.getAction(), ACTION_SKIP_CURRENT_EPISODE)) {
Log.d(TAG, "Received SKIP_CURRENT_EPISODE intent");
- mediaPlayer.endPlayback();
+ mediaPlayer.endPlayback(true);
}
}
};
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java
index 7cf7eb622..705cb987a 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackServiceMediaPlayer.java
@@ -275,7 +275,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
private void updateMediaSessionMetadata() {
executor.execute(() -> {
final Playable p = this.media;
- if(p == null) {
+ if (p == null) {
return;
}
MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder();
@@ -930,25 +930,22 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
};
- public void endPlayback() {
- executor.submit(new Runnable() {
- @Override
- public void run() {
- playerLock.lock();
- releaseWifiLockIfNecessary();
-
- if (playerStatus != PlayerStatus.INDETERMINATE) {
- setPlayerStatus(PlayerStatus.INDETERMINATE, media);
- }
- if (mediaPlayer != null) {
- mediaPlayer.reset();
+ public void endPlayback(final boolean wasSkipped) {
+ executor.submit(() -> {
+ playerLock.lock();
+ releaseWifiLockIfNecessary();
- }
- audioManager.abandonAudioFocus(audioFocusChangeListener);
- callback.endPlayback(true);
+ if (playerStatus != PlayerStatus.INDETERMINATE) {
+ setPlayerStatus(PlayerStatus.INDETERMINATE, media);
+ }
+ if (mediaPlayer != null) {
+ mediaPlayer.reset();
- playerLock.unlock();
}
+ audioManager.abandonAudioFocus(audioFocusChangeListener);
+ callback.endPlayback(true, wasSkipped);
+
+ playerLock.unlock();
});
}
@@ -1006,20 +1003,20 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
}
}
- public static interface PSMPCallback {
- public void statusChanged(PSMPInfo newInfo);
+ public interface PSMPCallback {
+ void statusChanged(PSMPInfo newInfo);
- public void shouldStop();
+ void shouldStop();
- public void playbackSpeedChanged(float s);
+ void playbackSpeedChanged(float s);
- public void onBufferingUpdate(int percent);
+ void onBufferingUpdate(int percent);
- public boolean onMediaPlayerInfo(int code);
+ boolean onMediaPlayerInfo(int code);
- public boolean onMediaPlayerError(Object inObj, int what, int extra);
+ boolean onMediaPlayerError(Object inObj, int what, int extra);
- public boolean endPlayback(boolean playNextEpisode);
+ boolean endPlayback(boolean playNextEpisode, boolean wasSkipped);
}
private IPlayer setMediaPlayerListeners(IPlayer mp) {
@@ -1062,7 +1059,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
};
private void genericOnCompletion() {
- endPlayback();
+ endPlayback(false);
}
private final org.antennapod.audio.MediaPlayer.OnBufferingUpdateListener audioBufferingUpdateListener = new org.antennapod.audio.MediaPlayer.OnBufferingUpdateListener() {
@@ -1177,7 +1174,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
@Override
public void onSkipToNext() {
super.onSkipToNext();
- endPlayback();
+ endPlayback(true);
}
@Override
@@ -1266,7 +1263,7 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
case KeyEvent.KEYCODE_MEDIA_NEXT:
{
Log.d(TAG, "Received next event from RemoteControlClient");
- endPlayback();
+ endPlayback(true);
return true;
}
default:
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java
index efeba888b..4eb955913 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/util/playback/PlaybackController.java
@@ -120,6 +120,7 @@ public abstract class PlaybackController {
throw new IllegalStateException(
"Can't call init() after release() has been called");
}
+ checkMediaInfoLoaded();
}
/**
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index 951b0b9ba..2881f7c41 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -272,6 +272,8 @@
<string name="pref_auto_delete_title">Auto Delete</string>
<string name="pref_smart_mark_as_played_sum">Mark episodes as played even if less than a certain amount of seconds of playing time is still left</string>
<string name="pref_smart_mark_as_played_title">Smart mark as played</string>
+ <string name="pref_skip_removes_from_queue_sum">Remove episodes from the queue when they are skipped</string>
+ <string name="pref_skip_removes_from_queue_title">Skip Removes Episode</string>
<string name="playback_pref">Playback</string>
<string name="network_pref">Network</string>
<string name="pref_autoUpdateIntervallOrTime_title">Update Interval or Time of Day</string>