refactor: replace MINIPLAYER_UPDATE_INTERVAL with UPDATE_INTERVAL and adjust duration rounding (#722)

* refactor: replace MINIPLAYER_UPDATE_INTERVAL with UPDATE_INTERVAL and adjust duration rounding

* removing miniplayer update interval config value

makes the miniplayer track progress match the player track progress

---------

Co-authored-by: Violet Caulfield <42452695+anultravioletaurora@users.noreply.github.com>
This commit is contained in:
skalthoff
2025-11-25 04:09:50 -08:00
committed by GitHub
parent a3c3b5e9c2
commit e6f68552b1
2 changed files with 5 additions and 15 deletions

View File

@@ -6,7 +6,7 @@ import TextTicker from 'react-native-text-ticker'
import PlayPauseButton from './components/buttons'
import { TextTickerConfig } from './component.config'
import { RunTimeSeconds } from '../Global/helpers/time-codes'
import { MINIPLAYER_UPDATE_INTERVAL } from '../../player/config'
import { UPDATE_INTERVAL } from '../../player/config'
import { Progress as TrackPlayerProgress } from 'react-native-track-player'
import { useProgress } from '../../providers/Player/hooks/queries'
@@ -171,7 +171,7 @@ function MiniPlayerRuntime({ duration }: { duration: number }): React.JSX.Elemen
<YStack justifyContent='center' marginLeft={'$2'}>
<RunTimeSeconds color={'$neutral'} alignment='right'>
{Math.max(0, Math.floor(duration))}
{Math.max(0, Math.round(duration))}
</RunTimeSeconds>
</YStack>
</XStack>
@@ -180,13 +180,13 @@ function MiniPlayerRuntime({ duration }: { duration: number }): React.JSX.Elemen
}
function MiniPlayerRuntimePosition(): React.JSX.Element {
const { position } = useProgress(MINIPLAYER_UPDATE_INTERVAL)
const { position } = useProgress(UPDATE_INTERVAL)
return <RunTimeSeconds alignment='left'>{Math.max(0, Math.floor(position))}</RunTimeSeconds>
return <RunTimeSeconds alignment='left'>{Math.max(0, Math.round(position))}</RunTimeSeconds>
}
function MiniPlayerProgress(): React.JSX.Element {
const progress = useProgress(MINIPLAYER_UPDATE_INTERVAL)
const progress = useProgress(UPDATE_INTERVAL)
return (
<Progress

View File

@@ -5,16 +5,6 @@
*/
export const UPDATE_INTERVAL: number = 250
/**
* Interval in milliseconds for the miniplayer progress updates from the track player
*
* Lower value provides smoother progress movement, but because of the math involved to
* determine playback progress, updates are only visible every full second.
*
* This is therefore set to 1000ms
*/
export const MINIPLAYER_UPDATE_INTERVAL: number = 1000
/**
* Indicates the seconds the progress position must be
* less than in order to do a skip to the previous