fix: seeking backwards no longer jumps to frame 0
Fixed critical bug where seeking backwards during playback would jump to position 0 instead of the desired position. Root cause: - When stop() was called on a playing source node, it triggered the onended event callback - The onended callback would set pauseTime = 0 (thinking playback naturally ended) - This interfered with the seek operation which was trying to set a new position Solution: - Clear sourceNode.onended callback BEFORE calling stop() - This prevents the ended event from firing when we manually stop - Seeking now works correctly in all directions The fix ensures clean state transitions during seeking operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -86,6 +86,8 @@ export class AudioPlayer {
|
||||
stop(): void {
|
||||
if (this.sourceNode) {
|
||||
try {
|
||||
// Clear onended callback first to prevent interference
|
||||
this.sourceNode.onended = null;
|
||||
this.sourceNode.stop();
|
||||
} catch (error) {
|
||||
// Ignore errors if already stopped
|
||||
|
||||
Reference in New Issue
Block a user