fix: support autoplay
This commit is contained in:
parent
778a54db1f
commit
91616c24ae
|
@ -30,6 +30,7 @@ const EpisodePlayer = ({
|
||||||
const playerRef = useRef<ReactPlayer>(null)
|
const playerRef = useRef<ReactPlayer>(null)
|
||||||
|
|
||||||
const [volume, setVolume] = useState(state.value.volume)
|
const [volume, setVolume] = useState(state.value.volume)
|
||||||
|
|
||||||
const isSimplecast = channel?.name === LPE.Podcast.ChannelNames.Simplecast
|
const isSimplecast = channel?.name === LPE.Podcast.ChannelNames.Simplecast
|
||||||
|
|
||||||
const url =
|
const url =
|
||||||
|
@ -110,7 +111,7 @@ const EpisodePlayer = ({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!state.value.isEnabled) {
|
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)
|
playerRef.current?.seekTo(state.value.played + offset)
|
||||||
}
|
}
|
||||||
}, [state.value.isEnabled])
|
}, [state.value.isEnabled])
|
||||||
|
@ -127,8 +128,8 @@ const EpisodePlayer = ({
|
||||||
const newVolume = data.info?.volume / 100 || state.value.volume
|
const newVolume = data.info?.volume / 100 || state.value.volume
|
||||||
|
|
||||||
if (isMuted) {
|
if (isMuted) {
|
||||||
if (muteChanged) {
|
if (muteChanged && !state.value.muted) {
|
||||||
state.set((prev) => ({ ...prev, muted: true, volume: newVolume }))
|
// TODO : handle mute
|
||||||
}
|
}
|
||||||
} else if (!isMuted) {
|
} else if (!isMuted) {
|
||||||
if (muteChanged) {
|
if (muteChanged) {
|
||||||
|
@ -138,7 +139,6 @@ const EpisodePlayer = ({
|
||||||
volume: newVolume,
|
volume: newVolume,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
setVolume(newVolume)
|
setVolume(newVolume)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue