Problem
Long-running audio conversions (especially on older/slower devices) provide no feedback to the caller. Users have no way of knowing whether the conversion is 10% or 90% complete, leading to a poor user experience.
Proposed Solution
Add an optional progress callback that reports decoding progress as a percentage (0.0 to 1.0):
Dart API
await AudioDecoder.convertToWav(
inputPath,
outputPath,
onProgress: (double progress) {
print('${(progress * 100).toStringAsFixed(0)}%');
},
);
Implementation Approach
- Use
MediaExtractor.getSampleTime() relative to the total duration (from MediaFormat.KEY_DURATION) to calculate progress
- Report progress via an
EventChannel or periodic method channel callbacks
- Throttle updates to avoid excessive cross-platform communication (e.g., report every 1-5%)
Expected Impact
- Better UX — users see that the conversion is progressing
- Low implementation effort — duration and current position are already available from the Android media APIs
Affected Files
lib/audio_decoder.dart (add onProgress parameter)
lib/audio_decoder_platform_interface.dart (platform interface update)
lib/audio_decoder_method_channel.dart (EventChannel or callback handling)
android/src/main/kotlin/nl/silversoft/audio_decoder/AudioDecoderPlugin.kt (progress reporting)
ios/Classes/AudioDecoderPlugin.swift (progress reporting)
Problem
Long-running audio conversions (especially on older/slower devices) provide no feedback to the caller. Users have no way of knowing whether the conversion is 10% or 90% complete, leading to a poor user experience.
Proposed Solution
Add an optional progress callback that reports decoding progress as a percentage (0.0 to 1.0):
Dart API
Implementation Approach
MediaExtractor.getSampleTime()relative to the total duration (fromMediaFormat.KEY_DURATION) to calculate progressEventChannelor periodic method channel callbacksExpected Impact
Affected Files
lib/audio_decoder.dart(add onProgress parameter)lib/audio_decoder_platform_interface.dart(platform interface update)lib/audio_decoder_method_channel.dart(EventChannel or callback handling)android/src/main/kotlin/nl/silversoft/audio_decoder/AudioDecoderPlugin.kt(progress reporting)ios/Classes/AudioDecoderPlugin.swift(progress reporting)