[BUG]: Unable to play audio file on Android
See original GitHub issueFlutter 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) [38;5;244mI/flutter ( 5773): #0 StandardMethodCodec.decodeEnvelope[39;49m [38;5;244mI/flutter ( 5773): #1 MethodChannel._invokeMethod[39;49m I/flutter ( 5773): <asynchronous suspension> [38;5;244mI/flutter ( 5773): #2 MethodChannelFlutterSoundPlayer.invokeMethod[39;49m I/flutter ( 5773): <asynchronous suspension> [38;5;244mI/flutter ( 5773): #3 FlutterSoundPlayer._startPlayer[39;49m I/flutter ( 5773): <asynchronous suspension> [38;5;244mI/flutter ( 5773): #4 FlutterSoundPlayer.startPlayer.<anonymous closure>[39;49m I/flutter ( 5773): <asynchronous suspension> [38;5;244mI/flutter ( 5773): #5 BasicLock.synchronized[39;49m I/flutter ( 5773): <asynchronous suspension> [38;5;244mI/flutter ( 5773): #6 FlutterSoundPlayer.startPlayer[39;49m I/flutter ( 5773): <asynchronous suspension> [38;5;248mI/flutter ( 5773): #7 AudioPlayerBloc.openPlayback[39;49m I/flutter ( 5773): <asynchr
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top GitHub Comments
@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
Yeah!!!
I think :
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)