问题
I want to allow the user of my app to trim a specific part from a video. And i'm looking for a solution that can help me make a time selection slider with two thumbs(Max and Min time).
This is a sample of what i want to achieve .
I know that there is already some librarys that can help:
android-range-seek-bar
Material Range Bar
But they work only with floats and integers. My question is how can i make it work with time values ?
回答1:
Basically you can represent time with a numeric type! With integer you can have a range time from 0
to Integer.MAX_VALUE
seconds (for example)
What do you need is display this int value in a mm:ss
format.
I don't know if the libs up here already do this, however I suggest to fork one on that and work on the values displayed on screen.
Example from another (using millis) SO link
String hms = String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(millis),
TimeUnit.MILLISECONDS.toMinutes(millis) % TimeUnit.HOURS.toMinutes(1),
TimeUnit.MILLISECONDS.toSeconds(millis) % TimeUnit.MINUTES.toSeconds(1));
来源:https://stackoverflow.com/questions/37243318/android-time-range-seek-bar