Moved logic for selecting playback speed entirely to UserPreferences
This commit is contained in:
parent
19896f0ec2
commit
684213c291
@ -80,7 +80,7 @@ public class AudioplayerActivity extends MediaplayerInfoActivity {
|
||||
}
|
||||
float speed = 1.0f;
|
||||
if(controller.canSetPlaybackSpeed()) {
|
||||
speed = getPlaybackSpeedForMedia();
|
||||
speed = UserPreferences.getPlaybackSpeed(controller.getMedia());
|
||||
}
|
||||
String speedStr = new DecimalFormat("0.00x").format(speed);
|
||||
butPlaybackSpeed.setText(speedStr);
|
||||
@ -107,7 +107,7 @@ public class AudioplayerActivity extends MediaplayerInfoActivity {
|
||||
|
||||
float currentSpeedValue = controller.getCurrentPlaybackSpeedMultiplier();
|
||||
if (currentSpeedValue == -1) {
|
||||
currentSpeedValue = getPlaybackSpeedForMedia();
|
||||
currentSpeedValue = UserPreferences.getPlaybackSpeed(controller.getMedia());
|
||||
}
|
||||
|
||||
String currentSpeed = new DecimalFormat("0.00", format).format(currentSpeedValue);
|
||||
|
@ -874,22 +874,4 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float getPlaybackSpeedForMedia() {
|
||||
float playbackSpeed = SPEED_USE_GLOBAL;
|
||||
if (controller != null) {
|
||||
Playable media = controller.getMedia();
|
||||
boolean isFeedMedia = media instanceof FeedMedia;
|
||||
|
||||
if (isFeedMedia) {
|
||||
playbackSpeed = ((FeedMedia) media).getMediaPlaybackSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
if (playbackSpeed == SPEED_USE_GLOBAL) {
|
||||
playbackSpeed = UserPreferences.getPlaybackSpeed();
|
||||
}
|
||||
|
||||
return playbackSpeed;
|
||||
}
|
||||
}
|
||||
|
@ -212,24 +212,11 @@ public class PlaybackControlsDialog extends DialogFragment {
|
||||
}
|
||||
|
||||
private float getCurrentSpeed() {
|
||||
float playbackSpeed = SPEED_USE_GLOBAL;
|
||||
Playable media = null;
|
||||
if (controller != null) {
|
||||
Playable media = controller.getMedia();
|
||||
boolean isFeedMedia = media instanceof FeedMedia;
|
||||
|
||||
if (isFeedMedia) {
|
||||
playbackSpeed = ((FeedMedia) media).getMediaPlaybackSpeed();
|
||||
}
|
||||
media = controller.getMedia();
|
||||
}
|
||||
|
||||
if (playbackSpeed == SPEED_USE_GLOBAL) {
|
||||
if (isPlayingVideo) {
|
||||
playbackSpeed = UserPreferences.getVideoPlaybackSpeed();
|
||||
} else {
|
||||
playbackSpeed = UserPreferences.getPlaybackSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
return playbackSpeed;
|
||||
return UserPreferences.getPlaybackSpeed(media);
|
||||
}
|
||||
}
|
||||
|
@ -606,7 +606,7 @@ public class QueueFragment extends Fragment {
|
||||
playbackSpeed = feed.getPreferences().getCurrentPlaybackSpeed();
|
||||
}
|
||||
if (playbackSpeed == SPEED_USE_GLOBAL) {
|
||||
playbackSpeed = UserPreferences.getPlaybackSpeed();
|
||||
playbackSpeed = UserPreferences.getPlaybackSpeed(item.getMedia());
|
||||
}
|
||||
if(item.getMedia() != null) {
|
||||
timeLeft +=
|
||||
|
@ -22,6 +22,8 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.danoeh.antennapod.core.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.core.feed.MediaType;
|
||||
import de.danoeh.antennapod.core.R;
|
||||
import de.danoeh.antennapod.core.service.download.ProxyConfig;
|
||||
import de.danoeh.antennapod.core.storage.APCleanupAlgorithm;
|
||||
@ -29,9 +31,12 @@ import de.danoeh.antennapod.core.storage.APNullCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.core.storage.APQueueCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.core.storage.EpisodeCleanupAlgorithm;
|
||||
import de.danoeh.antennapod.core.util.Converter;
|
||||
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||
import de.danoeh.antennapod.core.util.SortOrder;
|
||||
import de.danoeh.antennapod.core.util.download.AutoUpdateManager;
|
||||
|
||||
import static de.danoeh.antennapod.core.feed.FeedPreferences.SPEED_USE_GLOBAL;
|
||||
|
||||
/**
|
||||
* Provides access to preferences set by the user in the settings screen. A
|
||||
* private instance of this class must first be instantiated via
|
||||
@ -320,7 +325,26 @@ public class UserPreferences {
|
||||
return prefs.getBoolean(PREF_DELETE_REMOVES_FROM_QUEUE, false);
|
||||
}
|
||||
|
||||
public static float getPlaybackSpeed() {
|
||||
public static float getPlaybackSpeed(Playable media) {
|
||||
float playbackSpeed = SPEED_USE_GLOBAL;
|
||||
if (media != null) {
|
||||
if (media instanceof FeedMedia) {
|
||||
playbackSpeed = ((FeedMedia) media).getMediaPlaybackSpeed();
|
||||
}
|
||||
|
||||
if (playbackSpeed == SPEED_USE_GLOBAL && media.getMediaType() == MediaType.VIDEO) {
|
||||
playbackSpeed = getVideoPlaybackSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
if (playbackSpeed == SPEED_USE_GLOBAL) {
|
||||
playbackSpeed = getAudioPlaybackSpeed();
|
||||
}
|
||||
|
||||
return playbackSpeed;
|
||||
}
|
||||
|
||||
private static float getAudioPlaybackSpeed() {
|
||||
try {
|
||||
return Float.parseFloat(prefs.getString(PREF_PLAYBACK_SPEED, "1.00"));
|
||||
} catch (NumberFormatException e) {
|
||||
@ -330,7 +354,7 @@ public class UserPreferences {
|
||||
}
|
||||
}
|
||||
|
||||
public static float getVideoPlaybackSpeed() {
|
||||
private static float getVideoPlaybackSpeed() {
|
||||
try {
|
||||
return Float.parseFloat(prefs.getString(PREF_VIDEO_PLAYBACK_SPEED, "1.00"));
|
||||
} catch (NumberFormatException e) {
|
||||
|
@ -308,19 +308,7 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
|
||||
Log.d(TAG, "Resuming/Starting playback");
|
||||
acquireWifiLockIfNecessary();
|
||||
|
||||
float playbackSpeed = SPEED_USE_GLOBAL;
|
||||
if (media instanceof FeedMedia) {
|
||||
playbackSpeed = ((FeedMedia) media).getMediaPlaybackSpeed();
|
||||
}
|
||||
if (playbackSpeed == SPEED_USE_GLOBAL) {
|
||||
if (media.getMediaType() == MediaType.VIDEO) {
|
||||
playbackSpeed = UserPreferences.getVideoPlaybackSpeed();
|
||||
} else {
|
||||
playbackSpeed = UserPreferences.getPlaybackSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
setPlaybackParams(playbackSpeed, UserPreferences.isSkipSilence());
|
||||
setPlaybackParams(UserPreferences.getPlaybackSpeed(media), UserPreferences.isSkipSilence());
|
||||
setVolume(UserPreferences.getLeftVolume(), UserPreferences.getRightVolume());
|
||||
|
||||
if (playerStatus == PlayerStatus.PREPARED && media.getPosition() > 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user