|
|
|
|
@ -15,6 +15,8 @@ import androidx.media3.ui.TimeBar; |
|
|
|
|
import com.fongmi.android.tv.R; |
|
|
|
|
import com.fongmi.android.tv.player.Players; |
|
|
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
|
|
public class CustomSeekView extends FrameLayout implements TimeBar.OnScrubListener { |
|
|
|
|
|
|
|
|
|
private static final int MAX_UPDATE_INTERVAL_MS = 1000; |
|
|
|
|
@ -87,6 +89,7 @@ public class CustomSeekView extends FrameLayout implements TimeBar.OnScrubListen |
|
|
|
|
currentPosition = position; |
|
|
|
|
currentBuffered = buffered; |
|
|
|
|
if (durationChanged) { |
|
|
|
|
setKeyTimeIncrement(duration); |
|
|
|
|
timeBar.setDuration(duration); |
|
|
|
|
durationView.setText(player.stringToTime(duration < 0 ? 0 : duration)); |
|
|
|
|
} |
|
|
|
|
@ -105,6 +108,24 @@ public class CustomSeekView extends FrameLayout implements TimeBar.OnScrubListen |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void setKeyTimeIncrement(long duration) { |
|
|
|
|
if (duration > TimeUnit.HOURS.toMillis(2)) { |
|
|
|
|
timeBar.setKeyTimeIncrement(TimeUnit.MINUTES.toMillis(10)); |
|
|
|
|
} else if (duration > TimeUnit.HOURS.toMillis(1)) { |
|
|
|
|
timeBar.setKeyTimeIncrement(TimeUnit.MINUTES.toMillis(3)); |
|
|
|
|
} else if (duration > TimeUnit.MINUTES.toMillis(30)) { |
|
|
|
|
timeBar.setKeyTimeIncrement(TimeUnit.MINUTES.toMillis(1)); |
|
|
|
|
} else if (duration > TimeUnit.MINUTES.toMillis(15)) { |
|
|
|
|
timeBar.setKeyTimeIncrement(TimeUnit.SECONDS.toMillis(30)); |
|
|
|
|
} else if (duration > TimeUnit.MINUTES.toMillis(10)) { |
|
|
|
|
timeBar.setKeyTimeIncrement(TimeUnit.SECONDS.toMillis(15)); |
|
|
|
|
} else if (duration > TimeUnit.MINUTES.toMillis(5)) { |
|
|
|
|
timeBar.setKeyTimeIncrement(TimeUnit.SECONDS.toMillis(10)); |
|
|
|
|
} else if (duration > 0) { |
|
|
|
|
timeBar.setKeyTimeIncrement(TimeUnit.SECONDS.toMillis(5)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private long delayMs(long position) { |
|
|
|
|
long mediaTimeUntilNextFullSecondMs = 1000 - position % 1000; |
|
|
|
|
long mediaTimeDelayMs = Math.min(timeBar.getPreferredUpdateDelay(), mediaTimeUntilNextFullSecondMs); |
|
|
|
|
|