mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
use seekToTimeLabel
utils
This commit is contained in:
parent
c225658d15
commit
c275242f1e
@ -2,6 +2,7 @@ import React from "react"
|
|||||||
import * as antd from "antd"
|
import * as antd from "antd"
|
||||||
import Slider from "@mui/material/Slider"
|
import Slider from "@mui/material/Slider"
|
||||||
import classnames from "classnames"
|
import classnames from "classnames"
|
||||||
|
import seekToTimeLabel from "utils/seekToTimeLabel"
|
||||||
|
|
||||||
import "./index.less"
|
import "./index.less"
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ export default class SeekBar extends React.Component {
|
|||||||
|
|
||||||
// set duration
|
// set duration
|
||||||
this.setState({
|
this.setState({
|
||||||
durationText: this.seekToTimeLabel(audioDuration)
|
durationText: seekToTimeLabel(audioDuration)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,26 +50,10 @@ export default class SeekBar extends React.Component {
|
|||||||
|
|
||||||
// set time
|
// set time
|
||||||
this.setState({
|
this.setState({
|
||||||
timeText: this.seekToTimeLabel(seek)
|
timeText: seekToTimeLabel(seek)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
seekToTimeLabel = (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}`
|
|
||||||
}
|
|
||||||
|
|
||||||
updateProgressBar = () => {
|
updateProgressBar = () => {
|
||||||
if (this.state.sliderLock) {
|
if (this.state.sliderLock) {
|
||||||
return
|
return
|
||||||
@ -209,7 +194,7 @@ export default class SeekBar extends React.Component {
|
|||||||
}}
|
}}
|
||||||
valueLabelDisplay="auto"
|
valueLabelDisplay="auto"
|
||||||
valueLabelFormat={(value) => {
|
valueLabelFormat={(value) => {
|
||||||
return this.seekToTimeLabel((value / 100) * app.cores.player.duration())
|
return seekToTimeLabel((value / 100) * app.cores.player.duration())
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user