Skip to content

Conversation

@mattbajorek
Copy link
Contributor

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.

@Yang321423
Copy link

You are my life saver!!

@mattbajorek mattbajorek force-pushed the mattbajorek/fix-ios-seekTo branch from b3b41c5 to c66e5a7 Compare February 6, 2025 14:32
@mattbajorek
Copy link
Contributor Author

@ujas-m-simformsolutions could you rereview this one? I updated the merge conflict.

@aditya-css aditya-css requested a review from Copilot October 11, 2025 11:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattbajorek Please see this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants