No need to have other classes depend on the entire playback service when they just need one constant

This commit is contained in:
ByteHamster 2022-11-05 13:18:48 +01:00
parent 323149642a
commit ae3971a58f
8 changed files with 59 additions and 69 deletions

View File

@ -35,6 +35,7 @@ import de.danoeh.antennapod.core.event.DownloadEvent;
import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.core.service.download.DownloadService;
import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; import de.danoeh.antennapod.core.service.download.DownloadRequestCreator;
import de.danoeh.antennapod.core.feed.FeedUrlNotFoundException; import de.danoeh.antennapod.core.feed.FeedUrlNotFoundException;
import de.danoeh.antennapod.core.service.playback.PlaybackServiceInterface;
import de.danoeh.antennapod.core.util.DownloadErrorLabel; import de.danoeh.antennapod.core.util.DownloadErrorLabel;
import de.danoeh.antennapod.event.FeedListUpdateEvent; import de.danoeh.antennapod.event.FeedListUpdateEvent;
import de.danoeh.antennapod.event.PlayerStatusEvent; import de.danoeh.antennapod.event.PlayerStatusEvent;
@ -46,7 +47,6 @@ import de.danoeh.antennapod.core.service.download.DownloadRequest;
import de.danoeh.antennapod.model.download.DownloadStatus; import de.danoeh.antennapod.model.download.DownloadStatus;
import de.danoeh.antennapod.core.service.download.Downloader; import de.danoeh.antennapod.core.service.download.Downloader;
import de.danoeh.antennapod.core.service.download.HttpDownloader; import de.danoeh.antennapod.core.service.download.HttpDownloader;
import de.danoeh.antennapod.core.service.playback.PlaybackService;
import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.net.discovery.CombinedSearcher; import de.danoeh.antennapod.net.discovery.CombinedSearcher;
@ -465,7 +465,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
viewBinding.stopPreviewButton.setOnClickListener(v -> { viewBinding.stopPreviewButton.setOnClickListener(v -> {
PlaybackPreferences.writeNoMediaPlaying(); PlaybackPreferences.writeNoMediaPlaying();
IntentUtils.sendLocalBroadcast(this, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE); IntentUtils.sendLocalBroadcast(this, PlaybackServiceInterface.ACTION_SHUTDOWN_PLAYBACK_SERVICE);
}); });
if (UserPreferences.isEnableAutodownload()) { if (UserPreferences.isEnableAutodownload()) {

View File

@ -17,7 +17,7 @@ import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.preferences.PlaybackPreferences; import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.receiver.MediaButtonReceiver; import de.danoeh.antennapod.core.receiver.MediaButtonReceiver;
import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.core.service.playback.PlaybackServiceInterface;
import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.sync.SynchronizationSettings; import de.danoeh.antennapod.core.sync.SynchronizationSettings;
import de.danoeh.antennapod.core.sync.queue.SynchronizationQueueSink; import de.danoeh.antennapod.core.sync.queue.SynchronizationQueueSink;
@ -188,7 +188,7 @@ public class FeedItemMenuHandler {
selectedItem.getMedia().setPosition(0); selectedItem.getMedia().setPosition(0);
if (PlaybackPreferences.getCurrentlyPlayingFeedMediaId() == selectedItem.getMedia().getId()) { if (PlaybackPreferences.getCurrentlyPlayingFeedMediaId() == selectedItem.getMedia().getId()) {
PlaybackPreferences.writeNoMediaPlaying(); PlaybackPreferences.writeNoMediaPlaying();
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE); IntentUtils.sendLocalBroadcast(context, PlaybackServiceInterface.ACTION_SHUTDOWN_PLAYBACK_SERVICE);
} }
DBWriter.markItemPlayed(selectedItem, FeedItem.UNPLAYED, true); DBWriter.markItemPlayed(selectedItem, FeedItem.UNPLAYED, true);
} else if (menuItemId == R.id.visit_website_item) { } else if (menuItemId == R.id.visit_website_item) {

View File

@ -109,53 +109,21 @@ public class PlaybackService extends MediaBrowserServiceCompat {
*/ */
private static final String TAG = "PlaybackService"; private static final String TAG = "PlaybackService";
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 ACTION_PLAYER_STATUS_CHANGED = "action.de.danoeh.antennapod.core.service.playerStatusChanged"; 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"; private static final String AVRCP_ACTION_PLAYER_STATUS_CHANGED = "com.android.music.playstatechanged";
private static final String AVRCP_ACTION_META_CHANGED = "com.android.music.metachanged"; private static final String AVRCP_ACTION_META_CHANGED = "com.android.music.metachanged";
public static final String ACTION_PLAYER_NOTIFICATION = "action.de.danoeh.antennapod.core.service.playerNotification";
public static final String EXTRA_NOTIFICATION_CODE = "extra.de.danoeh.antennapod.core.service.notificationCode";
public static final String EXTRA_NOTIFICATION_TYPE = "extra.de.danoeh.antennapod.core.service.notificationType";
/**
* If the PlaybackService receives this action, it will stop playback and
* try to shutdown.
*/
public static final String ACTION_SHUTDOWN_PLAYBACK_SERVICE = "action.de.danoeh.antennapod.core.service.actionShutdownPlaybackService";
/** /**
* Custom action used by Android Wear, Android Auto * Custom action used by Android Wear, Android Auto
*/ */
private static final String CUSTOM_ACTION_FAST_FORWARD = "action.de.danoeh.antennapod.core.service.fastForward"; private static final String CUSTOM_ACTION_FAST_FORWARD = "action.de.danoeh.antennapod.core.service.fastForward";
private static final String CUSTOM_ACTION_REWIND = "action.de.danoeh.antennapod.core.service.rewind"; private static final String CUSTOM_ACTION_REWIND = "action.de.danoeh.antennapod.core.service.rewind";
/**
* Used in NOTIFICATION_TYPE_RELOAD.
*/
public static final int EXTRA_CODE_AUDIO = 1;
public static final int EXTRA_CODE_VIDEO = 2;
public static final int EXTRA_CODE_CAST = 3;
/**
* Receivers of this intent should update their information about the curently playing media
*/
public static final int NOTIFICATION_TYPE_RELOAD = 3;
/** /**
* Set a max number of episodes to load for Android Auto, otherwise there could be performance issues * Set a max number of episodes to load for Android Auto, otherwise there could be performance issues
*/ */
public static final int MAX_ANDROID_AUTO_EPISODES_PER_FEED = 100; public static final int MAX_ANDROID_AUTO_EPISODES_PER_FEED = 100;
/**
* No more episodes are going to be played.
*/
public static final int NOTIFICATION_TYPE_PLAYBACK_END = 7;
/** /**
* Is true if service is running. * Is true if service is running.
*/ */
@ -243,7 +211,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
registerReceiver(autoStateUpdated, new IntentFilter("com.google.android.gms.car.media.STATUS")); registerReceiver(autoStateUpdated, new IntentFilter("com.google.android.gms.car.media.STATUS"));
registerReceiver(headsetDisconnected, new IntentFilter(Intent.ACTION_HEADSET_PLUG)); registerReceiver(headsetDisconnected, new IntentFilter(Intent.ACTION_HEADSET_PLUG));
registerReceiver(shutdownReceiver, new IntentFilter(ACTION_SHUTDOWN_PLAYBACK_SERVICE)); registerReceiver(shutdownReceiver, new IntentFilter(PlaybackServiceInterface.ACTION_SHUTDOWN_PLAYBACK_SERVICE));
registerReceiver(bluetoothStateUpdated, new IntentFilter(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED)); registerReceiver(bluetoothStateUpdated, new IntentFilter(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED));
registerReceiver(audioBecomingNoisy, new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY)); registerReceiver(audioBecomingNoisy, new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY));
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
@ -478,7 +446,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
final int keycode = intent.getIntExtra(MediaButtonReceiver.EXTRA_KEYCODE, -1); final int keycode = intent.getIntExtra(MediaButtonReceiver.EXTRA_KEYCODE, -1);
final boolean hardwareButton = intent.getBooleanExtra(MediaButtonReceiver.EXTRA_HARDWAREBUTTON, false); final boolean hardwareButton = intent.getBooleanExtra(MediaButtonReceiver.EXTRA_HARDWAREBUTTON, false);
Playable playable = intent.getParcelableExtra(EXTRA_PLAYABLE); Playable playable = intent.getParcelableExtra(PlaybackServiceInterface.EXTRA_PLAYABLE);
if (keycode == -1 && playable == null) { if (keycode == -1 && playable == null) {
Log.e(TAG, "PlaybackService was started with no arguments"); Log.e(TAG, "PlaybackService was started with no arguments");
stateManager.stopService(); stateManager.stopService();
@ -505,9 +473,11 @@ public class PlaybackService extends MediaBrowserServiceCompat {
} }
} else { } else {
stateManager.validStartCommandWasReceived(); stateManager.validStartCommandWasReceived();
boolean allowStreamThisTime = intent.getBooleanExtra(EXTRA_ALLOW_STREAM_THIS_TIME, false); boolean allowStreamThisTime = intent.getBooleanExtra(
boolean allowStreamAlways = intent.getBooleanExtra(EXTRA_ALLOW_STREAM_ALWAYS, false); PlaybackServiceInterface.EXTRA_ALLOW_STREAM_THIS_TIME, false);
sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, 0); boolean allowStreamAlways = intent.getBooleanExtra(
PlaybackServiceInterface.EXTRA_ALLOW_STREAM_ALWAYS, false);
sendNotificationBroadcast(PlaybackServiceInterface.NOTIFICATION_TYPE_RELOAD, 0);
if (allowStreamAlways) { if (allowStreamAlways) {
UserPreferences.setAllowMobileStreaming(true); UserPreferences.setAllowMobileStreaming(true);
} }
@ -561,8 +531,8 @@ public class PlaybackService extends MediaBrowserServiceCompat {
private void displayStreamingNotAllowedNotification(Intent originalIntent) { private void displayStreamingNotAllowedNotification(Intent originalIntent) {
Intent intentAllowThisTime = new Intent(originalIntent); Intent intentAllowThisTime = new Intent(originalIntent);
intentAllowThisTime.setAction(EXTRA_ALLOW_STREAM_THIS_TIME); intentAllowThisTime.setAction(PlaybackServiceInterface.EXTRA_ALLOW_STREAM_THIS_TIME);
intentAllowThisTime.putExtra(EXTRA_ALLOW_STREAM_THIS_TIME, true); intentAllowThisTime.putExtra(PlaybackServiceInterface.EXTRA_ALLOW_STREAM_THIS_TIME, true);
PendingIntent pendingIntentAllowThisTime; PendingIntent pendingIntentAllowThisTime;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
pendingIntentAllowThisTime = PendingIntent.getForegroundService(this, pendingIntentAllowThisTime = PendingIntent.getForegroundService(this,
@ -575,8 +545,8 @@ public class PlaybackService extends MediaBrowserServiceCompat {
} }
Intent intentAlwaysAllow = new Intent(intentAllowThisTime); Intent intentAlwaysAllow = new Intent(intentAllowThisTime);
intentAlwaysAllow.setAction(EXTRA_ALLOW_STREAM_ALWAYS); intentAlwaysAllow.setAction(PlaybackServiceInterface.EXTRA_ALLOW_STREAM_ALWAYS);
intentAlwaysAllow.putExtra(EXTRA_ALLOW_STREAM_ALWAYS, true); intentAlwaysAllow.putExtra(PlaybackServiceInterface.EXTRA_ALLOW_STREAM_ALWAYS, true);
PendingIntent pendingIntentAlwaysAllow; PendingIntent pendingIntentAlwaysAllow;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
pendingIntentAlwaysAllow = PendingIntent.getForegroundService(this, pendingIntentAlwaysAllow = PendingIntent.getForegroundService(this,
@ -766,7 +736,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
@Override @Override
public void onChapterLoaded(Playable media) { public void onChapterLoaded(Playable media) {
sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, 0); sendNotificationBroadcast(PlaybackServiceInterface.NOTIFICATION_TYPE_RELOAD, 0);
} }
}; };
@ -848,7 +818,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
public void onMediaChanged(boolean reloadUI) { public void onMediaChanged(boolean reloadUI) {
Log.d(TAG, "reloadUI callback reached"); Log.d(TAG, "reloadUI callback reached");
if (reloadUI) { if (reloadUI) {
sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, 0); sendNotificationBroadcast(PlaybackServiceInterface.NOTIFICATION_TYPE_RELOAD, 0);
} }
updateNotificationAndMediaSession(getPlayable()); updateNotificationAndMediaSession(getPlayable());
} }
@ -1011,11 +981,12 @@ public class PlaybackService extends MediaBrowserServiceCompat {
} }
} }
if (mediaType == null) { if (mediaType == null) {
sendNotificationBroadcast(NOTIFICATION_TYPE_PLAYBACK_END, 0); sendNotificationBroadcast(PlaybackServiceInterface.NOTIFICATION_TYPE_PLAYBACK_END, 0);
} else { } else {
sendNotificationBroadcast(NOTIFICATION_TYPE_RELOAD, sendNotificationBroadcast(PlaybackServiceInterface.NOTIFICATION_TYPE_RELOAD,
isCasting ? EXTRA_CODE_CAST : isCasting ? PlaybackServiceInterface.EXTRA_CODE_CAST :
(mediaType == MediaType.VIDEO) ? EXTRA_CODE_VIDEO : EXTRA_CODE_AUDIO); (mediaType == MediaType.VIDEO) ? PlaybackServiceInterface.EXTRA_CODE_VIDEO :
PlaybackServiceInterface.EXTRA_CODE_AUDIO);
} }
} }
@ -1114,9 +1085,9 @@ public class PlaybackService extends MediaBrowserServiceCompat {
} }
private void sendNotificationBroadcast(int type, int code) { private void sendNotificationBroadcast(int type, int code) {
Intent intent = new Intent(ACTION_PLAYER_NOTIFICATION); Intent intent = new Intent(PlaybackServiceInterface.ACTION_PLAYER_NOTIFICATION);
intent.putExtra(EXTRA_NOTIFICATION_TYPE, type); intent.putExtra(PlaybackServiceInterface.EXTRA_NOTIFICATION_TYPE, type);
intent.putExtra(EXTRA_NOTIFICATION_CODE, code); intent.putExtra(PlaybackServiceInterface.EXTRA_NOTIFICATION_CODE, code);
intent.setPackage(getPackageName()); intent.setPackage(getPackageName());
sendBroadcast(intent); sendBroadcast(intent);
} }
@ -1521,7 +1492,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
if (TextUtils.equals(intent.getAction(), ACTION_SHUTDOWN_PLAYBACK_SERVICE)) { if (TextUtils.equals(intent.getAction(), PlaybackServiceInterface.ACTION_SHUTDOWN_PLAYBACK_SERVICE)) {
EventBus.getDefault().post(new PlaybackServiceEvent(PlaybackServiceEvent.Action.SERVICE_SHUT_DOWN)); EventBus.getDefault().post(new PlaybackServiceEvent(PlaybackServiceEvent.Action.SERVICE_SHUT_DOWN));
stateManager.stopService(); stateManager.stopService();
} }

