Home > Enterprise >  flutter_sound 8.4.2 startPlayer() exception
flutter_sound 8.4.2 startPlayer() exception

Time:12-21

 await _audioPlayer!.startPlayer(
    fromURI: 'https://URL/TestFiles/sssssssss.acc',
    codec: Codec.aacADTS,
  );
} catch (e) {
  print(e);
}

the exception is platform exceptio error unknown startplayer() error,null . in the debug console I got these FlutterSoundPlayer.log (package:flutter_sound/public/flutter_sound_player.dart:500:13

MethodChannelFlutterSoundPlayer.channelMethodCallHandler (package:flutter_sound_platform_interface/method_channel_flutter_sound_player.dart:161:19

I am using real android device flutter doctor returns everything is good this remote file works well in angular client

CodePudding user response:

to play audios i use this library audioplayers: ^0.19.1 declare this variable to access audio

 String audioCorrect = "audio/access_granted.mp3";
 String audioInCorrect = "audio/access_denied.mp3";

method for init player

void initPlayer() {
    advancedPlayer = new AudioPlayer();
    audioCache = new AudioCache(fixedPlayer: advancedPlayer);
  }

call initPlayer in initState method play the audio this way

   audioCache.play(audioCorrect);

CodePudding user response:

It's played Now I was missing that the file extension is aac not acc

so it should be

await _audioPlayer!.startPlayer(
fromURI: 'https://URL/TestFiles/sssssssss.aac',
);
} catch (e) {
print(e);
}
  • Related