question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG]: Unable to play audio file on Android

See original GitHub issue

Flutter Sound Version :

  • FULL or LITE flavor ?

  • Important: Result of the command : flutter pub deps | grep flutter_sound flutter pub deps | grep flutter_sound |-- flutter_sound_lite 8.1.4 | |-- flutter_sound_platform_interface 8.1.4 | |-- flutter_sound_web 8.1.4 | | |-- flutter_sound_platform_interface…


Severity

  • Result is not what expected

Platforms you faced the error

  • Android 10 on a OnePlus 6 physical device

Describe the bug When attempting to play audio, the library throws an error and does not start playback. The same code works on iOS.

To Reproduce

try {
      await player.openAudioSession(
        focus: AudioFocus.requestFocusAndStopOthers,
        category: SessionCategory.playback,
        mode: SessionMode.modeSpokenAudio,
        withUI: true,
      );
      await player.setSubscriptionDuration(Duration(milliseconds: 50));
      streamSubscription = player.onProgress.listen((event) {
        playbackStream.add(event);
      });
      await player.startPlayer(
          fromURI: audioFilePath,
          whenFinished: () async {
            await stopPlayback();
            print("audio playback done");
          });
      status = PlayerStatus.playing;
      _statusStream.add(status);
    } catch (err, trace) {
      print(err);
      print(trace);
    }

Logs

I/flutter ( 5773): FS:—> openAudioSession D/MediaBrowserCompat( 5773): Connecting to a MediaBrowserService. I/AudioManager( 5773): In stopBluetoothSco(), calling application: com.example.voice_app I/AudioManager( 5773): In setBluetoothScoOn(), on: false, calling application: com.example.voice_app I/AudioManager( 5773): In setSpeakerphoneOn(), on: true, calling application: com.example.voice_app I/AudioManager( 5773): In setSpeakerphoneOn(), on: true, calling application: com.example.voice_app I/AudioManager( 5773): In setBluetoothScoOn(), on: false, calling application: com.example.voice_app I/AudioManager( 5773): In stopBluetoothSco(), calling application: com.example.voice_app I/AudioManager( 5773): In setMode(), mode: 0, calling application: com.example.voice_app I/flutter ( 5773): FS:<— openAudioSession I/flutter ( 5773): FS:—> channelMethodCallHandler : openPlayerCompleted I/flutter ( 5773): —> openPlayerCompleted: true I/flutter ( 5773): <— openPlayerCompleted: true I/flutter ( 5773): FS:<— channelMethodCallHandler : openPlayerCompleted I/flutter ( 5773): FS:—> setSubscriptionDuration I/flutter ( 5773): FS:<---- setSubscriptionDuration I/flutter ( 5773): FS:—> startPlayer I/flutter ( 5773): FS:—> stop E/MediaPlayerNative( 5773): stop called in state 0, mPlayer(0x0) I/flutter ( 5773): FS:—> channelMethodCallHandler : stopPlayerCompleted I/flutter ( 5773): —> stopPlayerCompleted: true I/flutter ( 5773): <— stopPlayerCompleted: true I/flutter ( 5773): FS:<— channelMethodCallHandler : stopPlayerCompleted V/MediaPlayer( 5773): resetDrmState: mDrmInfo=null mDrmProvisioningThread=null mPrepareDrmInProgress=false mActiveDrmScheme=false V/MediaPlayer( 5773): cleanDrmObj: mDrmObj=null mDrmSessionId=null I/flutter ( 5773): FS:<— stop I/flutter ( 5773): FS:—> _convert I/flutter ( 5773): FS:—> needToConvert I/flutter ( 5773): FS:<— needToConvert I/flutter ( 5773): FS:<— _convert E/FlutterSoundPlugin( 5773): startPlayer() exception I/flutter ( 5773): FS:—> channelMethodCallHandler : updatePlaybackState I/flutter ( 5773): FS:<— channelMethodCallHandler : updatePlaybackState I/flutter ( 5773): PlatformException(ERR_UNKNOWN, ERR_UNKNOWN, Attempt to invoke virtual method ‘int java.lang.Integer.intValue()’ on a null object reference, null) I/flutter ( 5773): #0 StandardMethodCodec.decodeEnvelope I/flutter ( 5773): #1 MethodChannel._invokeMethod I/flutter ( 5773): <asynchronous suspension> I/flutter ( 5773): #2 MethodChannelFlutterSoundPlayer.invokeMethod I/flutter ( 5773): <asynchronous suspension> I/flutter ( 5773): #3 FlutterSoundPlayer._startPlayer I/flutter ( 5773): <asynchronous suspension> I/flutter ( 5773): #4 FlutterSoundPlayer.startPlayer.<anonymous closure> I/flutter ( 5773): <asynchronous suspension> I/flutter ( 5773): #5 BasicLock.synchronized I/flutter ( 5773): <asynchronous suspension> I/flutter ( 5773): #6 FlutterSoundPlayer.startPlayer I/flutter ( 5773): <asynchronous suspension> I/flutter ( 5773): #7 AudioPlayerBloc.openPlayback I/flutter ( 5773): <asynchr


Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
Larpouxcommented, Jun 14, 2021

@mhstoller ,

How are you doing my friend ? I added a few lines in the documentation for people trying to run flutter_sound inside a debugger : Here

1reaction
Larpouxcommented, Jun 11, 2021

Yeah!!!

I think :

  • Either Flutter Sound should be clear when not using “startPlayerFromTrack()” and withUI=true
  • Or accept correctely “startPlayer()” like it is done on iOS

The fix is simple. But actually I do not work anymore on Tau. Someone can do a Pull Request ? (I always consider PR, because I want other developers on this project)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Audio (not) playing in Android app - Uptech
SoundPool. An Android class I discovered when working on this problem. A very peculiar thing really, it can be used for small audio...
Read more >
10 Methods: How to Solve Audio File Not Playing
Part 2: Troubleshooting Audio File Not Playing Issue · Method 1: Install Audio Codecs · Method 2: Choose Correct Audio Speaker · Method...
Read more >
Unable to play audio file? - Android Central Forums
Try to play the songs using Ringtone Maker (press the left end of the line for the song to play it.) If that...
Read more >
Error playing Audio! #7748 - signalapp/Signal-Android - GitHub
Was able to reproduce this bug and narrowed down a bit what might be causing the issue. Audio files (MP3) with length of...
Read more >
Cannot Play Audio Consistently in Some Android Browsers
Once, I used Android's Manage Applications tool to delete Browser's data and cache. This also caused the Browser process to stop. This one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found