import React from "react"; import MusicPlayer from "../melodii/MusicPlayer"; var mp = new MusicPlayer(); export default class SeekBar extends React.Component { constructor(props) { super(props); this.isPlayingOnMouseDown = false; this.onChangeUsed = false; } /** @param {Event} e */ handleChange(e) { mp.seek(+e.target.value); this.onChangeUsed = true; } /** @param {KeyboardEvent} e */ handleMouseDown(e) { this.isPlayingOnMouseDown = !mp.isPaused; mp.pause(); } /** @param {MouseEvent} e */ handleMouseUp(e) { if (!this.onChangeUsed) { mp.seek(+e.target.value); } if (this.isPlayingOnMouseDown) mp.play(); } render() { return (