diff --git a/README.md b/README.md index 73b6cfe..2303e9a 100644 --- a/README.md +++ b/README.md @@ -7,4 +7,9 @@ A desktop app that lets you easily create Minecraft `/playsound` commands # Supported ### 大感謝   Thank you so so so so so much -### [@ChenCMD](https://github.com/ChenCMD) \ No newline at end of file +### [@ChenCMD](https://github.com/ChenCMD) + + +# Feedback + +[Create Issue](https://github.com/nea-c/Knead/issues/new) \ No newline at end of file diff --git a/image.png b/image.png index 61282d4..7aa704c 100644 Binary files a/image.png and b/image.png differ diff --git a/src/web/hooks/useAudioPlay.ts b/src/hooks/useAudioPlay.ts similarity index 96% rename from src/web/hooks/useAudioPlay.ts rename to src/hooks/useAudioPlay.ts index 4d8cd39..61daf35 100644 --- a/src/web/hooks/useAudioPlay.ts +++ b/src/hooks/useAudioPlay.ts @@ -1,5 +1,5 @@ import { useCallback, useState, useMemo, useEffect } from 'react' -import { mapEntries } from '../../utils/ObjectUtil' +import { mapEntries } from '../utils/ObjectUtil' type GlobalContext = { isSomePlaying: boolean @@ -98,8 +98,8 @@ export const useAudioPlay = (): { context: GlobalContext, contexts: { head?: Pub absn.connect(audioContext.destination) const gainController = audioContext.createGain() - gainController.gain.value = volume gainController.connect(audioContext.destination) + gainController.gain.value = volume return [absn, gainController] }, [audioContext]) @@ -221,11 +221,10 @@ export const useAudioPlay = (): { context: GlobalContext, contexts: { head?: Pub const setPlaybackTime = useCallback((soundKey: string, playbackTime: number) => { setAudioState((prev) => { if (prev[soundKey].isPlaying) { - // いろいろ試したけどこの書き方が一番思ってる挙動する 謎 + // いろいろ試したけどこれが一番思ってる挙動する 謎 const playTime = prev[soundKey].absn.context.currentTime - (playbackTime / (prev[soundKey].speed < 1 ? prev[soundKey].speed : 1)) pause() - // どうやったら少しだけ待ってくれるん?これ - setTimeout(() => {}, 100) + // ここで少しだけ待ってもらうような処理書いたほうがバグ発生抑えれる? でも待つ処理がわからん play() return { ...prev, [soundKey]: { ...prev[soundKey], playTime, pauseTime: 0, playbackTime } } } diff --git a/src/web/hooks/useVirtualScroll.ts b/src/hooks/useVirtualScroll.ts similarity index 100% rename from src/web/hooks/useVirtualScroll.ts rename to src/hooks/useVirtualScroll.ts diff --git a/src/web/hooks/useWindowSize.ts b/src/hooks/useWindowSize.ts similarity index 100% rename from src/web/hooks/useWindowSize.ts rename to src/hooks/useWindowSize.ts diff --git a/src/web/Footer.tsx b/src/web/Footer.tsx index ed7531c..c4e522d 100644 --- a/src/web/Footer.tsx +++ b/src/web/Footer.tsx @@ -6,7 +6,7 @@ import { useAddDispatch, useAppSelector } from '../store/_store' import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { SoundName, updateSelectedSound } from '../store/fetchSlice' import { isAboveVersion, VersionInfoType } from '../types/VersionInfo' -import { useAudioPlay } from './hooks/useAudioPlay' +import { useAudioPlay } from '../hooks/useAudioPlay' import { useTranslation } from 'react-i18next' import { PitchInput } from './PitchInput' import { secondsToString } from '../utils/NumberUtil' @@ -182,7 +182,7 @@ export const Footer = () => { else if (target_pitch > 2) target_pitch = 2 try { const hash = await myAPI.get_mcSoundHash(sound?.hash ?? '') - await AudioController.commands.setSound(selectedSound, hash, target_pitch, appVolume) + await AudioController.commands.setSound(selectedSound, hash, target_pitch, appVolume - 1) AudioController.commands.play() } catch (e: unknown) { @@ -193,6 +193,11 @@ export const Footer = () => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [soundSelectDetector]) + useEffect(() => { + if (selectedSound) AudioController.commands.setVolume(selectedSound, appVolume - 100) + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [appVolume]) + return ( <>