mirror of
https://github.com/Jellify-Music/App.git
synced 2026-01-05 10:30:38 -06:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user