use time converter and pref in MediaPlayer and Widget
This commit is contained in:
parent
6187945e8f
commit
cf638a4978
|
@ -56,6 +56,7 @@ import de.danoeh.antennapod.core.util.IntentUtils;
|
|||
import de.danoeh.antennapod.core.util.ShareUtils;
|
||||
import de.danoeh.antennapod.core.util.StorageUtils;
|
||||
import de.danoeh.antennapod.core.util.Supplier;
|
||||
import de.danoeh.antennapod.core.util.TimeSpeedConverter;
|
||||
import de.danoeh.antennapod.core.util.gui.PictureInPictureUtil;
|
||||
import de.danoeh.antennapod.core.util.playback.ExternalMedia;
|
||||
import de.danoeh.antennapod.core.util.playback.MediaPlayerError;
|
||||
|
@ -684,8 +685,11 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
|||
if (controller == null || txtvPosition == null || txtvLength == null) {
|
||||
return;
|
||||
}
|
||||
int currentPosition = controller.getPosition();
|
||||
int duration = controller.getDuration();
|
||||
|
||||
int currentPosition = TimeSpeedConverter.convert(controller.getPosition());
|
||||
int duration = TimeSpeedConverter.convert(controller.getDuration());
|
||||
int remainingTime = TimeSpeedConverter.convert(
|
||||
controller.getDuration() - controller.getPosition());
|
||||
Log.d(TAG, "currentPosition " + Converter.getDurationStringLong(currentPosition));
|
||||
if (currentPosition == PlaybackService.INVALID_TIME ||
|
||||
duration == PlaybackService.INVALID_TIME) {
|
||||
|
@ -694,7 +698,7 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
|||
}
|
||||
txtvPosition.setText(Converter.getDurationStringLong(currentPosition));
|
||||
if (showTimeLeft) {
|
||||
txtvLength.setText("-" + Converter.getDurationStringLong(duration - currentPosition));
|
||||
txtvLength.setText("-" + Converter.getDurationStringLong(remainingTime));
|
||||
} else {
|
||||
txtvLength.setText(Converter.getDurationStringLong(duration));
|
||||
}
|
||||
|
@ -842,9 +846,13 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
|||
|
||||
String length;
|
||||
if (showTimeLeft) {
|
||||
length = "-" + Converter.getDurationStringLong(media.getDuration() - media.getPosition());
|
||||
int remainingTime = TimeSpeedConverter.convert(
|
||||
media.getDuration() - media.getPosition());
|
||||
|
||||
length = "-" + Converter.getDurationStringLong(remainingTime);
|
||||
} else {
|
||||
length = Converter.getDurationStringLong(media.getDuration());
|
||||
int duration = TimeSpeedConverter.convert(media.getDuration());
|
||||
length = Converter.getDurationStringLong(duration);
|
||||
}
|
||||
txtvLength.setText(length);
|
||||
|
||||
|
@ -947,7 +955,8 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
|||
prog = controller.onSeekBarProgressChanged(seekBar, progress, fromUser, txtvPosition);
|
||||
if (showTimeLeft && prog != 0) {
|
||||
int duration = controller.getDuration();
|
||||
String length = "-" + Converter.getDurationStringLong(duration - (int) (prog * duration));
|
||||
int timeLeft = TimeSpeedConverter.convert(duration - (int) (prog * duration));
|
||||
String length = "-" + Converter.getDurationStringLong(timeLeft);
|
||||
txtvLength.setText(length);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import de.danoeh.antennapod.core.receiver.PlayerWidget;
|
|||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||
import de.danoeh.antennapod.core.service.playback.PlayerStatus;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.TimeSpeedConverter;
|
||||
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||
|
||||
/**
|
||||
|
@ -152,6 +153,8 @@ public class PlayerWidgetJobService extends SafeJobIntentService {
|
|||
|
||||
private String getProgressString(int position, int duration) {
|
||||
if (position > 0 && duration > 0) {
|
||||
position = TimeSpeedConverter.convert(position);
|
||||
duration = TimeSpeedConverter.convert(duration);
|
||||
return Converter.getDurationStringLong(position) + " / "
|
||||
+ Converter.getDurationStringLong(duration);
|
||||
} else {
|
||||
|
|
|
@ -36,6 +36,7 @@ import de.danoeh.antennapod.core.service.playback.PlayerStatus;
|
|||
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.Optional;
|
||||
import de.danoeh.antennapod.core.util.TimeSpeedConverter;
|
||||
import de.danoeh.antennapod.core.util.playback.Playable.PlayableUtils;
|
||||
import io.reactivex.Maybe;
|
||||
import io.reactivex.MaybeOnSubscribe;
|
||||
|
@ -540,8 +541,8 @@ public abstract class PlaybackController {
|
|||
if (fromUser && playbackService != null && media != null) {
|
||||
float prog = progress / ((float) seekBar.getMax());
|
||||
int duration = media.getDuration();
|
||||
txtvPosition.setText(Converter
|
||||
.getDurationStringLong((int) (prog * duration)));
|
||||
int position = TimeSpeedConverter.convert((int) (prog * duration));
|
||||
txtvPosition.setText(Converter.getDurationStringLong(position));
|
||||
return prog;
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue