From 91616c24ae0494f03ddb958108a2115d34972a5e Mon Sep 17 00:00:00 2001 From: jinhojang6 Date: Tue, 29 Aug 2023 02:06:03 +0900 Subject: [PATCH] fix: support autoplay --- src/components/Episode/Header/Episode.Player.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/Episode/Header/Episode.Player.tsx b/src/components/Episode/Header/Episode.Player.tsx index b7823bb..019dc72 100644 --- a/src/components/Episode/Header/Episode.Player.tsx +++ b/src/components/Episode/Header/Episode.Player.tsx @@ -30,6 +30,7 @@ const EpisodePlayer = ({ const playerRef = useRef(null) const [volume, setVolume] = useState(state.value.volume) + const isSimplecast = channel?.name === LPE.Podcast.ChannelNames.Simplecast const url = @@ -110,7 +111,7 @@ const EpisodePlayer = ({ useEffect(() => { if (!state.value.isEnabled) { - const offset = 1 / state.value.duration // 1 second in % + const offset = state.value.played === 0 ? 0 : 1 / state.value.duration // 1 second in % playerRef.current?.seekTo(state.value.played + offset) } }, [state.value.isEnabled]) @@ -127,8 +128,8 @@ const EpisodePlayer = ({ const newVolume = data.info?.volume / 100 || state.value.volume if (isMuted) { - if (muteChanged) { - state.set((prev) => ({ ...prev, muted: true, volume: newVolume })) + if (muteChanged && !state.value.muted) { + // TODO : handle mute } } else if (!isMuted) { if (muteChanged) { @@ -138,7 +139,6 @@ const EpisodePlayer = ({ volume: newVolume, })) } - setVolume(newVolume) } }