add a time conversion class
convert time depending on current playback speed and preferences
This commit is contained in:
parent
743ec1927c
commit
6187945e8f
|
@ -0,0 +1,22 @@
|
||||||
|
package de.danoeh.antennapod.core.util;
|
||||||
|
|
||||||
|
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||||
|
|
||||||
|
public class TimeSpeedConverter {
|
||||||
|
private TimeSpeedConverter() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Convert millisecond according to the current playback speed
|
||||||
|
* @param time: time to convert
|
||||||
|
* @return converted time (can be < 0 if time is < 0)
|
||||||
|
*/
|
||||||
|
public static int convert(int time) {
|
||||||
|
boolean timeRespectsSpeed = UserPreferences.timeRespectsSpeed();
|
||||||
|
if (time > 0 && timeRespectsSpeed) {
|
||||||
|
float speed = Float.parseFloat(UserPreferences.getPlaybackSpeed());
|
||||||
|
return (int)(time / speed);
|
||||||
|
}
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue