Add: sleep stop timer

This commit is contained in:
2022-01-15 00:53:42 +08:00
parent a367b9253e
commit a84dfe8178
2 changed files with 34 additions and 0 deletions

View File

@@ -108,3 +108,6 @@ dialog {
.warp-word { .warp-word {
overflow-wrap: anywhere; overflow-wrap: anywhere;
} }
.number-input {
width: 5em;
}

View File

@@ -18,6 +18,8 @@ function AudioPlayer(props) {
}); });
const [playingURL, setPlayingURL] = useState(""); const [playingURL, setPlayingURL] = useState("");
const [isPreparing, setIsPreparing] = useState(false); const [isPreparing, setIsPreparing] = useState(false);
const [timerCount, setTimerCount] = useState(0);
const [timerID, setTimerID] = useState(null);
useEffect(() => { useEffect(() => {
// no playing file // no playing file
@@ -111,6 +113,35 @@ function AudioPlayer(props) {
<br /> <br />
<span className="horizontal">
<input
className="number-input"
disabled={timerID !== null}
type="number"
value={timerCount}
onChange={(e) => {
setTimerCount(e.target.value);
}}
/>
<button
onClick={() => {
if (timerID != null) {
clearInterval(timerID);
setTimerID(null);
return;
}
setTimerID(
setTimeout(() => {
props.setPlayingFile({});
setTimerID(null);
}, timerCount * 1000 * 60)
);
}}
>
Stop Timer
</button>
</span>
<span> <span>
<input <input
checked={loop} checked={loop}