flutter_sound icon indicating copy to clipboard operation
flutter_sound copied to clipboard

ui_dart_state.cc(199)] Unhandled Exception: PlatformException(Audio Player, startPlayer failure, null, null)

Open anypwx opened this issue 3 years ago • 15 comments

Flutter Sound Version : 8.3.9

  • FULL or LITE flavor ? FULL

  • Important: Result of the command : flutter pub deps | grep flutter_sound


Severity

  • Crash ? yes

Platforms you faced the error

  • iOS ? iphone x ios 14.7.1

Describe the bug ui_dart_state.cc(199)] Unhandled Exception: PlatformException(Audio Player, startPlayer failure, null, null) #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:597:7) #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18) #2 MethodChannelFlutterSoundPlayer.invokeMethod (package:flutter_sound_platform_interface/method_channel_flutter_sound_player.dart:181:12) #3 FlutterSoundPlayer._startPlayer (package:flutter_sound/public/flutter_sound_player.dart:1146:19) #4 FlutterSoundPlayer.startPlayer. (package:flutter_sound/public/flutter_sound_player.dart:1076:11)

To Reproduce Steps to reproduce the behavior: Click on 'startPlayer'


Logs!!!!

(This is very important. Most of the time we cannot do anything if we do not have information on your bug). ui_dart_state.cc(199)] Unhandled Exception: PlatformException(Audio Player, startPlayer failure, null, null) #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:597:7) #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158:18) #2 MethodChannelFlutterSoundPlayer.invokeMethod (package:flutter_sound_platform_interface/method_channel_flutter_sound_player.dart:181:12) #3 FlutterSoundPlayer._startPlayer (package:flutter_sound/public/flutter_sound_player.dart:1146:19) #4 FlutterSoundPlayer.startPlayer. (package:flutter_sound/public/flutter_sound_player.dart:1076:11)


anypwx avatar Aug 31 '21 07:08 anypwx

same issue in android

sanba-anass avatar Sep 24 '21 15:09 sanba-anass

Check :

  • What is the file that you try to play
  • What is its extension
  • What is the codec that you specified to startPlayer()

Larpoux avatar Sep 24 '21 15:09 Larpoux

@Larpoux what should be a codec for video picked from iOS device ?

bhargav6744 avatar Dec 27 '21 18:12 bhargav6744

Check :

  • What is the file that you try to play
  • What is its extension
  • What is the codec that you specified to startPlayer()

i faced issue on real ios device only. extension: .aac codec: Codec.aacADTS file: /var/mobile/Containers/Data/Application/8E613239-E966-4244-B5AD-832263CBB5E6/Library/Caches/12323123.aac

alperenbaskaya58 avatar Apr 11 '22 15:04 alperenbaskaya58

I am not sure that /var/mobile/Containers/Data/Application/8E613239-E966-4244-B5AD-832263CBB5E6/Library/Caches/12323123.aac is in your sandbox

Larpoux avatar Apr 11 '22 16:04 Larpoux

I am not sure that /var/mobile/Containers/Data/Application/8E613239-E966-4244-B5AD-832263CBB5E6/Library/Caches/12323123.aac is in your sandbox

what to do then? Any reccomendations?

alperenbaskaya58 avatar Apr 15 '22 13:04 alperenbaskaya58

Most of the time you must call the flutter plugin 'path_provider' to get a correct path where you can store or read your files.

Larpoux avatar Apr 15 '22 13:04 Larpoux

Most of the time you must call the flutter plugin 'path_provider' to get a correct path where you can store or read your files.

tempDir = await getTemporaryDirectory();

this is the directory of the file where I uses pathprovider

alperenbaskaya58 avatar Apr 15 '22 13:04 alperenbaskaya58

That's correct.

But 'var/mobile/Containers/Data/Application/8E613239-E966-4244-B5AD-832263CBB5E6/Library/Caches/12323123.aac' seems to be a path for an ios emulator, not a correct path for a real device

Larpoux avatar Apr 15 '22 13:04 Larpoux

I am using real device and nothing work for playing. This path is from real device var/mobile/Containers/Data/Application/8E613239-E966-4244-B5AD-832263CBB5E6/Library/Caches/12323123.aac

 tempDir = await getTemporaryDirectory();
    log(tempDir!.path.toString());
    PermissionStatus status;
    try {
      status = await Permission.microphone.request();
    } catch (e) {
      throw e;
    }
    log(tempDir.path.toString());

    if (status != PermissionStatus.granted)
      throw RecordingPermissionException("You must give acces to mic");
    pathToRecord =
        "${tempDir.path}/${DateTime.now().millisecondsSinceEpoch.toString()}.aac";

    await flutterSoundRecorder.startRecorder(
      toFile: "$pathToRecord",
      codec: Codec.aacADTS,
    );
playing;
  play(path) async {
    await flutterSoundPlayer.startPlayer(
        fromURI: path,

        //fromDataBuffer: bytes,
        codec: Codec.aacADTS);
    update();
  }

alperenbaskaya58 avatar Apr 17 '22 19:04 alperenbaskaya58

Your code seems correct. I don't see. Is your player correctly open?

Larpoux avatar Apr 18 '22 10:04 Larpoux

Yes, it works on android debug, android release and ios debug. It doesnt work only release mode on iOS.

alperenbaskaya58 avatar Apr 18 '22 10:04 alperenbaskaya58

Is there any reason you use FS 8.x and not 9.2? Do you depend on another Flutter audio plugin, than Flutter Sound?

Larpoux avatar Apr 18 '22 10:04 Larpoux

i am using fs 9.1.8 to 9.2.2 not 8

alperenbaskaya58 avatar Apr 18 '22 12:04 alperenbaskaya58

i have the same, I copy your code in the example project (SimpleRecorder), and try to record, then play audio, but it has an error (android working), i don't change anything, please tell me how i can fix this error @Larpoux thank you. flutter_sound: ^9.2.13 ios: 15.4.1

minh-dai avatar Jul 27 '22 15:07 minh-dai

same issue, anyone found a solution?

JettChen12 avatar Feb 21 '23 08:02 JettChen12

Execute openPlayer first and then startPlayer, and the issue will be resolved

play() async {
    await flutterSoundPlayer.openPlayer()
    await flutterSoundPlayer.startPlayer()
}

hbalxzdl avatar Feb 24 '23 11:02 hbalxzdl

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.

github-actions[bot] avatar Dec 12 '23 01:12 github-actions[bot]