mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 14:03:26 +00:00
Improve layout, add current time and duration
This commit is contained in:
18
apps/expo/src/components/player/utils.ts
Normal file
18
apps/expo/src/components/player/utils.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export const mapMillisecondsToTime = (milliseconds: number): string => {
|
||||
const hours = Math.floor(milliseconds / (1000 * 60 * 60));
|
||||
const minutes = Math.floor((milliseconds % (1000 * 60 * 60)) / (1000 * 60));
|
||||
const seconds = Math.floor((milliseconds % (1000 * 60)) / 1000);
|
||||
|
||||
const components: string[] = [];
|
||||
|
||||
if (hours > 0) {
|
||||
components.push(hours.toString().padStart(2, "0"));
|
||||
}
|
||||
|
||||
components.push(minutes.toString().padStart(2, "0"));
|
||||
components.push(seconds.toString().padStart(2, "0"));
|
||||
|
||||
const formattedTime = components.join(":");
|
||||
|
||||
return formattedTime;
|
||||
};
|
Reference in New Issue
Block a user