audio_waveforms icon indicating copy to clipboard operation
audio_waveforms copied to clipboard

Error while preparePlayer on ios 15.5 (using ios simulator not a real device)

Open khaled-muhammad opened this issue 2 years ago • 6 comments

audio_waveforms/AudioPlayer.swift:23: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSOSStatusErrorDomain Code=1685348671 "(null)" Lost connection to device.

khaled-muhammad avatar Jun 27 '22 16:06 khaled-muhammad

Hello @khaled-muhammad We have tried to replicate the same issue with ios 15.5, and we cannot reproduce the same. Please recheck the same with our latest release and let us know if you still face the same?

DhavalRKansara avatar Jul 28 '22 08:07 DhavalRKansara

version 0.1.3 on real device Device: iPhoneX iOS: 14.4.2

Problem scanning for packets
 MPEGAudioFile::OpenFromDataSource failed
 OpenFromDataSource failed
 Open failed
Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSOSStatusErrorDomain Code=1685348671 "(null)": file audio_waveforms/AudioPlayer.swift, line 22
* thread #1, queue = 'com.apple.main-thread', stop reason = Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSOSStatusErrorDomain Code=1685348671 "(null)"
    frame #0: 0x00000001997e9ff8 libswiftCore.dylib`_swift_runtime_on_report
libswiftCore.dylib`_swift_runtime_on_report:
->  0x1997e9ff8 <+0>: ret
libswiftCore.dylib`_swift_reportToDebugger:
    0x1997e9ffc <+0>: b      0x1997e9ff8               ; _swift_runtime_on_report
libswiftCore.dylib`_swift_shouldReportFatalErrorsToDebugger:
    0x1997ea000 <+0>: adrp   x8, 352372
    0x1997ea004 <+4>: ldrb   w0, [x8, #0x998]
Target 0: (Runner) stopped.
Lost connection to device.

Please help to fix this issue, thx. :)

JeChingLin avatar Jul 29 '22 18:07 JeChingLin

version 0.1.3 on real device Device: iPhoneX iOS: 14.4.2

Problem scanning for packets
 MPEGAudioFile::OpenFromDataSource failed
 OpenFromDataSource failed
 Open failed
Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSOSStatusErrorDomain Code=1685348671 "(null)": file audio_waveforms/AudioPlayer.swift, line 22
* thread #1, queue = 'com.apple.main-thread', stop reason = Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSOSStatusErrorDomain Code=1685348671 "(null)"
    frame #0: 0x00000001997e9ff8 libswiftCore.dylib`_swift_runtime_on_report
libswiftCore.dylib`_swift_runtime_on_report:
->  0x1997e9ff8 <+0>: ret
libswiftCore.dylib`_swift_reportToDebugger:
    0x1997e9ffc <+0>: b      0x1997e9ff8               ; _swift_runtime_on_report
libswiftCore.dylib`_swift_shouldReportFatalErrorsToDebugger:
    0x1997ea000 <+0>: adrp   x8, 352372
    0x1997ea004 <+4>: ldrb   w0, [x8, #0x998]
Target 0: (Runner) stopped.
Lost connection to device.

Please help to fix this issue, thx. :)

Problem solved.

Use 'test.m4a' instead of

File file = File('test.mp3');

JeChingLin avatar Jul 31 '22 12:07 JeChingLin

@JeChingLin Can you please provide sample code for how you were trying to play the audio?

Ujas-Majithiya avatar Jul 31 '22 17:07 Ujas-Majithiya

I have the same issue. It happens only when I record from Android and play the record on IOS.

@JeChingLin Any help please?

awnigharbia avatar Aug 16 '22 09:08 awnigharbia

I have the same issue. It happens only when I record from Android and play the record on IOS.

@JeChingLin Any help please?

this is work for me.

Recorder

 bool _isRecording = false;
 late final RecorderController recorderController = RecorderController();

 Future<void> _startRecord() async {
    try {
      if (await recorderController.checkPermission()) {
        if (Platform.isAndroid) {
          await recorderController.record();
        } else {
          appDirectory = await getTemporaryDirectory();
          final file = File('${appDirectory.path}/record.m4a');
          await recorderController.record(file.path);
        }

        setState(() {
          _isRecording = recorderController.isRecording;
        });
      }
    } catch (e) {
      if (kDebugMode) {
        print(e);
      }
    }
  }

Player

   late final PlayerController playerController;
   late Directory appDirectory;
   late PlayerState state = PlayerState.stopped;

    @override
     void initState() async {
         super.initState();
         appDirectory = await getTemporaryDirectory();
         final file = File('${appDirectory.path}/tmp.m4a');
         await file.writeAsBytes(widget.bytes);
   
         try {
             await playerController.preparePlayer(file.path);
             setState(() {
                 state = playerController.playerState;
              });
          } catch (e) {
              if (kDebugMode) {
                  print('player error: $e');
              }
          }
      }

JeChingLin avatar Aug 25 '22 18:08 JeChingLin

You shouldn't be facing the crash from 1.0.0. the native initialization of the player was force unwrapped that's why it was throwing exception sometimes. I'm going to close this issue for now but feel free to reopen or create a new issue.

ujas-m-simformsolutions avatar Dec 29 '22 06:12 ujas-m-simformsolutions