I am trying to create an audio player, I have been following the documentation here for the full control example,
However, when I try to update the seek of the player with my range input, the same song starts playing from the beginning while the previous one is still playing.
Here are the methods I use to manage the player seek
// called on the onChange event
handleSeekingChange = (e) => {
this.setState({
currentTime: parseFloat(e.target.value),
});
};
// called on the onMouseDown event
handleMouseDownSeek = () => {
this.setState({
isSeeking: true,
});
};
// called on the onMouseUp
handleMouseUpSeek = (e) => {
this.setState({
isSeeking: false,
});
this.player.seek(e.target.value);
};
renderSeekPos = () => {
const { states } = this.props;
const { isSeeking } = this.state;
const { isPlaying } = states;
if (!isSeeking) {
this.setState({
currentTime: this.player.seek(),
});
}
if (isPlaying) {
this._raf = raf(this.renderSeekPos);
}
};