mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-01-31 10:54:50 +01:00
if it was skipped we shouldn't remove it, but otherwise we should
This commit is contained in:
parent
6d0465ad13
commit
5b6fce427b
@ -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;
|
||||
}
|
||||
};
|
||||
|
@ -217,7 +217,7 @@ public class UserPreferences {
|
||||
return prefs.getBoolean(PREF_FOLLOW_QUEUE, false);
|
||||
}
|
||||
|
||||
public static boolean isSkipRemoveFromQueue() { return prefs.getBoolean(PREF_SKIP_REMOVES, false); }
|
||||
public static boolean shouldSkipRemoveFromQueue() { return prefs.getBoolean(PREF_SKIP_REMOVES, false); }
|
||||
|
||||
public static boolean isAutoDelete() {
|
||||
return prefs.getBoolean(PREF_AUTO_DELETE, false);
|
||||
|
@ -14,7 +14,6 @@ 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;
|
||||
@ -164,7 +163,6 @@ public class PlaybackService extends Service {
|
||||
|
||||
private static final int NOTIFICATION_ID = 1;
|
||||
|
||||
private RemoteControlClient remoteControlClient;
|
||||
private PlaybackServiceMediaPlayer mediaPlayer;
|
||||
private PlaybackServiceTaskManager taskManager;
|
||||
|
||||
@ -343,7 +341,7 @@ public class PlaybackService extends Service {
|
||||
|
||||
break;
|
||||
case KeyEvent.KEYCODE_MEDIA_NEXT:
|
||||
endPlayback(true);
|
||||
endPlayback(true, true);
|
||||
break;
|
||||
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
|
||||
mediaPlayer.seekDelta(UserPreferences.getFastFowardSecs() * 1000);
|
||||
@ -544,13 +542,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();
|
||||
@ -577,7 +575,7 @@ public class PlaybackService extends Service {
|
||||
e.printStackTrace();
|
||||
// isInQueue remains false
|
||||
}
|
||||
if (isInQueue && UserPreferences.isSkipRemoveFromQueue()) {
|
||||
if (isInQueue && (!wasSkipped || UserPreferences.shouldSkipRemoveFromQueue())) {
|
||||
DBWriter.removeQueueItem(PlaybackService.this, item, true);
|
||||
}
|
||||
DBWriter.addItemToPlaybackHistory(media);
|
||||
@ -1094,7 +1092,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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -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();
|
||||
public void endPlayback(final boolean wasSkipped) {
|
||||
executor.submit(() -> {
|
||||
playerLock.lock();
|
||||
releaseWifiLockIfNecessary();
|
||||
|
||||
if (playerStatus != PlayerStatus.INDETERMINATE) {
|
||||
setPlayerStatus(PlayerStatus.INDETERMINATE, media);
|
||||
}
|
||||
if (mediaPlayer != null) {
|
||||
mediaPlayer.reset();
|
||||
|
||||
}
|
||||
audioManager.abandonAudioFocus(audioFocusChangeListener);
|
||||
callback.endPlayback(true);
|
||||
|
||||
playerLock.unlock();
|
||||
if (playerStatus != PlayerStatus.INDETERMINATE) {
|
||||
setPlayerStatus(PlayerStatus.INDETERMINATE, media);
|
||||
}
|
||||
if (mediaPlayer != null) {
|
||||
mediaPlayer.reset();
|
||||
|
||||
}
|
||||
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:
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 39 KiB |
Loading…
x
Reference in New Issue
Block a user