No need to define INVALID_TIME multiple times
This commit is contained in:
parent
17f2ebd7f2
commit
a29041cd4d
|
@ -669,8 +669,8 @@ public class VideoplayerActivity extends CastEnabledActivity implements SeekBar.
|
||||||
int remainingTime = converter.convert(
|
int remainingTime = converter.convert(
|
||||||
controller.getDuration() - controller.getPosition());
|
controller.getDuration() - controller.getPosition());
|
||||||
Log.d(TAG, "currentPosition " + Converter.getDurationStringLong(currentPosition));
|
Log.d(TAG, "currentPosition " + Converter.getDurationStringLong(currentPosition));
|
||||||
if (currentPosition == PlaybackService.INVALID_TIME
|
if (currentPosition == Playable.INVALID_TIME
|
||||||
|| duration == PlaybackService.INVALID_TIME) {
|
|| duration == Playable.INVALID_TIME) {
|
||||||
Log.w(TAG, "Could not react to position observer update because of invalid time");
|
Log.w(TAG, "Could not react to position observer update because of invalid time");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ import com.google.android.material.elevation.SurfaceColors;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
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.util.playback.PlaybackController;
|
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
||||||
import de.danoeh.antennapod.event.playback.BufferUpdateEvent;
|
import de.danoeh.antennapod.event.playback.BufferUpdateEvent;
|
||||||
import de.danoeh.antennapod.event.playback.PlaybackServiceEvent;
|
import de.danoeh.antennapod.event.playback.PlaybackServiceEvent;
|
||||||
|
@ -375,7 +374,7 @@ public class AudioPlayerFragment extends Fragment implements
|
||||||
int remainingTime = converter.convert(Math.max(event.getDuration() - event.getPosition(), 0));
|
int remainingTime = converter.convert(Math.max(event.getDuration() - event.getPosition(), 0));
|
||||||
currentChapterIndex = ChapterUtils.getCurrentChapterIndex(controller.getMedia(), currentPosition);
|
currentChapterIndex = ChapterUtils.getCurrentChapterIndex(controller.getMedia(), currentPosition);
|
||||||
Log.d(TAG, "currentPosition " + Converter.getDurationStringLong(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");
|
Log.w(TAG, "Could not react to position observer update because of invalid time");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,8 +139,8 @@ public class ExternalPlayerFragment extends Fragment {
|
||||||
public void onPositionObserverUpdate(PlaybackPositionEvent event) {
|
public void onPositionObserverUpdate(PlaybackPositionEvent event) {
|
||||||
if (controller == null) {
|
if (controller == null) {
|
||||||
return;
|
return;
|
||||||
} else if (controller.getPosition() == PlaybackService.INVALID_TIME
|
} else if (controller.getPosition() == Playable.INVALID_TIME
|
||||||
|| controller.getDuration() == PlaybackService.INVALID_TIME) {
|
|| controller.getDuration() == Playable.INVALID_TIME) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
progressBar.setProgress((int)
|
progressBar.setProgress((int)
|
||||||
|
|
|
@ -30,10 +30,10 @@ import de.danoeh.antennapod.model.feed.FeedMedia;
|
||||||
import de.danoeh.antennapod.model.playback.MediaType;
|
import de.danoeh.antennapod.model.playback.MediaType;
|
||||||
import de.danoeh.antennapod.core.feed.util.ImageResourceUtils;
|
import de.danoeh.antennapod.core.feed.util.ImageResourceUtils;
|
||||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
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.Converter;
|
||||||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
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.CircularProgressBar;
|
||||||
import de.danoeh.antennapod.ui.common.ThemeUtils;
|
import de.danoeh.antennapod.ui.common.ThemeUtils;
|
||||||
|
|
||||||
|
@ -230,7 +230,7 @@ public class EpisodeItemViewHolder extends RecyclerView.ViewHolder {
|
||||||
int timeDuration = event.getDuration();
|
int timeDuration = event.getDuration();
|
||||||
int remainingTime = Math.max(timeDuration - currentPosition, 0);
|
int remainingTime = Math.max(timeDuration - currentPosition, 0);
|
||||||
Log.d(TAG, "currentPosition " + Converter.getDurationStringLong(currentPosition));
|
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");
|
Log.w(TAG, "Could not react to position observer update because of invalid time");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.service.download.HttpCredentialEncoder;
|
||||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||||
import de.danoeh.antennapod.core.util.playback.IPlayer;
|
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.Observable;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
|
@ -154,7 +154,7 @@ public class ExoPlayerWrapper implements IPlayer {
|
||||||
@Override
|
@Override
|
||||||
public int getDuration() {
|
public int getDuration() {
|
||||||
if (exoPlayer.getDuration() == C.TIME_UNSET) {
|
if (exoPlayer.getDuration() == C.TIME_UNSET) {
|
||||||
return PlaybackServiceMediaPlayer.INVALID_TIME;
|
return Playable.INVALID_TIME;
|
||||||
}
|
}
|
||||||
return (int) exoPlayer.getDuration();
|
return (int) exoPlayer.getDuration();
|
||||||
}
|
}
|
||||||
|
|
|
@ -543,7 +543,7 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
|
||||||
executor.submit(() -> {
|
executor.submit(() -> {
|
||||||
playerLock.lock();
|
playerLock.lock();
|
||||||
int currentPosition = getPosition();
|
int currentPosition = getPosition();
|
||||||
if (currentPosition != INVALID_TIME) {
|
if (currentPosition != Playable.INVALID_TIME) {
|
||||||
seekToSync(currentPosition + d);
|
seekToSync(currentPosition + d);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "getPosition() returned INVALID_TIME in seekDelta");
|
Log.e(TAG, "getPosition() returned INVALID_TIME in seekDelta");
|
||||||
|
@ -559,10 +559,10 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
|
||||||
@Override
|
@Override
|
||||||
public int getDuration() {
|
public int getDuration() {
|
||||||
if (!playerLock.tryLock()) {
|
if (!playerLock.tryLock()) {
|
||||||
return INVALID_TIME;
|
return Playable.INVALID_TIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
int retVal = INVALID_TIME;
|
int retVal = Playable.INVALID_TIME;
|
||||||
if (playerStatus == PlayerStatus.PLAYING
|
if (playerStatus == PlayerStatus.PLAYING
|
||||||
|| playerStatus == PlayerStatus.PAUSED
|
|| playerStatus == PlayerStatus.PAUSED
|
||||||
|| playerStatus == PlayerStatus.PREPARED) {
|
|| playerStatus == PlayerStatus.PREPARED) {
|
||||||
|
@ -583,13 +583,13 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
|
||||||
public int getPosition() {
|
public int getPosition() {
|
||||||
try {
|
try {
|
||||||
if (!playerLock.tryLock(50, TimeUnit.MILLISECONDS)) {
|
if (!playerLock.tryLock(50, TimeUnit.MILLISECONDS)) {
|
||||||
return INVALID_TIME;
|
return Playable.INVALID_TIME;
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
return INVALID_TIME;
|
return Playable.INVALID_TIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
int retVal = INVALID_TIME;
|
int retVal = Playable.INVALID_TIME;
|
||||||
if (playerStatus.isAtLeast(PlayerStatus.PREPARED)) {
|
if (playerStatus.isAtLeast(PlayerStatus.PREPARED)) {
|
||||||
retVal = mediaPlayer.getCurrentPosition();
|
retVal = mediaPlayer.getCurrentPosition();
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,12 +156,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
*/
|
*/
|
||||||
public static final int NOTIFICATION_TYPE_PLAYBACK_END = 7;
|
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.
|
* Is true if service is running.
|
||||||
*/
|
*/
|
||||||
|
@ -761,7 +755,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
private final PlaybackServiceTaskManager.PSTMCallback taskManagerCallback = new PlaybackServiceTaskManager.PSTMCallback() {
|
private final PlaybackServiceTaskManager.PSTMCallback taskManagerCallback = new PlaybackServiceTaskManager.PSTMCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void positionSaverTick() {
|
public void positionSaverTick() {
|
||||||
saveCurrentPosition(true, null, PlaybackServiceMediaPlayer.INVALID_TIME);
|
saveCurrentPosition(true, null, Playable.INVALID_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -813,7 +807,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
break;
|
break;
|
||||||
case PLAYING:
|
case PLAYING:
|
||||||
PlaybackPreferences.writePlayerStatus(mediaPlayer.getPlayerStatus());
|
PlaybackPreferences.writePlayerStatus(mediaPlayer.getPlayerStatus());
|
||||||
saveCurrentPosition(true, null, INVALID_TIME);
|
saveCurrentPosition(true, null, Playable.INVALID_TIME);
|
||||||
updateNotificationAndMediaSession(newInfo.playable);
|
updateNotificationAndMediaSession(newInfo.playable);
|
||||||
setupPositionObserver();
|
setupPositionObserver();
|
||||||
stateManager.validStartCommandWasReceived();
|
stateManager.validStartCommandWasReceived();
|
||||||
|
@ -868,7 +862,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
@Override
|
@Override
|
||||||
public void onPlaybackStart(@NonNull Playable playable, int position) {
|
public void onPlaybackStart(@NonNull Playable playable, int position) {
|
||||||
taskManager.startWidgetUpdater();
|
taskManager.startWidgetUpdater();
|
||||||
if (position != PlaybackServiceMediaPlayer.INVALID_TIME) {
|
if (position != Playable.INVALID_TIME) {
|
||||||
playable.setPosition(position);
|
playable.setPosition(position);
|
||||||
} else {
|
} else {
|
||||||
skipIntro(playable);
|
skipIntro(playable);
|
||||||
|
@ -881,8 +875,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
public void onPlaybackPause(Playable playable, int position) {
|
public void onPlaybackPause(Playable playable, int position) {
|
||||||
taskManager.cancelPositionSaver();
|
taskManager.cancelPositionSaver();
|
||||||
cancelPositionObserver();
|
cancelPositionObserver();
|
||||||
saveCurrentPosition(position == PlaybackServiceMediaPlayer.INVALID_TIME || playable == null,
|
saveCurrentPosition(position == Playable.INVALID_TIME || playable == null, playable, position);
|
||||||
playable, position);
|
|
||||||
taskManager.cancelWidgetUpdater();
|
taskManager.cancelWidgetUpdater();
|
||||||
if (playable != null) {
|
if (playable != null) {
|
||||||
if (playable instanceof FeedMedia) {
|
if (playable instanceof FeedMedia) {
|
||||||
|
@ -1377,7 +1370,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
} else {
|
} else {
|
||||||
duration = playable.getDuration();
|
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);
|
Log.d(TAG, "Saving current position to " + position);
|
||||||
PlayableUtils.saveCurrentPosition(playable, position, System.currentTimeMillis());
|
PlayableUtils.saveCurrentPosition(playable, position, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
@ -1653,7 +1646,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
*/
|
*/
|
||||||
public int getDuration() {
|
public int getDuration() {
|
||||||
if (mediaPlayer == null) {
|
if (mediaPlayer == null) {
|
||||||
return INVALID_TIME;
|
return Playable.INVALID_TIME;
|
||||||
}
|
}
|
||||||
return mediaPlayer.getDuration();
|
return mediaPlayer.getDuration();
|
||||||
}
|
}
|
||||||
|
@ -1664,7 +1657,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
||||||
*/
|
*/
|
||||||
public int getCurrentPosition() {
|
public int getCurrentPosition() {
|
||||||
if (mediaPlayer == null) {
|
if (mediaPlayer == null) {
|
||||||
return INVALID_TIME;
|
return Playable.INVALID_TIME;
|
||||||
}
|
}
|
||||||
return mediaPlayer.getPosition();
|
return mediaPlayer.getPosition();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ import java.util.List;
|
||||||
public abstract class PlaybackController {
|
public abstract class PlaybackController {
|
||||||
|
|
||||||
private static final String TAG = "PlaybackController";
|
private static final String TAG = "PlaybackController";
|
||||||
private static final int INVALID_TIME = -1;
|
|
||||||
|
|
||||||
private final Activity activity;
|
private final Activity activity;
|
||||||
private PlaybackService playbackService;
|
private PlaybackService playbackService;
|
||||||
|
@ -363,7 +362,7 @@ public abstract class PlaybackController {
|
||||||
} else if (getMedia() != null) {
|
} else if (getMedia() != null) {
|
||||||
return getMedia().getPosition();
|
return getMedia().getPosition();
|
||||||
} else {
|
} else {
|
||||||
return PlaybackService.INVALID_TIME;
|
return Playable.INVALID_TIME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,7 +372,7 @@ public abstract class PlaybackController {
|
||||||
} else if (getMedia() != null) {
|
} else if (getMedia() != null) {
|
||||||
return getMedia().getDuration();
|
return getMedia().getDuration();
|
||||||
} else {
|
} else {
|
||||||
return PlaybackService.INVALID_TIME;
|
return Playable.INVALID_TIME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,13 +397,13 @@ public abstract class PlaybackController {
|
||||||
if (playbackService != null) {
|
if (playbackService != null) {
|
||||||
return playbackService.getSleepTimerTimeLeft();
|
return playbackService.getSleepTimerTimeLeft();
|
||||||
} else {
|
} else {
|
||||||
return INVALID_TIME;
|
return Playable.INVALID_TIME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void extendSleepTimer(long extendTime) {
|
public void extendSleepTimer(long extendTime) {
|
||||||
long timeLeft = getSleepTimerTimeLeft();
|
long timeLeft = getSleepTimerTimeLeft();
|
||||||
if (playbackService != null && timeLeft != INVALID_TIME) {
|
if (playbackService != null && timeLeft != Playable.INVALID_TIME) {
|
||||||
setSleepTimer(timeLeft + extendTime);
|
setSleepTimer(timeLeft + extendTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,6 @@ import de.danoeh.antennapod.model.playback.Playable;
|
||||||
public abstract class PlaybackServiceMediaPlayer {
|
public abstract class PlaybackServiceMediaPlayer {
|
||||||
private static final String TAG = "PlaybackSvcMediaPlayer";
|
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;
|
private volatile PlayerStatus oldPlayerStatus;
|
||||||
protected volatile PlayerStatus playerStatus;
|
protected volatile PlayerStatus playerStatus;
|
||||||
|
|
||||||
|
@ -307,7 +302,7 @@ public abstract class PlaybackServiceMediaPlayer {
|
||||||
* @param newStatus The new PlayerStatus. This must not be null.
|
* @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 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.
|
* @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,
|
protected final synchronized void setPlayerStatus(@NonNull PlayerStatus newStatus,
|
||||||
Playable newMedia, int position) {
|
Playable newMedia, int position) {
|
||||||
|
@ -337,7 +332,7 @@ public abstract class PlaybackServiceMediaPlayer {
|
||||||
* @see #setPlayerStatus(PlayerStatus, Playable, int)
|
* @see #setPlayerStatus(PlayerStatus, Playable, int)
|
||||||
*/
|
*/
|
||||||
protected final void setPlayerStatus(@NonNull PlayerStatus newStatus, Playable newMedia) {
|
protected final void setPlayerStatus(@NonNull PlayerStatus newStatus, Playable newMedia) {
|
||||||
setPlayerStatus(newStatus, newMedia, INVALID_TIME);
|
setPlayerStatus(newStatus, newMedia, Playable.INVALID_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface PSMPCallback {
|
public interface PSMPCallback {
|
||||||
|
|
|
@ -173,7 +173,7 @@ public class CastPsmp extends PlaybackServiceMediaPlayer {
|
||||||
|
|
||||||
if (mediaChanged && stateChanged && oldState == MediaStatus.PLAYER_STATE_PLAYING
|
if (mediaChanged && stateChanged && oldState == MediaStatus.PLAYER_STATE_PLAYING
|
||||||
&& state != MediaStatus.PLAYER_STATE_IDLE) {
|
&& 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
|
// We don't want setPlayerStatus to handle the onPlaybackPause callback
|
||||||
setPlayerStatus(PlayerStatus.INDETERMINATE, currentMedia);
|
setPlayerStatus(PlayerStatus.INDETERMINATE, currentMedia);
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ public class CastPsmp extends PlaybackServiceMediaPlayer {
|
||||||
case MediaStatus.PLAYER_STATE_BUFFERING:
|
case MediaStatus.PLAYER_STATE_BUFFERING:
|
||||||
setPlayerStatus((mediaChanged || playerStatus == PlayerStatus.PREPARING)
|
setPlayerStatus((mediaChanged || playerStatus == PlayerStatus.PREPARING)
|
||||||
? PlayerStatus.PREPARING : PlayerStatus.SEEKING, currentMedia,
|
? PlayerStatus.PREPARING : PlayerStatus.SEEKING, currentMedia,
|
||||||
currentMedia != null ? currentMedia.getPosition() : INVALID_TIME);
|
currentMedia != null ? currentMedia.getPosition() : Playable.INVALID_TIME);
|
||||||
break;
|
break;
|
||||||
case MediaStatus.PLAYER_STATE_IDLE:
|
case MediaStatus.PLAYER_STATE_IDLE:
|
||||||
int reason = status.getIdleReason();
|
int reason = status.getIdleReason();
|
||||||
|
@ -218,7 +218,7 @@ public class CastPsmp extends PlaybackServiceMediaPlayer {
|
||||||
// Means that a request to load a different media was sent
|
// Means that a request to load a different media was sent
|
||||||
// Not sure if currentMedia already reflects the to be loaded one
|
// Not sure if currentMedia already reflects the to be loaded one
|
||||||
if (mediaChanged && oldState == MediaStatus.PLAYER_STATE_PLAYING) {
|
if (mediaChanged && oldState == MediaStatus.PLAYER_STATE_PLAYING) {
|
||||||
callback.onPlaybackPause(null, INVALID_TIME);
|
callback.onPlaybackPause(null, Playable.INVALID_TIME);
|
||||||
setPlayerStatus(PlayerStatus.INDETERMINATE, currentMedia);
|
setPlayerStatus(PlayerStatus.INDETERMINATE, currentMedia);
|
||||||
}
|
}
|
||||||
setPlayerStatus(PlayerStatus.PREPARING, currentMedia);
|
setPlayerStatus(PlayerStatus.PREPARING, currentMedia);
|
||||||
|
@ -376,7 +376,7 @@ public class CastPsmp extends PlaybackServiceMediaPlayer {
|
||||||
@Override
|
@Override
|
||||||
public void seekDelta(int d) {
|
public void seekDelta(int d) {
|
||||||
int position = getPosition();
|
int position = getPosition();
|
||||||
if (position != INVALID_TIME) {
|
if (position != Playable.INVALID_TIME) {
|
||||||
seekTo(position + d);
|
seekTo(position + d);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "getPosition() returned INVALID_TIME in seekDelta");
|
Log.e(TAG, "getPosition() returned INVALID_TIME in seekDelta");
|
||||||
|
@ -386,7 +386,7 @@ public class CastPsmp extends PlaybackServiceMediaPlayer {
|
||||||
@Override
|
@Override
|
||||||
public int getDuration() {
|
public int getDuration() {
|
||||||
int retVal = (int) remoteMediaClient.getStreamDuration();
|
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();
|
retVal = media.getDuration();
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
|
@ -542,7 +542,7 @@ public class CastPsmp extends PlaybackServiceMediaPlayer {
|
||||||
}
|
}
|
||||||
} else if (isPlaying) {
|
} else if (isPlaying) {
|
||||||
callback.onPlaybackPause(currentMedia,
|
callback.onPlaybackPause(currentMedia,
|
||||||
currentMedia != null ? currentMedia.getPosition() : INVALID_TIME);
|
currentMedia != null ? currentMedia.getPosition() : Playable.INVALID_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
FutureTask<?> future = new FutureTask<>(() -> { }, null);
|
FutureTask<?> future = new FutureTask<>(() -> { }, null);
|
||||||
|
|
Loading…
Reference in New Issue