Merge pull request #6173 from ByteHamster/playbackservice-cleanup
PlaybackService cleanup
This commit is contained in:
commit
9b06bf0dc5
|
@ -3,6 +3,7 @@ package de.test.antennapod.playback;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.view.KeyEvent;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import android.view.View;
|
||||
|
||||
|
@ -10,6 +11,7 @@ import androidx.test.filters.LargeTest;
|
|||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.rule.ActivityTestRule;
|
||||
|
||||
import de.danoeh.antennapod.core.receiver.MediaButtonReceiver;
|
||||
import de.danoeh.antennapod.model.feed.FeedItemFilter;
|
||||
import de.danoeh.antennapod.playback.base.PlayerStatus;
|
||||
import org.awaitility.Awaitility;
|
||||
|
@ -32,10 +34,8 @@ import de.danoeh.antennapod.model.feed.FeedItem;
|
|||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.LongList;
|
||||
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
||||
import de.test.antennapod.EspressoTestUtils;
|
||||
|
@ -241,11 +241,11 @@ public class PlaybackTest {
|
|||
}
|
||||
|
||||
private void skipEpisode() {
|
||||
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SKIP_CURRENT_EPISODE);
|
||||
context.sendBroadcast(MediaButtonReceiver.createIntent(context, KeyEvent.KEYCODE_MEDIA_NEXT));
|
||||
}
|
||||
|
||||
protected void pauseEpisode() {
|
||||
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE);
|
||||
context.sendBroadcast(MediaButtonReceiver.createIntent(context, KeyEvent.KEYCODE_MEDIA_PAUSE));
|
||||
}
|
||||
|
||||
protected void startLocalPlayback() {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
|
@ -23,7 +22,6 @@ import androidx.core.view.ViewCompat;
|
|||
import androidx.core.view.WindowCompat;
|
||||
import androidx.core.view.WindowInsetsCompat;
|
||||
import com.google.android.material.appbar.MaterialToolbar;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentContainerView;
|
||||
|
@ -44,7 +42,6 @@ import org.greenrobot.eventbus.ThreadMode;
|
|||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.receiver.MediaButtonReceiver;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.util.download.AutoUpdateManager;
|
||||
import de.danoeh.antennapod.dialog.RatingDialog;
|
||||
import de.danoeh.antennapod.event.MessageEvent;
|
||||
|
@ -448,7 +445,6 @@ public class MainActivity extends CastEnabledActivity {
|
|||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||
@Override
|
||||
public void onTrimMemory(int level) {
|
||||
super.onTrimMemory(level);
|
||||
|
@ -662,9 +658,7 @@ public class MainActivity extends CastEnabledActivity {
|
|||
}
|
||||
|
||||
if (customKeyCode != null) {
|
||||
Intent intent = new Intent(this, PlaybackService.class);
|
||||
intent.putExtra(MediaButtonReceiver.EXTRA_KEYCODE, customKeyCode);
|
||||
ContextCompat.startForegroundService(this, intent);
|
||||
sendBroadcast(MediaButtonReceiver.createIntent(this, customKeyCode));
|
||||
return true;
|
||||
}
|
||||
return super.onKeyUp(keyCode, event);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
|
@ -174,7 +173,6 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
|||
super.onPause();
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
|
||||
@Override
|
||||
public void onTrimMemory(int level) {
|
||||
super.onTrimMemory(level);
|
||||
|
@ -189,19 +187,19 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
|||
|
||||
private PlaybackController newPlaybackController() {
|
||||
return new PlaybackController(this) {
|
||||
@Override
|
||||
public void onPositionObserverUpdate() {
|
||||
VideoplayerActivity.this.onPositionObserverUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReloadNotification(int code) {
|
||||
VideoplayerActivity.this.onReloadNotification(code);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updatePlayButtonShowsPlay(boolean showPlay) {
|
||||
viewBinding.playButton.setIsShowPlay(showPlay);
|
||||
if (showPlay) {
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
} else {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
setupVideoAspectRatio();
|
||||
if (videoSurfaceCreated && controller != null) {
|
||||
Log.d(TAG, "Videosurface already created, setting videosurface now");
|
||||
controller.setVideoSurface(viewBinding.videoView.getHolder());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -209,28 +207,10 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
|||
VideoplayerActivity.this.loadMediaInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAwaitingVideoSurface() {
|
||||
setupVideoAspectRatio();
|
||||
if (videoSurfaceCreated && controller != null) {
|
||||
Log.d(TAG, "Videosurface already created, setting videosurface now");
|
||||
controller.setVideoSurface(viewBinding.videoView.getHolder());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaybackEnd() {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setScreenOn(boolean enable) {
|
||||
if (enable) {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
} else {
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -259,6 +239,13 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
|||
if (controller == null || controller.getMedia() == null) {
|
||||
return;
|
||||
}
|
||||
if (controller.getStatus() == PlayerStatus.PLAYING && !controller.isPlayingVideoLocally()) {
|
||||
Log.d(TAG, "Closing, no longer video");
|
||||
destroyingDueToReload = true;
|
||||
finish();
|
||||
new MainActivityStarter(this).withOpenPlayer().start();
|
||||
return;
|
||||
}
|
||||
showTimeLeft = UserPreferences.shouldShowRemainingTime();
|
||||
onPositionObserverUpdate();
|
||||
checkFavorite();
|
||||
|
@ -485,22 +472,6 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
|||
}
|
||||
};
|
||||
|
||||
protected void onReloadNotification(int notificationCode) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && PictureInPictureUtil.isInPictureInPictureMode(this)) {
|
||||
if (notificationCode == PlaybackService.EXTRA_CODE_AUDIO
|
||||
|| notificationCode == PlaybackService.EXTRA_CODE_CAST) {
|
||||
finish();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (notificationCode == PlaybackService.EXTRA_CODE_CAST) {
|
||||
Log.d(TAG, "ReloadNotification received, switching to Castplayer now");
|
||||
destroyingDueToReload = true;
|
||||
finish();
|
||||
new MainActivityStarter(this).withOpenPlayer().start();
|
||||
}
|
||||
}
|
||||
|
||||
private void showVideoControls() {
|
||||
viewBinding.bottomControlsContainer.setVisibility(View.VISIBLE);
|
||||
viewBinding.controlsContainer.setVisibility(View.VISIBLE);
|
||||
|
@ -669,8 +640,8 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
|||
int remainingTime = converter.convert(
|
||||
controller.getDuration() - controller.getPosition());
|
||||
Log.d(TAG, "currentPosition " + Converter.getDurationStringLong(currentPosition));
|
||||
if (currentPosition == PlaybackService.INVALID_TIME
|
||||
|| duration == PlaybackService.INVALID_TIME) {
|
||||
if (currentPosition == Playable.INVALID_TIME
|
||||
|| duration == Playable.INVALID_TIME) {
|
||||
Log.w(TAG, "Could not react to position observer update because of invalid time");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
package de.danoeh.antennapod.adapter.actionbutton;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.KeyEvent;
|
||||
import androidx.annotation.DrawableRes;
|
||||
import androidx.annotation.StringRes;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.core.receiver.MediaButtonReceiver;
|
||||
import de.danoeh.antennapod.model.feed.FeedItem;
|
||||
import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
|
||||
import static de.danoeh.antennapod.core.service.playback.PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE;
|
||||
|
||||
public class PauseActionButton extends ItemActionButton {
|
||||
|
||||
|
@ -37,7 +36,7 @@ public class PauseActionButton extends ItemActionButton {
|
|||
}
|
||||
|
||||
if (FeedItemUtil.isCurrentlyPlaying(media)) {
|
||||
IntentUtils.sendLocalBroadcast(context, ACTION_PAUSE_PLAY_CURRENT_EPISODE);
|
||||
context.sendBroadcast(MediaButtonReceiver.createIntent(context, KeyEvent.KEYCODE_MEDIA_PAUSE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package de.danoeh.antennapod.fragment;
|
|||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -26,7 +27,7 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior;
|
|||
import com.google.android.material.elevation.SurfaceColors;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.receiver.MediaButtonReceiver;
|
||||
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
||||
import de.danoeh.antennapod.event.playback.BufferUpdateEvent;
|
||||
import de.danoeh.antennapod.event.playback.PlaybackServiceEvent;
|
||||
|
@ -54,7 +55,6 @@ import de.danoeh.antennapod.core.feed.util.PlaybackSpeedUtils;
|
|||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.util.ChapterUtils;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.TimeSpeedConverter;
|
||||
import de.danoeh.antennapod.model.playback.Playable;
|
||||
import de.danoeh.antennapod.dialog.PlaybackControlsDialog;
|
||||
|
@ -215,8 +215,8 @@ public class AudioPlayerFragment extends Fragment implements
|
|||
SkipPreferenceDialog.SkipDirection.SKIP_FORWARD, txtvFF);
|
||||
return false;
|
||||
});
|
||||
butSkip.setOnClickListener(v ->
|
||||
IntentUtils.sendLocalBroadcast(getActivity(), PlaybackService.ACTION_SKIP_CURRENT_EPISODE));
|
||||
butSkip.setOnClickListener(v -> getActivity().sendBroadcast(
|
||||
MediaButtonReceiver.createIntent(getContext(), KeyEvent.KEYCODE_MEDIA_NEXT)));
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
|
@ -374,7 +374,7 @@ public class AudioPlayerFragment extends Fragment implements
|
|||
int remainingTime = converter.convert(Math.max(event.getDuration() - event.getPosition(), 0));
|
||||
currentChapterIndex = ChapterUtils.getCurrentChapterIndex(controller.getMedia(), currentPosition);
|
||||
Log.d(TAG, "currentPosition " + Converter.getDurationStringLong(currentPosition));
|
||||
if (currentPosition == PlaybackService.INVALID_TIME || duration == PlaybackService.INVALID_TIME) {
|
||||
if (currentPosition == Playable.INVALID_TIME || duration == Playable.INVALID_TIME) {
|
||||
Log.w(TAG, "Could not react to position observer update because of invalid time");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -88,11 +88,6 @@ public class ChaptersFragment extends AppCompatDialogFragment {
|
|||
public void loadMediaInfo() {
|
||||
ChaptersFragment.this.loadMediaInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPositionObserverUpdate() {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
controller.init();
|
||||
EventBus.getDefault().register(this);
|
||||
|
|
|
@ -139,8 +139,8 @@ public class ExternalPlayerFragment extends Fragment {
|
|||
public void onPositionObserverUpdate(PlaybackPositionEvent event) {
|
||||
if (controller == null) {
|
||||
return;
|
||||
} else if (controller.getPosition() == PlaybackService.INVALID_TIME
|
||||
|| controller.getDuration() == PlaybackService.INVALID_TIME) {
|
||||
} else if (controller.getPosition() == Playable.INVALID_TIME
|
||||
|| controller.getDuration() == Playable.INVALID_TIME) {
|
||||
return;
|
||||
}
|
||||
progressBar.setProgress((int)
|
||||
|
|
|
@ -3,6 +3,7 @@ package de.danoeh.antennapod.menuhandler;
|
|||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
|
@ -15,6 +16,7 @@ import de.danoeh.antennapod.R;
|
|||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.receiver.MediaButtonReceiver;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import de.danoeh.antennapod.core.sync.SynchronizationSettings;
|
||||
|
@ -143,7 +145,7 @@ public class FeedItemMenuHandler {
|
|||
|
||||
@NonNull Context context = fragment.requireContext();
|
||||
if (menuItemId == R.id.skip_episode_item) {
|
||||
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SKIP_CURRENT_EPISODE);
|
||||
context.sendBroadcast(MediaButtonReceiver.createIntent(context, KeyEvent.KEYCODE_MEDIA_NEXT));
|
||||
} else if (menuItemId == R.id.remove_item) {
|
||||
DBWriter.deleteFeedMediaOfItem(context, selectedItem.getMedia().getId());
|
||||
} else if (menuItemId == R.id.remove_inbox_item) {
|
||||
|
|
|
@ -30,10 +30,10 @@ import de.danoeh.antennapod.model.feed.FeedMedia;
|
|||
import de.danoeh.antennapod.model.playback.MediaType;
|
||||
import de.danoeh.antennapod.core.feed.util.ImageResourceUtils;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.model.playback.Playable;
|
||||
import de.danoeh.antennapod.ui.common.CircularProgressBar;
|
||||
import de.danoeh.antennapod.ui.common.ThemeUtils;
|
||||
|
||||
|
@ -230,7 +230,7 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder {
|
|||
int timeDuration = event.getDuration();
|
||||
int remainingTime = Math.max(timeDuration - currentPosition, 0);
|
||||
Log.d(TAG, "currentPosition " + Converter.getDurationStringLong(currentPosition));
|
||||
if (currentPosition == PlaybackService.INVALID_TIME || timeDuration == PlaybackService.INVALID_TIME) {
|
||||
if (currentPosition == Playable.INVALID_TIME || timeDuration == Playable.INVALID_TIME) {
|
||||
Log.w(TAG, "Could not react to position observer update because of invalid time");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package de.danoeh.antennapod.core.receiver;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
|
@ -10,36 +12,44 @@ import android.view.KeyEvent;
|
|||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
|
||||
/** Receives media button events. */
|
||||
/**
|
||||
* Receives media button events.
|
||||
*/
|
||||
public class MediaButtonReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "MediaButtonReceiver";
|
||||
public static final String EXTRA_KEYCODE = "de.danoeh.antennapod.core.service.extra.MediaButtonReceiver.KEYCODE";
|
||||
public static final String EXTRA_SOURCE = "de.danoeh.antennapod.core.service.extra.MediaButtonReceiver.SOURCE";
|
||||
public static final String EXTRA_HARDWAREBUTTON = "de.danoeh.antennapod.core.service.extra.MediaButtonReceiver.HARDWAREBUTTON";
|
||||
private static final String TAG = "MediaButtonReceiver";
|
||||
public static final String EXTRA_KEYCODE = "de.danoeh.antennapod.core.service.extra.MediaButtonReceiver.KEYCODE";
|
||||
public static final String EXTRA_SOURCE = "de.danoeh.antennapod.core.service.extra.MediaButtonReceiver.SOURCE";
|
||||
public static final String EXTRA_HARDWAREBUTTON
|
||||
= "de.danoeh.antennapod.core.service.extra.MediaButtonReceiver.HARDWAREBUTTON";
|
||||
public static final String NOTIFY_BUTTON_RECEIVER = "de.danoeh.antennapod.NOTIFY_BUTTON_RECEIVER";
|
||||
|
||||
public static final String NOTIFY_BUTTON_RECEIVER = "de.danoeh.antennapod.NOTIFY_BUTTON_RECEIVER";
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.d(TAG, "Received intent");
|
||||
if (intent == null || intent.getExtras() == null) {
|
||||
return;
|
||||
}
|
||||
KeyEvent event = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT);
|
||||
if (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
|
||||
ClientConfig.initialize(context);
|
||||
Intent serviceIntent = new Intent(context, PlaybackService.class);
|
||||
serviceIntent.putExtra(EXTRA_KEYCODE, event.getKeyCode());
|
||||
serviceIntent.putExtra(EXTRA_SOURCE, event.getSource());
|
||||
serviceIntent.putExtra(EXTRA_HARDWAREBUTTON, event.getEventTime() > 0 || event.getDownTime() > 0);
|
||||
ContextCompat.startForegroundService(context, serviceIntent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.d(TAG, "Received intent");
|
||||
if (intent == null || intent.getExtras() == null) {
|
||||
return;
|
||||
}
|
||||
KeyEvent event = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT);
|
||||
if (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount()==0) {
|
||||
ClientConfig.initialize(context);
|
||||
Intent serviceIntent = new Intent(context, PlaybackService.class);
|
||||
serviceIntent.putExtra(EXTRA_KEYCODE, event.getKeyCode());
|
||||
serviceIntent.putExtra(EXTRA_SOURCE, event.getSource());
|
||||
//detect if this is a hardware button press
|
||||
if (event.getEventTime() > 0 || event.getDownTime() > 0) {
|
||||
serviceIntent.putExtra(EXTRA_HARDWAREBUTTON, true);
|
||||
} else {
|
||||
serviceIntent.putExtra(EXTRA_HARDWAREBUTTON, false);
|
||||
}
|
||||
ContextCompat.startForegroundService(context, serviceIntent);
|
||||
}
|
||||
|
||||
}
|
||||
public static Intent createIntent(Context context, int eventCode) {
|
||||
KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, eventCode);
|
||||
Intent startingIntent = new Intent(context, MediaButtonReceiver.class);
|
||||
startingIntent.setAction(MediaButtonReceiver.NOTIFY_BUTTON_RECEIVER);
|
||||
startingIntent.putExtra(Intent.EXTRA_KEY_EVENT, event);
|
||||
return startingIntent;
|
||||
}
|
||||
|
||||
public static PendingIntent createPendingIntent(Context context, int eventCode) {
|
||||
return PendingIntent.getBroadcast(context, eventCode, createIntent(context, eventCode),
|
||||
(Build.VERSION.SDK_INT >= 23 ? PendingIntent.FLAG_IMMUTABLE : 0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
|||
import de.danoeh.antennapod.core.service.download.HttpCredentialEncoder;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
import de.danoeh.antennapod.core.util.playback.IPlayer;
|
||||
import de.danoeh.antennapod.playback.base.PlaybackServiceMediaPlayer;
|
||||
import de.danoeh.antennapod.model.playback.Playable;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
@ -154,7 +154,7 @@ public class ExoPlayerWrapper implements IPlayer {
|
|||
@Override
|
||||
public int getDuration() {
|
||||
if (exoPlayer.getDuration() == C.TIME_UNSET) {
|
||||
return PlaybackServiceMediaPlayer.INVALID_TIME;
|
||||
return Playable.INVALID_TIME;
|
||||
}
|
||||
return (int) exoPlayer.getDuration();
|
||||
}
|
||||
|
|
|
@ -543,7 +543,7 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
|
|||
executor.submit(() -> {
|
||||
playerLock.lock();
|
||||
int currentPosition = getPosition();
|
||||
if (currentPosition != INVALID_TIME) {
|
||||
if (currentPosition != Playable.INVALID_TIME) {
|
||||
seekToSync(currentPosition + d);
|
||||
} else {
|
||||
Log.e(TAG, "getPosition() returned INVALID_TIME in seekDelta");
|
||||
|
@ -559,10 +559,10 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
|
|||
@Override
|
||||
public int getDuration() {
|
||||
if (!playerLock.tryLock()) {
|
||||
return INVALID_TIME;
|
||||
return Playable.INVALID_TIME;
|
||||
}
|
||||
|
||||
int retVal = INVALID_TIME;
|
||||
int retVal = Playable.INVALID_TIME;
|
||||
if (playerStatus == PlayerStatus.PLAYING
|
||||
|| playerStatus == PlayerStatus.PAUSED
|
||||
|| playerStatus == PlayerStatus.PREPARED) {
|
||||
|
@ -583,13 +583,13 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
|
|||
public int getPosition() {
|
||||
try {
|
||||
if (!playerLock.tryLock(50, TimeUnit.MILLISECONDS)) {
|
||||
return INVALID_TIME;
|
||||
return Playable.INVALID_TIME;
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
return INVALID_TIME;
|
||||
return Playable.INVALID_TIME;
|
||||
}
|
||||
|
||||
int retVal = INVALID_TIME;
|
||||
int retVal = Playable.INVALID_TIME;
|
||||
if (playerStatus.isAtLeast(PlayerStatus.PREPARED)) {
|
||||
retVal = mediaPlayer.getCurrentPosition();
|
||||
}
|
||||
|
|
|
@ -127,17 +127,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
*/
|
||||
public static final String ACTION_SHUTDOWN_PLAYBACK_SERVICE = "action.de.danoeh.antennapod.core.service.actionShutdownPlaybackService";
|
||||
|
||||
/**
|
||||
* If the PlaybackService receives this action, it will end playback of the
|
||||
* current episode and load the next episode if there is one available.
|
||||
*/
|
||||
public static final String ACTION_SKIP_CURRENT_EPISODE = "action.de.danoeh.antennapod.core.service.skipCurrentEpisode";
|
||||
|
||||
/**
|
||||
* If the PlaybackService receives this action, it will pause playback.
|
||||
*/
|
||||
public static final String ACTION_PAUSE_PLAY_CURRENT_EPISODE = "action.de.danoeh.antennapod.core.service.pausePlayCurrentEpisode";
|
||||
|
||||
/**
|
||||
* Custom action used by Android Wear, Android Auto
|
||||
*/
|
||||
|
@ -167,12 +156,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
*/
|
||||
public static final int NOTIFICATION_TYPE_PLAYBACK_END = 7;
|
||||
|
||||
/**
|
||||
* Returned by getPositionSafe() or getDurationSafe() if the playbackService
|
||||
* is in an invalid state.
|
||||
*/
|
||||
public static final int INVALID_TIME = -1;
|
||||
|
||||
/**
|
||||
* Is true if service is running.
|
||||
*/
|
||||
|
@ -263,8 +246,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
registerReceiver(shutdownReceiver, new IntentFilter(ACTION_SHUTDOWN_PLAYBACK_SERVICE));
|
||||
registerReceiver(bluetoothStateUpdated, new IntentFilter(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED));
|
||||
registerReceiver(audioBecomingNoisy, new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY));
|
||||
registerReceiver(skipCurrentEpisodeReceiver, new IntentFilter(ACTION_SKIP_CURRENT_EPISODE));
|
||||
registerReceiver(pausePlayCurrentEpisodeReceiver, new IntentFilter(ACTION_PAUSE_PLAY_CURRENT_EPISODE));
|
||||
EventBus.getDefault().register(this);
|
||||
taskManager = new PlaybackServiceTaskManager(this, taskManagerCallback);
|
||||
|
||||
|
@ -347,8 +328,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
unregisterReceiver(shutdownReceiver);
|
||||
unregisterReceiver(bluetoothStateUpdated);
|
||||
unregisterReceiver(audioBecomingNoisy);
|
||||
unregisterReceiver(skipCurrentEpisodeReceiver);
|
||||
unregisterReceiver(pausePlayCurrentEpisodeReceiver);
|
||||
mediaPlayer.shutdown();
|
||||
taskManager.shutdown();
|
||||
}
|
||||
|
@ -776,7 +755,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
private final PlaybackServiceTaskManager.PSTMCallback taskManagerCallback = new PlaybackServiceTaskManager.PSTMCallback() {
|
||||
@Override
|
||||
public void positionSaverTick() {
|
||||
saveCurrentPosition(true, null, PlaybackServiceMediaPlayer.INVALID_TIME);
|
||||
saveCurrentPosition(true, null, Playable.INVALID_TIME);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -828,7 +807,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
break;
|
||||
case PLAYING:
|
||||
PlaybackPreferences.writePlayerStatus(mediaPlayer.getPlayerStatus());
|
||||
saveCurrentPosition(true, null, INVALID_TIME);
|
||||
saveCurrentPosition(true, null, Playable.INVALID_TIME);
|
||||
updateNotificationAndMediaSession(newInfo.playable);
|
||||
setupPositionObserver();
|
||||
stateManager.validStartCommandWasReceived();
|
||||
|
@ -883,7 +862,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
@Override
|
||||
public void onPlaybackStart(@NonNull Playable playable, int position) {
|
||||
taskManager.startWidgetUpdater();
|
||||
if (position != PlaybackServiceMediaPlayer.INVALID_TIME) {
|
||||
if (position != Playable.INVALID_TIME) {
|
||||
playable.setPosition(position);
|
||||
} else {
|
||||
skipIntro(playable);
|
||||
|
@ -896,8 +875,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
public void onPlaybackPause(Playable playable, int position) {
|
||||
taskManager.cancelPositionSaver();
|
||||
cancelPositionObserver();
|
||||
saveCurrentPosition(position == PlaybackServiceMediaPlayer.INVALID_TIME || playable == null,
|
||||
playable, position);
|
||||
saveCurrentPosition(position == Playable.INVALID_TIME || playable == null, playable, position);
|
||||
taskManager.cancelWidgetUpdater();
|
||||
if (playable != null) {
|
||||
if (playable instanceof FeedMedia) {
|
||||
|
@ -1392,7 +1370,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
} else {
|
||||
duration = playable.getDuration();
|
||||
}
|
||||
if (position != INVALID_TIME && duration != INVALID_TIME && playable != null) {
|
||||
if (position != Playable.INVALID_TIME && duration != Playable.INVALID_TIME && playable != null) {
|
||||
Log.d(TAG, "Saving current position to " + position);
|
||||
PlayableUtils.saveCurrentPosition(playable, position, System.currentTimeMillis());
|
||||
}
|
||||
|
@ -1551,26 +1529,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
|
||||
};
|
||||
|
||||
private final BroadcastReceiver skipCurrentEpisodeReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (TextUtils.equals(intent.getAction(), ACTION_SKIP_CURRENT_EPISODE)) {
|
||||
Log.d(TAG, "Received SKIP_CURRENT_EPISODE intent");
|
||||
mediaPlayer.skip();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final BroadcastReceiver pausePlayCurrentEpisodeReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (TextUtils.equals(intent.getAction(), ACTION_PAUSE_PLAY_CURRENT_EPISODE)) {
|
||||
Log.d(TAG, "Received PAUSE_PLAY_CURRENT_EPISODE intent");
|
||||
mediaPlayer.pause(false, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
@SuppressWarnings("unused")
|
||||
public void volumeAdaptionChanged(VolumeAdaptionChangedEvent event) {
|
||||
|
@ -1630,10 +1588,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
mediaPlayer.pause(abandonAudioFocus, reinit);
|
||||
}
|
||||
|
||||
public void reinit() {
|
||||
mediaPlayer.reinit();
|
||||
}
|
||||
|
||||
public PlaybackServiceMediaPlayer.PSMPInfo getPSMPInfo() {
|
||||
return mediaPlayer.getPSMPInfo();
|
||||
}
|
||||
|
@ -1692,7 +1646,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
*/
|
||||
public int getDuration() {
|
||||
if (mediaPlayer == null) {
|
||||
return INVALID_TIME;
|
||||
return Playable.INVALID_TIME;
|
||||
}
|
||||
return mediaPlayer.getDuration();
|
||||
}
|
||||
|
@ -1703,7 +1657,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
*/
|
||||
public int getCurrentPosition() {
|
||||
if (mediaPlayer == null) {
|
||||
return INVALID_TIME;
|
||||
return Playable.INVALID_TIME;
|
||||
}
|
||||
return mediaPlayer.getPosition();
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import java.util.List;
|
|||
public abstract class PlaybackController {
|
||||
|
||||
private static final String TAG = "PlaybackController";
|
||||
private static final int INVALID_TIME = -1;
|
||||
|
||||
private final Activity activity;
|
||||
private PlaybackService playbackService;
|
||||
|
@ -217,8 +216,6 @@ public abstract class PlaybackController {
|
|||
}
|
||||
mediaInfoLoaded = false;
|
||||
queryService();
|
||||
onReloadNotification(intent.getIntExtra(
|
||||
PlaybackService.EXTRA_NOTIFICATION_CODE, -1));
|
||||
break;
|
||||
case PlaybackService.NOTIFICATION_TYPE_PLAYBACK_END:
|
||||
onPlaybackEnd();
|
||||
|
@ -228,13 +225,6 @@ public abstract class PlaybackController {
|
|||
|
||||
};
|
||||
|
||||
public void onPositionObserverUpdate() {}
|
||||
|
||||
/**
|
||||
* Called when the currently displayed information should be refreshed.
|
||||
*/
|
||||
public void onReloadNotification(int code) {}
|
||||
|
||||
public void onPlaybackEnd() {}
|
||||
|
||||
/**
|
||||
|
@ -245,18 +235,7 @@ public abstract class PlaybackController {
|
|||
Log.d(TAG, "status: " + status.toString());
|
||||
checkMediaInfoLoaded();
|
||||
switch (status) {
|
||||
case PAUSED:
|
||||
onPositionObserverUpdate();
|
||||
updatePlayButtonShowsPlay(true);
|
||||
if (!PlaybackService.isCasting() && PlaybackService.getCurrentMediaType() == MediaType.VIDEO) {
|
||||
setScreenOn(false);
|
||||
}
|
||||
break;
|
||||
case PLAYING:
|
||||
if (!PlaybackService.isCasting() && PlaybackService.getCurrentMediaType() == MediaType.VIDEO) {
|
||||
onAwaitingVideoSurface();
|
||||
setScreenOn(true);
|
||||
}
|
||||
updatePlayButtonShowsPlay(false);
|
||||
break;
|
||||
case PREPARING:
|
||||
|
@ -264,15 +243,10 @@ public abstract class PlaybackController {
|
|||
updatePlayButtonShowsPlay(!playbackService.isStartWhenPrepared());
|
||||
}
|
||||
break;
|
||||
case PREPARED:
|
||||
updatePlayButtonShowsPlay(true);
|
||||
onPositionObserverUpdate();
|
||||
break;
|
||||
case SEEKING:
|
||||
onPositionObserverUpdate();
|
||||
break;
|
||||
case PAUSED:
|
||||
case PREPARED: // Fall-through
|
||||
case STOPPED: // Fall-through
|
||||
case INITIALIZED:
|
||||
case INITIALIZED: // Fall-through
|
||||
updatePlayButtonShowsPlay(true);
|
||||
break;
|
||||
default:
|
||||
|
@ -294,8 +268,6 @@ public abstract class PlaybackController {
|
|||
|
||||
public abstract void loadMediaInfo();
|
||||
|
||||
public void onAwaitingVideoSurface() {}
|
||||
|
||||
/**
|
||||
* Called when connection to playback service has been established or
|
||||
* information has to be refreshed
|
||||
|
@ -317,16 +289,6 @@ public abstract class PlaybackController {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should be implemented by classes that show a video. The default implementation
|
||||
* does nothing
|
||||
*
|
||||
* @param enable True if the screen should be kept on, false otherwise
|
||||
*/
|
||||
protected void setScreenOn(boolean enable) {
|
||||
|
||||
}
|
||||
|
||||
public void playPause() {
|
||||
if (playbackService == null) {
|
||||
new PlaybackServiceStarter(activity, media).start();
|
||||
|
@ -363,7 +325,7 @@ public abstract class PlaybackController {
|
|||
} else if (getMedia() != null) {
|
||||
return getMedia().getPosition();
|
||||
} else {
|
||||
return PlaybackService.INVALID_TIME;
|
||||
return Playable.INVALID_TIME;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -373,7 +335,7 @@ public abstract class PlaybackController {
|
|||
} else if (getMedia() != null) {
|
||||
return getMedia().getDuration();
|
||||
} else {
|
||||
return PlaybackService.INVALID_TIME;
|
||||
return Playable.INVALID_TIME;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -398,13 +360,13 @@ public abstract class PlaybackController {
|
|||
if (playbackService != null) {
|
||||
return playbackService.getSleepTimerTimeLeft();
|
||||
} else {
|
||||
return INVALID_TIME;
|
||||
return Playable.INVALID_TIME;
|
||||
}
|
||||
}
|
||||
|
||||
public void extendSleepTimer(long extendTime) {
|
||||
long timeLeft = getSleepTimerTimeLeft();
|
||||
if (playbackService != null && timeLeft != INVALID_TIME) {
|
||||
if (playbackService != null && timeLeft != Playable.INVALID_TIME) {
|
||||
setSleepTimer(timeLeft + extendTime);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,8 @@ import android.app.PendingIntent;
|
|||
import android.appwidget.AppWidgetManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
|
@ -133,21 +131,21 @@ public abstract class WidgetUpdater {
|
|||
views.setContentDescription(R.id.butPlayExtended, context.getString(R.string.play_label));
|
||||
}
|
||||
views.setOnClickPendingIntent(R.id.butPlay,
|
||||
createMediaButtonIntent(context, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));
|
||||
MediaButtonReceiver.createPendingIntent(context, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));
|
||||
views.setOnClickPendingIntent(R.id.butPlayExtended,
|
||||
createMediaButtonIntent(context, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));
|
||||
MediaButtonReceiver.createPendingIntent(context, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));
|
||||
views.setOnClickPendingIntent(R.id.butRew,
|
||||
createMediaButtonIntent(context, KeyEvent.KEYCODE_MEDIA_REWIND));
|
||||
MediaButtonReceiver.createPendingIntent(context, KeyEvent.KEYCODE_MEDIA_REWIND));
|
||||
views.setOnClickPendingIntent(R.id.butFastForward,
|
||||
createMediaButtonIntent(context, KeyEvent.KEYCODE_MEDIA_FAST_FORWARD));
|
||||
MediaButtonReceiver.createPendingIntent(context, KeyEvent.KEYCODE_MEDIA_FAST_FORWARD));
|
||||
views.setOnClickPendingIntent(R.id.butSkip,
|
||||
createMediaButtonIntent(context, KeyEvent.KEYCODE_MEDIA_NEXT));
|
||||
MediaButtonReceiver.createPendingIntent(context, KeyEvent.KEYCODE_MEDIA_NEXT));
|
||||
} else {
|
||||
// start the app if they click anything
|
||||
views.setOnClickPendingIntent(R.id.layout_left, startMediaPlayer);
|
||||
views.setOnClickPendingIntent(R.id.butPlay, startMediaPlayer);
|
||||
views.setOnClickPendingIntent(R.id.butPlayExtended,
|
||||
createMediaButtonIntent(context, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));
|
||||
MediaButtonReceiver.createPendingIntent(context, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE));
|
||||
views.setViewVisibility(R.id.txtvProgress, View.GONE);
|
||||
views.setViewVisibility(R.id.txtvTitle, View.GONE);
|
||||
views.setViewVisibility(R.id.txtNoPlaying, View.VISIBLE);
|
||||
|
@ -205,19 +203,6 @@ public abstract class WidgetUpdater {
|
|||
return n - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an intent which fakes a mediabutton press.
|
||||
*/
|
||||
private static PendingIntent createMediaButtonIntent(Context context, int eventCode) {
|
||||
KeyEvent event = new KeyEvent(KeyEvent.ACTION_DOWN, eventCode);
|
||||
Intent startingIntent = new Intent(context, MediaButtonReceiver.class);
|
||||
startingIntent.setAction(MediaButtonReceiver.NOTIFY_BUTTON_RECEIVER);
|
||||
startingIntent.putExtra(Intent.EXTRA_KEY_EVENT, event);
|
||||
|
||||
return PendingIntent.getBroadcast(context, eventCode, startingIntent,
|
||||
(Build.VERSION.SDK_INT >= 23 ? PendingIntent.FLAG_IMMUTABLE : 0));
|
||||
}
|
||||
|
||||
private static String getProgressString(int position, int duration, float speed) {
|
||||
if (position < 0 || duration <= 0) {
|
||||
return null;
|
||||
|
|
|
@ -28,11 +28,6 @@ import de.danoeh.antennapod.model.playback.Playable;
|
|||
public abstract class PlaybackServiceMediaPlayer {
|
||||
private static final String TAG = "PlaybackSvcMediaPlayer";
|
||||
|
||||
/**
|
||||
* Return value of some PSMP methods if the method call failed.
|
||||
*/
|
||||
public static final int INVALID_TIME = -1;
|
||||
|
||||
private volatile PlayerStatus oldPlayerStatus;
|
||||
protected volatile PlayerStatus playerStatus;
|
||||
|
||||
|
@ -307,7 +302,7 @@ public abstract class PlaybackServiceMediaPlayer {
|
|||
* @param newStatus The new PlayerStatus. This must not be null.
|
||||
* @param newMedia The new playable object of the PSMP object. This can be null.
|
||||
* @param position The position to be set to the current Playable object in case playback started or paused.
|
||||
* Will be ignored if given the value of {@link #INVALID_TIME}.
|
||||
* Will be ignored if given the value of {@link Playable#INVALID_TIME}.
|
||||
*/
|
||||
protected final synchronized void setPlayerStatus(@NonNull PlayerStatus newStatus,
|
||||
Playable newMedia, int position) {
|
||||
|
@ -337,7 +332,7 @@ public abstract class PlaybackServiceMediaPlayer {
|
|||
* @see #setPlayerStatus(PlayerStatus, Playable, int)
|
||||
*/
|
||||
protected final void setPlayerStatus(@NonNull PlayerStatus newStatus, Playable newMedia) {
|
||||
setPlayerStatus(newStatus, newMedia, INVALID_TIME);
|
||||
setPlayerStatus(newStatus, newMedia, Playable.INVALID_TIME);
|
||||
}
|
||||
|
||||
public interface PSMPCallback {
|
||||
|
|
|
@ -173,7 +173,7 @@ public class CastPsmp extends PlaybackServiceMediaPlayer {
|
|||
|
||||
if (mediaChanged && stateChanged && oldState == MediaStatus.PLAYER_STATE_PLAYING
|
||||
&& state != MediaStatus.PLAYER_STATE_IDLE) {
|
||||
callback.onPlaybackPause(null, INVALID_TIME);
|
||||
callback.onPlaybackPause(null, Playable.INVALID_TIME);
|
||||
// We don't want setPlayerStatus to handle the onPlaybackPause callback
|
||||
setPlayerStatus(PlayerStatus.INDETERMINATE, currentMedia);
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ public class CastPsmp extends PlaybackServiceMediaPlayer {
|
|||
case MediaStatus.PLAYER_STATE_BUFFERING:
|
||||
setPlayerStatus((mediaChanged || playerStatus == PlayerStatus.PREPARING)
|
||||
? PlayerStatus.PREPARING : PlayerStatus.SEEKING, currentMedia,
|
||||
currentMedia != null ? currentMedia.getPosition() : INVALID_TIME);
|
||||
currentMedia != null ? currentMedia.getPosition() : Playable.INVALID_TIME);
|
||||
break;
|
||||
case MediaStatus.PLAYER_STATE_IDLE:
|
||||
int reason = status.getIdleReason();
|
||||
|
@ -218,7 +218,7 @@ public class CastPsmp extends PlaybackServiceMediaPlayer {
|
|||
// Means that a request to load a different media was sent
|
||||
// Not sure if currentMedia already reflects the to be loaded one
|
||||
if (mediaChanged && oldState == MediaStatus.PLAYER_STATE_PLAYING) {
|
||||
callback.onPlaybackPause(null, INVALID_TIME);
|
||||
callback.onPlaybackPause(null, Playable.INVALID_TIME);
|
||||
setPlayerStatus(PlayerStatus.INDETERMINATE, currentMedia);
|
||||
}
|
||||
setPlayerStatus(PlayerStatus.PREPARING, currentMedia);
|
||||
|
@ -376,7 +376,7 @@ public class CastPsmp extends PlaybackServiceMediaPlayer {
|
|||
@Override
|
||||
public void seekDelta(int d) {
|
||||
int position = getPosition();
|
||||
if (position != INVALID_TIME) {
|
||||
if (position != Playable.INVALID_TIME) {
|
||||
seekTo(position + d);
|
||||
} else {
|
||||
Log.e(TAG, "getPosition() returned INVALID_TIME in seekDelta");
|
||||
|
@ -386,7 +386,7 @@ public class CastPsmp extends PlaybackServiceMediaPlayer {
|
|||
@Override
|
||||
public int getDuration() {
|
||||
int retVal = (int) remoteMediaClient.getStreamDuration();
|
||||
if (retVal == INVALID_TIME && media != null && media.getDuration() > 0) {
|
||||
if (retVal == Playable.INVALID_TIME && media != null && media.getDuration() > 0) {
|
||||
retVal = media.getDuration();
|
||||
}
|
||||
return retVal;
|
||||
|
@ -542,7 +542,7 @@ public class CastPsmp extends PlaybackServiceMediaPlayer {
|
|||
}
|
||||
} else if (isPlaying) {
|
||||
callback.onPlaybackPause(currentMedia,
|
||||
currentMedia != null ? currentMedia.getPosition() : INVALID_TIME);
|
||||
currentMedia != null ? currentMedia.getPosition() : Playable.INVALID_TIME);
|
||||
}
|
||||
|
||||
FutureTask<?> future = new FutureTask<>(() -> { }, null);
|
||||
|
|
Loading…
Reference in New Issue