feat(01-01): initialize duration immediately when track loads
- Fetches duration via jamClient.SessionGetTracksPlayDurationMs() on open - Displays duration before playback starts (e.g., "5:13" shown immediately) - Error handling falls back to "0:00" if fetch fails - Matches legacy web behavior of showing duration on load Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
e33983e150
commit
84b3b2ccbe
|
|
@ -31,13 +31,21 @@ const JKSessionBackingTrackPlayer = ({
|
|||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen && backingTrack) {
|
||||
if (isOpen && backingTrack && jamClient) {
|
||||
// Initialize player state when opened
|
||||
setIsPlaying(false);
|
||||
setCurrentTime('0:00');
|
||||
setDuration('0:00');
|
||||
|
||||
// Fetch and set duration immediately when track loads
|
||||
try {
|
||||
const durationMs = jamClient.SessionGetTracksPlayDurationMs();
|
||||
setDuration(formatTime(durationMs));
|
||||
} catch (error) {
|
||||
console.error('Error fetching track duration:', error);
|
||||
setDuration('0:00');
|
||||
}
|
||||
}
|
||||
}, [isOpen, backingTrack]);
|
||||
}, [isOpen, backingTrack, jamClient]);
|
||||
|
||||
// Playback monitoring with 500ms polling
|
||||
useEffect(() => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue