Replies: 1 comment
-
|
Thanks for bringing this up! In our app we round to an |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
The
AudioPlayer.seek()method fails on iOS when passing floating-point values to thetimeInSecondsparameter, even though the TypeScript interface acceptsnumbertype.Steps to Reproduce
import { AudioPlayer } from '@mediagrid/capacitor-native-audio';)await AudioPlayer.seek({ audioId: 'my-audio', timeInSeconds: 187.909 })188works fineExpected
Seeking to a fractional second should work (or be rounded consistently) since the TS type is
number.Actual
Float values fail on iOS; integers succeed.
Suspected Root Cause
In
ios/Sources/AudioPlayerPlugin/AudioPlayerPlugin.swift,timeInSecondsis read withcall.getInt("timeInSeconds"), which returnsnilfor non-integers — causing the generic error path instead of a specific invalid-time error.Suggested Fix (Option A - accept fractional seconds)
Read as
Doubleand convert:Alternative (Option B - integers only)
If only integers are intended, update the docs and the TS type/JS wrapper to enforce integers. I'm happy to submit a docs/types PR if this is the desired API.
Workaround
Round before calling:
Environment
@mediagrid/capacitor-native-audio2.3.0Logs
Willing to open a PR?
Yes. I can submit a PR for Option A (accept Double) and add a brief note to the README/API section clarifying rounding behaviour. Please advise whether you prefer rounding vs truncation for fractional seconds.
Beta Was this translation helpful? Give feedback.
All reactions