View File

@ -0,0 +1,20 @@
package de.danoeh.antennapod.core.service.playback;
public abstract class PlaybackServiceInterface {
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 ACTION_PLAYER_NOTIFICATION
= "action.de.danoeh.antennapod.core.service.playerNotification";
public static final String EXTRA_NOTIFICATION_CODE = "extra.de.danoeh.antennapod.core.service.notificationCode";
public static final String EXTRA_NOTIFICATION_TYPE = "extra.de.danoeh.antennapod.core.service.notificationType";
public static final int NOTIFICATION_TYPE_PLAYBACK_END = 7;
public static final int NOTIFICATION_TYPE_RELOAD = 3;
public static final int EXTRA_CODE_AUDIO = 1; // Used in NOTIFICATION_TYPE_RELOAD
public static final int EXTRA_CODE_VIDEO = 2;
public static final int EXTRA_CODE_CAST = 3;
public static final String ACTION_SHUTDOWN_PLAYBACK_SERVICE
= "action.de.danoeh.antennapod.core.service.actionShutdownPlaybackService";
}

View File

@ -9,6 +9,7 @@ import androidx.annotation.Nullable;
import androidx.core.app.NotificationManagerCompat; import androidx.core.app.NotificationManagerCompat;
import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.core.service.download.DownloadService;
import de.danoeh.antennapod.core.service.playback.PlaybackServiceInterface;
import de.danoeh.antennapod.storage.database.PodDBAdapter; import de.danoeh.antennapod.storage.database.PodDBAdapter;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
@ -36,7 +37,6 @@ import de.danoeh.antennapod.core.feed.FeedEvent;
import de.danoeh.antennapod.core.preferences.PlaybackPreferences; import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.model.download.DownloadStatus; import de.danoeh.antennapod.model.download.DownloadStatus;
import de.danoeh.antennapod.core.service.playback.PlaybackService;
import de.danoeh.antennapod.core.sync.queue.SynchronizationQueueSink; import de.danoeh.antennapod.core.sync.queue.SynchronizationQueueSink;
import de.danoeh.antennapod.core.util.FeedItemPermutors; import de.danoeh.antennapod.core.util.FeedItemPermutors;
import de.danoeh.antennapod.core.util.IntentUtils; import de.danoeh.antennapod.core.util.IntentUtils;
@ -128,7 +128,7 @@ public class DBWriter {
if (media.getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId()) { if (media.getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId()) {
PlaybackPreferences.writeNoMediaPlaying(); PlaybackPreferences.writeNoMediaPlaying();
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE); IntentUtils.sendLocalBroadcast(context, PlaybackServiceInterface.ACTION_SHUTDOWN_PLAYBACK_SERVICE);
NotificationManagerCompat nm = NotificationManagerCompat.from(context); NotificationManagerCompat nm = NotificationManagerCompat.from(context);
nm.cancel(R.id.notification_playing); nm.cancel(R.id.notification_playing);
@ -201,7 +201,7 @@ public class DBWriter {
if (item.getMedia().getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId()) { if (item.getMedia().getId() == PlaybackPreferences.getCurrentlyPlayingFeedMediaId()) {
// Applies to both downloaded and streamed media // Applies to both downloaded and streamed media
PlaybackPreferences.writeNoMediaPlaying(); PlaybackPreferences.writeNoMediaPlaying();
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE); IntentUtils.sendLocalBroadcast(context, PlaybackServiceInterface.ACTION_SHUTDOWN_PLAYBACK_SERVICE);
} }
if (item.getMedia().isDownloaded()) { if (item.getMedia().isDownloaded()) {
deleteFeedMediaSynchronous(context, item.getMedia()); deleteFeedMediaSynchronous(context, item.getMedia());

View File

@ -4,8 +4,6 @@ import androidx.annotation.NonNull;
import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.model.feed.FeedMedia;
import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
import de.danoeh.antennapod.core.service.playback.PlaybackService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -12,6 +12,7 @@ import android.util.Log;
import android.util.Pair; import android.util.Pair;
import android.view.SurfaceHolder; import android.view.SurfaceHolder;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import de.danoeh.antennapod.core.service.playback.PlaybackServiceInterface;
import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.event.playback.PlaybackPositionEvent; import de.danoeh.antennapod.event.playback.PlaybackPositionEvent;
import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.model.feed.FeedMedia;
@ -84,10 +85,9 @@ public abstract class PlaybackController {
initialized = true; initialized = true;
activity.registerReceiver(statusUpdate, new IntentFilter( activity.registerReceiver(statusUpdate, new IntentFilter(
PlaybackService.ACTION_PLAYER_STATUS_CHANGED)); PlaybackService.ACTION_PLAYER_STATUS_CHANGED));
activity.registerReceiver(notificationReceiver, new IntentFilter( activity.registerReceiver(notificationReceiver, new IntentFilter(
PlaybackService.ACTION_PLAYER_NOTIFICATION)); PlaybackServiceInterface.ACTION_PLAYER_NOTIFICATION));
if (!released) { if (!released) {
bindToService(); bindToService();
@ -202,14 +202,14 @@ public abstract class PlaybackController {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
int type = intent.getIntExtra(PlaybackService.EXTRA_NOTIFICATION_TYPE, -1); int type = intent.getIntExtra(PlaybackServiceInterface.EXTRA_NOTIFICATION_TYPE, -1);
int code = intent.getIntExtra(PlaybackService.EXTRA_NOTIFICATION_CODE, -1); int code = intent.getIntExtra(PlaybackServiceInterface.EXTRA_NOTIFICATION_CODE, -1);
if (code == -1 || type == -1) { if (code == -1 || type == -1) {
Log.d(TAG, "Bad arguments. Won't handle intent"); Log.d(TAG, "Bad arguments. Won't handle intent");
return; return;
} }
switch (type) { switch (type) {
case PlaybackService.NOTIFICATION_TYPE_RELOAD: case PlaybackServiceInterface.NOTIFICATION_TYPE_RELOAD:
if (playbackService == null && PlaybackService.isRunning) { if (playbackService == null && PlaybackService.isRunning) {
bindToService(); bindToService();
return; return;
@ -217,7 +217,7 @@ public abstract class PlaybackController {
mediaInfoLoaded = false; mediaInfoLoaded = false;
queryService(); queryService();
break; break;
case PlaybackService.NOTIFICATION_TYPE_PLAYBACK_END: case PlaybackServiceInterface.NOTIFICATION_TYPE_PLAYBACK_END:
onPlaybackEnd(); onPlaybackEnd();
break; break;
} }

View File

@ -6,6 +6,7 @@ import android.os.Parcelable;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import de.danoeh.antennapod.core.service.playback.PlaybackService; import de.danoeh.antennapod.core.service.playback.PlaybackService;
import de.danoeh.antennapod.core.service.playback.PlaybackServiceInterface;
import de.danoeh.antennapod.model.playback.Playable; import de.danoeh.antennapod.model.playback.Playable;
public class PlaybackServiceStarter { public class PlaybackServiceStarter {
@ -34,8 +35,8 @@ public class PlaybackServiceStarter {
public Intent getIntent() { public Intent getIntent() {
Intent launchIntent = new Intent(context, PlaybackService.class); Intent launchIntent = new Intent(context, PlaybackService.class);
launchIntent.putExtra(PlaybackService.EXTRA_PLAYABLE, (Parcelable) media); launchIntent.putExtra(PlaybackServiceInterface.EXTRA_PLAYABLE, (Parcelable) media);
launchIntent.putExtra(PlaybackService.EXTRA_ALLOW_STREAM_THIS_TIME, shouldStreamThisTime); launchIntent.putExtra(PlaybackServiceInterface.EXTRA_ALLOW_STREAM_THIS_TIME, shouldStreamThisTime);
return launchIntent; return launchIntent;
} }