diff --git a/packages/app/src/components/MusicTrack/index.jsx b/packages/app/src/components/MusicTrack/index.jsx index 06ecef34..123297f7 100644 --- a/packages/app/src/components/MusicTrack/index.jsx +++ b/packages/app/src/components/MusicTrack/index.jsx @@ -1,6 +1,8 @@ import React from "react" import * as antd from "antd" import classnames from "classnames" +import LikeButton from "components/LikeButton" +import seekToTimeLabel from "utils/seekToTimeLabel" import { ImageViewer } from "components" import { Icons } from "components/Icons" @@ -16,6 +18,7 @@ export default (props) => { playbackStatus, } = React.useContext(Context) + const isLiked = props.track?.liked const isCurrent = currentManifest?._id === props.track._id const isPlaying = isCurrent && playbackStatus === "playing" @@ -49,9 +52,11 @@ export default (props) => { /> +
+
{props.track.title} @@ -61,10 +66,21 @@ export default (props) => {
-
-
- {props.track.duration ?? "00:00"} +
+
+
+ { + props.track.metadata?.duration + ? seekToTimeLabel(props.track.metadata?.duration) + : "00:00" + } +
+ +
} \ No newline at end of file diff --git a/packages/app/src/components/MusicTrack/index.less b/packages/app/src/components/MusicTrack/index.less index 61355870..5a18c94d 100644 --- a/packages/app/src/components/MusicTrack/index.less +++ b/packages/app/src/components/MusicTrack/index.less @@ -152,14 +152,21 @@ } } - .music-track_info { + .music-track_right_actions { display: flex; - flex-direction: column; + flex-direction: row; + + align-items: center; + justify-content: center; + + gap: 10px; margin-left: auto; color: var(--text-color); + } + .music-track_info { .music-track_duration { font-size: 0.8rem; } diff --git a/packages/app/src/utils/seekToTimeLabel/index.js b/packages/app/src/utils/seekToTimeLabel/index.js new file mode 100644 index 00000000..5b812ed7 --- /dev/null +++ b/packages/app/src/utils/seekToTimeLabel/index.js @@ -0,0 +1,15 @@ +export default (value) => { + // convert seek to minutes and seconds + const minutes = Math.floor(value / 60) + + // add leading zero if minutes is less than 10 + const minutesString = minutes < 10 ? `0${minutes}` : minutes + + // get seconds + const seconds = Math.floor(value - minutes * 60) + + // add leading zero if seconds is less than 10 + const secondsString = seconds < 10 ? `0${seconds}` : seconds + + return `${minutesString}:${secondsString}` +} \ No newline at end of file