Allow seekTo to go to millisecond rather than floored second#321
Open
mattbajorek wants to merge 1 commit intoSimformSolutionsPvtLtd:mainfrom
Open
Allow seekTo to go to millisecond rather than floored second#321mattbajorek wants to merge 1 commit intoSimformSolutionsPvtLtd:mainfrom
mattbajorek wants to merge 1 commit intoSimformSolutionsPvtLtd:mainfrom
Conversation
|
You are my life saver!! |
b3b41c5 to
c66e5a7
Compare
Contributor
Author
|
@ujas-m-simformsolutions could you rereview this one? I updated the merge conflict. |
There was a problem hiding this comment.
Pull Request Overview
Fixes iOS audio player seeking precision by preserving millisecond accuracy when converting seek time from milliseconds to seconds.
- Changes integer division order to prevent precision loss from integer truncation
- Converts millisecond timestamp to TimeInterval for more accurate seeking
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| func seekTo(_ time: Int?, _ result: @escaping FlutterResult) { | ||
| if(time != nil) { | ||
| player?.currentTime = Double(time! / 1000) | ||
| player?.currentTime = TimeInterval(time! / 1000) |
There was a problem hiding this comment.
The integer division time! / 1000 still occurs before the TimeInterval conversion, which means millisecond precision is still lost due to integer truncation. Convert to TimeInterval first, then divide: player?.currentTime = TimeInterval(time!) / 1000.0
Suggested change
| player?.currentTime = TimeInterval(time! / 1000) | |
| player?.currentTime = TimeInterval(time!) / 1000.0 |
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.
Issue
Currently when seeking on iOS the seek time will go to the closest second. This is because the int is first divided by 1000 which floors it and then it is converted to a double.
Fix
First convert int then divide it by 1000 to convert it into seconds.