fix: playhead not moving in SECTION-TAB with empty tracks

Two fixes:
1. handlePlayPause: add explicit requestAnimationFrame(updatePlayhead)
   after setIsPlaying(true) to ensure RAF starts immediately.
2. handleEditSectionInTab: add setCurrentTime(0) to reset playhead
   to section start. Without this, currentTime may be outside
   the section's timeline range (e.g. from main session playback).
This commit is contained in:
2026-07-28 09:20:31 +07:00
parent 2f2f84066c
commit 5d31563df6
3 changed files with 10 additions and 2 deletions
+2
View File
@@ -8525,6 +8525,7 @@ const App = () => {
})); }));
setSessionTabs(prev => [...prev, { id: tabId, name: tabName, sectionId: sectionId, tracks: clonedTracks, color: section.color || null }]); setSessionTabs(prev => [...prev, { id: tabId, name: tabName, sectionId: sectionId, tracks: clonedTracks, color: section.color || null }]);
setActiveTab(tabId); setActiveTab(tabId);
setCurrentTime(0);
}; };
// Sub Tab: apply effects & merge back (LOOP_EDITOR_2.md §1.2) // Sub Tab: apply effects & merge back (LOOP_EDITOR_2.md §1.2)
@@ -10614,6 +10615,7 @@ const App = () => {
startAudioTimeRef.current = context.currentTime; startAudioTimeRef.current = context.currentTime;
startTrackPlayback(currentTime); startTrackPlayback(currentTime);
setIsPlaying(true); setIsPlaying(true);
animationFrameIdRef.current = requestAnimationFrame(updatePlayhead);
} }
}; };
handlePlayPauseRef.current = handlePlayPause; handlePlayPauseRef.current = handlePlayPause;
File diff suppressed because one or more lines are too long
+6
View File
@@ -539,6 +539,12 @@
- **Ghi chú/Test (nếu có):** `npm run build` pass. Ctrl+Click+Drag section/MIDI item → copy đến vị trí mới, item không bị selected. - **Ghi chú/Test (nếu có):** `npm run build` pass. Ctrl+Click+Drag section/MIDI item → copy đến vị trí mới, item không bị selected.
--- ---
### [2026-07-28 09:17] Task: Playhead SECTION-TAB di chuyển dù không có items
- **Tóm tắt thay đổi:** Thêm `requestAnimationFrame(updatePlayhead)` sau `setIsPlaying(true)` trong `handlePlayPause` để đảm bảo RAF luôn chạy. Thêm `setCurrentTime(0)` trong `handleEditSectionInTab` để reset playhead về 0 khi mở section tab. Trước đây playhead không di chuyển vì effect useEffect dependency chưa kịp fire hoặc `currentTime` ở vị trí ngoài section timeline.
- **Các file ảnh hưởng:** `app/static/js/app.jsx`, `app/static/js/app.precompiled.js`
- **Ghi chú/Test (nếu có):** `npm run build` pass. Mở SECTION-TAB → Play → playhead di chuyển từ 0 đến maxDuration.
---
### [2026-07-28 09:40] Task: Cả main + section MIDI playback không default program 0 ### [2026-07-28 09:40] Task: Cả main + section MIDI playback không default program 0
- **Tóm tắt thay đổi:** Thay đổi line 10283 giống line 10393: `instrumentProgram !== undefined ? ... : 0``instrumentProgram`. Trước đây main playback cũng default program 0 khi `instrumentProgram` undefined → `_playNoteFluid` gọi `program_change(ch,0)` trên FluidSynth → load program 0 của MAIN SoundFont. Fix: undefined → oscillator fallback. - **Tóm tắt thay đổi:** Thay đổi line 10283 giống line 10393: `instrumentProgram !== undefined ? ... : 0``instrumentProgram`. Trước đây main playback cũng default program 0 khi `instrumentProgram` undefined → `_playNoteFluid` gọi `program_change(ch,0)` trên FluidSynth → load program 0 của MAIN SoundFont. Fix: undefined → oscillator fallback.
- **Các file ảnh hưởng:** `app/static/js/app.jsx`, `app/static/js/app.precompiled.js` - **Các file ảnh hưởng:** `app/static/js/app.jsx`, `app/static/js/app.precompiled.js`