Remove startWhenPrepared and prepareImmediately
They are always `true` anyway.
This commit is contained in:
parent
acb384b128
commit
1e87e34797
|
@ -99,7 +99,6 @@ public class AutoDownloadTest {
|
|||
FeedMedia media = item.getMedia();
|
||||
new PlaybackServiceStarter(context, media)
|
||||
.callEvenIfRunning(true)
|
||||
.startWhenPrepared(true)
|
||||
.start();
|
||||
Awaitility.await("episode is playing")
|
||||
.atMost(2000, MILLISECONDS)
|
||||
|
|
|
@ -80,7 +80,6 @@ public class FeedItemlistDescriptionAdapter extends ArrayAdapter<FeedItem> {
|
|||
}
|
||||
|
||||
new PlaybackServiceStarter(getContext(), playable)
|
||||
.startWhenPrepared(true)
|
||||
.callEvenIfRunning(true)
|
||||
.start();
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ public class PlayActionButton extends ItemActionButton {
|
|||
}
|
||||
new PlaybackServiceStarter(context, media)
|
||||
.callEvenIfRunning(true)
|
||||
.startWhenPrepared(true)
|
||||
.start();
|
||||
|
||||
if (media.getMediaType() == MediaType.VIDEO) {
|
||||
|
|
|
@ -37,7 +37,6 @@ public class PlayLocalActionButton extends ItemActionButton {
|
|||
|
||||
new PlaybackServiceStarter(context, media)
|
||||
.callEvenIfRunning(true)
|
||||
.startWhenPrepared(true)
|
||||
.start();
|
||||
|
||||
if (media.getMediaType() == MediaType.VIDEO) {
|
||||
|
|
|
@ -47,7 +47,6 @@ public class StreamActionButton extends ItemActionButton {
|
|||
}
|
||||
new PlaybackServiceStarter(context, media)
|
||||
.callEvenIfRunning(true)
|
||||
.startWhenPrepared(true)
|
||||
.start();
|
||||
|
||||
if (media.getMediaType() == MediaType.VIDEO) {
|
||||
|
|
|
@ -32,7 +32,6 @@ public class StreamingConfirmationDialog {
|
|||
private void stream() {
|
||||
new PlaybackServiceStarter(context, playable)
|
||||
.callEvenIfRunning(true)
|
||||
.startWhenPrepared(true)
|
||||
.shouldStreamThisTime(true)
|
||||
.start();
|
||||
}
|
||||
|
|
|
@ -867,7 +867,6 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
|
|||
if (focusChange == AudioManager.AUDIOFOCUS_GAIN && pausedBecauseOfTransientAudiofocusLoss) {
|
||||
pausedBecauseOfTransientAudiofocusLoss = false;
|
||||
new PlaybackServiceStarter(context, getPlayable())
|
||||
.startWhenPrepared(true)
|
||||
.callEvenIfRunning(false)
|
||||
.start();
|
||||
}
|
||||
|
|
|
@ -110,9 +110,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
public static final String EXTRA_PLAYABLE = "PlaybackService.PlayableExtra";
|
||||
public static final String EXTRA_ALLOW_STREAM_THIS_TIME = "extra.de.danoeh.antennapod.core.service.allowStream";
|
||||
public static final String EXTRA_ALLOW_STREAM_ALWAYS = "extra.de.danoeh.antennapod.core.service.allowStreamAlways";
|
||||
public static final String EXTRA_START_WHEN_PREPARED = "extra.de.danoeh.antennapod.core.service.startWhenPrepared";
|
||||
|
||||
public static final String EXTRA_PREPARE_IMMEDIATELY = "extra.de.danoeh.antennapod.core.service.prepareImmediately";
|
||||
|
||||
public static final String ACTION_PLAYER_STATUS_CHANGED = "action.de.danoeh.antennapod.core.service.playerStatusChanged";
|
||||
private static final String AVRCP_ACTION_PLAYER_STATUS_CHANGED = "com.android.music.playstatechanged";
|
||||
|
@ -523,8 +520,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
stateManager.validStartCommandWasReceived();
|
||||
boolean allowStreamThisTime = intent.getBooleanExtra(EXTRA_ALLOW_STREAM_THIS_TIME, false);
|
||||
boolean allowStreamAlways = intent.getBooleanExtra(EXTRA_ALLOW_STREAM_ALWAYS, false);
|
||||
boolean startWhenPrepared = intent.getBooleanExtra(EXTRA_START_WHEN_PREPARED, false);
|
||||
boolean prepareImmediately = intent.getBooleanExtra(EXTRA_PREPARE_IMMEDIATELY, false);
|
||||
sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, 0);
|
||||
if (allowStreamAlways) {
|
||||
UserPreferences.setAllowMobileStreaming(true);
|
||||
|
@ -540,8 +535,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
loadedPlayable -> startPlaying(loadedPlayable, allowStreamThisTime,
|
||||
startWhenPrepared, prepareImmediately),
|
||||
loadedPlayable -> startPlaying(loadedPlayable, allowStreamThisTime),
|
||||
error -> {
|
||||
Log.d(TAG, "Playable was not found. Stopping service.");
|
||||
error.printStackTrace();
|
||||
|
@ -725,7 +719,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
playable -> startPlaying(playable, false, true, true),
|
||||
playable -> startPlaying(playable, false),
|
||||
error -> {
|
||||
Log.d(TAG, "Playable was not loaded from preferences. Stopping service.");
|
||||
error.printStackTrace();
|
||||
|
@ -733,15 +727,12 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
});
|
||||
}
|
||||
|
||||
private void startPlaying(Playable playable, boolean allowStreamThisTime,
|
||||
boolean startWhenPrepared, boolean prepareImmediately) {
|
||||
private void startPlaying(Playable playable, boolean allowStreamThisTime) {
|
||||
boolean localFeed = URLUtil.isContentUrl(playable.getStreamUrl());
|
||||
boolean stream = !playable.localFileAvailable() || localFeed;
|
||||
if (stream && !localFeed && !NetworkUtils.isStreamingAllowed() && !allowStreamThisTime) {
|
||||
displayStreamingNotAllowedNotification(
|
||||
new PlaybackServiceStarter(this, playable)
|
||||
.prepareImmediately(true)
|
||||
.startWhenPrepared(true)
|
||||
.getIntent());
|
||||
PlaybackPreferences.writeNoMediaPlaying();
|
||||
stateManager.stopService();
|
||||
|
@ -752,7 +743,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
PlaybackPreferences.clearCurrentlyPlayingTemporaryPlaybackSpeed();
|
||||
}
|
||||
|
||||
mediaPlayer.playMediaObject(playable, stream, startWhenPrepared, prepareImmediately);
|
||||
mediaPlayer.playMediaObject(playable, stream, true, true);
|
||||
stateManager.validStartCommandWasReceived();
|
||||
updateNotificationAndMediaSession(playable);
|
||||
addPlayableToQueue(playable);
|
||||
|
@ -1005,8 +996,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
&& UserPreferences.isFollowQueue() && !nextItem.getFeed().isLocalFeed()) {
|
||||
displayStreamingNotAllowedNotification(
|
||||
new PlaybackServiceStarter(this, nextItem.getMedia())
|
||||
.prepareImmediately(true)
|
||||
.startWhenPrepared(true)
|
||||
.getIntent());
|
||||
PlaybackPreferences.writeNoMediaPlaying();
|
||||
stateManager.stopService();
|
||||
|
@ -1795,7 +1784,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
Log.d(TAG, "onPlayFromMediaId: mediaId: " + mediaId + " extras: " + extras.toString());
|
||||
FeedMedia p = DBReader.getFeedMedia(Long.parseLong(mediaId));
|
||||
if (p != null) {
|
||||
startPlaying(p, false, true, true);
|
||||
startPlaying(p, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1806,7 +1795,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
List<FeedItem> results = FeedSearcher.searchFeedItems(getBaseContext(), query, 0);
|
||||
if (results.size() > 0 && results.get(0).getMedia() != null) {
|
||||
FeedMedia media = results.get(0).getMedia();
|
||||
startPlaying(media, false, true, true);
|
||||
startPlaying(media, false);
|
||||
return;
|
||||
}
|
||||
onPlay();
|
||||
|
|
|
@ -329,9 +329,7 @@ public abstract class PlaybackController {
|
|||
|
||||
public void playPause() {
|
||||
if (playbackService == null) {
|
||||
new PlaybackServiceStarter(activity, media)
|
||||
.startWhenPrepared(true)
|
||||
.start();
|
||||
new PlaybackServiceStarter(activity, media).start();
|
||||
Log.w(TAG, "Play/Pause button was pressed, but playbackservice was null!");
|
||||
return;
|
||||
}
|
||||
|
@ -352,7 +350,6 @@ public abstract class PlaybackController {
|
|||
break;
|
||||
default:
|
||||
new PlaybackServiceStarter(activity, media)
|
||||
.startWhenPrepared(true)
|
||||
.callEvenIfRunning(true)
|
||||
.start();
|
||||
Log.w(TAG, "Play/Pause button was pressed and PlaybackService state was unknown");
|
||||
|
|
|
@ -11,24 +11,14 @@ import de.danoeh.antennapod.model.playback.Playable;
|
|||
public class PlaybackServiceStarter {
|
||||
private final Context context;
|
||||
private final Playable media;
|
||||
private boolean startWhenPrepared = false;
|
||||
private boolean shouldStreamThisTime = false;
|
||||
private boolean callEvenIfRunning = false;
|
||||
private boolean prepareImmediately = true;
|
||||
|
||||
public PlaybackServiceStarter(Context context, Playable media) {
|
||||
this.context = context;
|
||||
this.media = media;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default value: false
|
||||
*/
|
||||
public PlaybackServiceStarter startWhenPrepared(boolean startWhenPrepared) {
|
||||
this.startWhenPrepared = startWhenPrepared;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default value: false
|
||||
*/
|
||||
|
@ -37,14 +27,6 @@ public class PlaybackServiceStarter {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default value: true
|
||||
*/
|
||||
public PlaybackServiceStarter prepareImmediately(boolean prepareImmediately) {
|
||||
this.prepareImmediately = prepareImmediately;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlaybackServiceStarter shouldStreamThisTime(boolean shouldStreamThisTime) {
|
||||
this.shouldStreamThisTime = shouldStreamThisTime;
|
||||
return this;
|
||||
|
@ -53,10 +35,7 @@ public class PlaybackServiceStarter {
|
|||
public Intent getIntent() {
|
||||
Intent launchIntent = new Intent(context, PlaybackService.class);
|
||||
launchIntent.putExtra(PlaybackService.EXTRA_PLAYABLE, (Parcelable) media);
|
||||
launchIntent.putExtra(PlaybackService.EXTRA_START_WHEN_PREPARED, startWhenPrepared);
|
||||
launchIntent.putExtra(PlaybackService.EXTRA_PREPARE_IMMEDIATELY, prepareImmediately);
|
||||
launchIntent.putExtra(PlaybackService.EXTRA_ALLOW_STREAM_THIS_TIME, shouldStreamThisTime);
|
||||
|
||||
return launchIntent;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue