Canardoux / flutter_sound

Flutter plugin for sound. Audio recorder and player.
Mozilla Public License 2.0
875 stars 573 forks source link

[BUG]: Unable to playback .aac files on iOS devices if they were sent from an Android phone #682

Open BreSmit521 opened 3 years ago

BreSmit521 commented 3 years ago

Flutter Sound Version :

Full |-- flutter_sound 8.1.1 | |-- flutter_sound_platform_interface 8.1.1 | |-- flutter_sound_web 8.1.1 | | |-- flutter_sound_platform_interface...


Severity


Platforms you faced the error


Describe the bug Recording a file on android using the plugin with the default codec like this:

  Future<void> startRecorder() async {
      final String _temporaryAudioFile = 'temporaryAudioRecording.aac';

        File('$_localAudioPath$_temporaryAudioFilePath').createSync();

        final audioSession = await _recorder.openAudioSession();
        audioSession?.startRecorder(toFile: _temporaryAudioFilePath);
  }

And playing it back by using:

  Future<Duration?> playRecording(File file, {VoidCallback? whenFinished}) async {
    await _player.openAudioSession();
    return await _player.startPlayer(
        fromURI: file.uri.toString(),
        whenFinished: () async {
          await stopPlayback();
          whenFinished?.call();
        });
  }

Playback works as expected if the file was recorded on iOS and played back on iOS but not if it was recorded on Android and played back on iOS. Recorded on iOS and played back on Android works as expected.

I can get around this if I specify codec: Codec.aacADTS when I record the file and all files can be played back as expected. But I have a requirement to also accept .aac files from the web which are also not working on iOS.

Logs

flutter: FS:---> _convert
flutter: FS:---> needToConvert
flutter: FS:<--- needToConvert
flutter: FS:<--- _convert
IOS:--> startPlayer
IOS:--> startPlayer
IOS:--> stopTimer
IOS:<-- stopTimer
 ReadBytes Failed
 AACAudioFile::ParseAudioFile failed
 OpenFromDataSource failed
 Open failed
IOS:<-- startPlayer
IOS:<-- startPlayer

BreSmit521 commented 3 years ago

More info: This does appear to work as expected using fromDataBuffer on 8.1.4

github-actions[bot] commented 10 months ago

This issue is stale because it has been open 90 days with no activity. Leave a comment or this will be closed in 7 days.