mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
fix seekbar initial states
This commit is contained in:
parent
0511a508bc
commit
e21a02a5da
@ -8,7 +8,7 @@ import "./index.less"
|
|||||||
|
|
||||||
export default class SeekBar extends React.Component {
|
export default class SeekBar extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
playing: false,
|
playing: app.cores.player.state["playback_status"] === "playing",
|
||||||
timeText: "00:00",
|
timeText: "00:00",
|
||||||
durationText: "00:00",
|
durationText: "00:00",
|
||||||
sliderTime: 0,
|
sliderTime: 0,
|
||||||
@ -31,7 +31,7 @@ export default class SeekBar extends React.Component {
|
|||||||
|
|
||||||
calculateDuration = (preCalculatedDuration) => {
|
calculateDuration = (preCalculatedDuration) => {
|
||||||
// get current audio duration
|
// get current audio duration
|
||||||
const audioDuration = preCalculatedDuration || app.cores.player.duration()
|
const audioDuration = preCalculatedDuration ?? app.cores.player.duration()
|
||||||
|
|
||||||
if (isNaN(audioDuration)) {
|
if (isNaN(audioDuration)) {
|
||||||
return
|
return
|
||||||
@ -102,6 +102,10 @@ export default class SeekBar extends React.Component {
|
|||||||
},
|
},
|
||||||
// handle when player changes track
|
// handle when player changes track
|
||||||
"player.state.update:track_manifest": (manifest) => {
|
"player.state.update:track_manifest": (manifest) => {
|
||||||
|
if (!manifest) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
this.updateAll()
|
this.updateAll()
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
@ -131,6 +135,7 @@ export default class SeekBar extends React.Component {
|
|||||||
|
|
||||||
componentDidMount = () => {
|
componentDidMount = () => {
|
||||||
this.calculateDuration()
|
this.calculateDuration()
|
||||||
|
this.updateAll()
|
||||||
this.tick()
|
this.tick()
|
||||||
|
|
||||||
for (const [event, callback] of Object.entries(this.events)) {
|
for (const [event, callback] of Object.entries(this.events)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user