Skip to content

How to prevent react-howler from creating a new instance of the same song while the previous one is still playing when updating the seek? #133

@barackm

Description

@barackm

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);
    }
  };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions