mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
support for parse times
This commit is contained in:
parent
dde659ef01
commit
342cc34d65
@ -1,6 +1,8 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import classnames from "classnames"
|
import classnames from "classnames"
|
||||||
|
|
||||||
|
import parseTimeToMs from "@utils/parseTimeToMs"
|
||||||
|
|
||||||
import useMaxScreen from "@hooks/useMaxScreen"
|
import useMaxScreen from "@hooks/useMaxScreen"
|
||||||
import { usePlayerStateContext } from "@contexts/WithPlayerContext"
|
import { usePlayerStateContext } from "@contexts/WithPlayerContext"
|
||||||
|
|
||||||
@ -62,7 +64,7 @@ const EnchancedLyricsPage = () => {
|
|||||||
// get current track instance
|
// get current track instance
|
||||||
const instance = app.cores.player.track()
|
const instance = app.cores.player.track()
|
||||||
|
|
||||||
const result = await instance.manifest.serviceOperations
|
let result = await instance.manifest.serviceOperations
|
||||||
.fetchLyrics({
|
.fetchLyrics({
|
||||||
preferTranslation: translationEnabled,
|
preferTranslation: translationEnabled,
|
||||||
})
|
})
|
||||||
@ -71,6 +73,10 @@ const EnchancedLyricsPage = () => {
|
|||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (result.sync_audio_at && !result.sync_audio_at_ms) {
|
||||||
|
result.sync_audio_at_ms = parseTimeToMs(result.sync_audio_at)
|
||||||
|
}
|
||||||
|
|
||||||
console.log("Fetched Lyrics >", result)
|
console.log("Fetched Lyrics >", result)
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
|
9
packages/app/src/utils/parseTimeToMs/index.js
Normal file
9
packages/app/src/utils/parseTimeToMs/index.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
export default (timeStr) => {
|
||||||
|
const [minutes, seconds, milliseconds] = timeStr.split(":")
|
||||||
|
|
||||||
|
return (
|
||||||
|
Number(minutes) * 60 * 1000 +
|
||||||
|
Number(seconds) * 1000 +
|
||||||
|
Number(milliseconds)
|
||||||
|
)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user