Conversation
Add a `loop` property to the Player class. When set to true, playback automatically restarts from the beginning when the end of the file is reached, instead of stopping. The `endOfFile` event is still emitted on each loop iteration. Also marks the internal `playLoop()` method as `@private` in JSDoc to clarify it is not a public API for looping songs. Closes #105 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Hoist endOfFile() check above the tracks forEach so it runs once instead of once per track. This fixes endOfFile firing N times (once per track) and the loop restart logic running repeatedly. - Reset scheduledTime when looping to prevent drift-correction from clamping delays to 0 after a restart. - Use Date.now() consistently instead of mixing with (new Date()).getTime(). - Add three automated tests for the loop feature: restart on loop, single endOfFile per iteration, and stop when loop is false. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Change assert from <= 1 (allows zero) to strict equality with 1, since sinon fake timers make timing deterministic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
loopproperty to the Player class — whentrue, playback restarts automatically at end-of-file instead of stoppingplayLoop()method as@privatein JSDoc to clarify it is not a public looping APIendOfFileevent is still emitted on each loop iteration so consumers can reactUsage
Closes #105
Test plan
loop = false(default) — should stop at endloop = true— should restart seamlessly at endendOfFileevent fires on each loop iteration🤖 Generated with Claude Code