mirror of
https://github.com/austinried/subtracks.git
synced 2026-02-10 06:52:43 +01:00
impl repeat mode
fix position not being restored on close/open due to some bad progress updates
This commit is contained in:
@@ -1,15 +1,23 @@
|
||||
import { useStore } from '@app/state/store'
|
||||
import { selectTrackPlayer } from '@app/state/trackplayer'
|
||||
import React, { useEffect } from 'react'
|
||||
import { useProgress } from 'react-native-track-player'
|
||||
import { State, useProgress } from 'react-native-track-player'
|
||||
|
||||
const ProgressHook = () => {
|
||||
const playerState = useStore(selectTrackPlayer.playerState)
|
||||
const setProgress = useStore(selectTrackPlayer.setProgress)
|
||||
const progress = useProgress(250)
|
||||
|
||||
useEffect(() => {
|
||||
if (playerState !== State.Playing) {
|
||||
return
|
||||
}
|
||||
if (progress.buffered === 0 && progress.duration === 0 && progress.position === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
setProgress(progress)
|
||||
}, [setProgress, progress])
|
||||
}, [setProgress, progress, playerState])
|
||||
|
||||
return <></>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user