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...
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);
}
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):
[38;5;244mI/flutter ( 5773): #2 MethodChannelFlutterSoundPlayer.invokeMethod[39;49m
I/flutter ( 5773):
[38;5;244mI/flutter ( 5773): #3 FlutterSoundPlayer._startPlayer[39;49m
I/flutter ( 5773):
[38;5;244mI/flutter ( 5773): #4 FlutterSoundPlayer.startPlayer.
I/flutter ( 5773):
[38;5;244mI/flutter ( 5773): #5 BasicLock.synchronized[39;49m
I/flutter ( 5773):
[38;5;244mI/flutter ( 5773): #6 FlutterSoundPlayer.startPlayer[39;49m
I/flutter ( 5773):
[38;5;248mI/flutter ( 5773): #7 AudioPlayerBloc.openPlayback[39;49m
I/flutter ( 5773):
mode: SessionMode.modeSpokenAudio, withUI: true,
...
await player.startPlayer(
Normally, you should call "startPlayerFromTrack()" when withUI is true.
Try to change to withUI: false, : the code is simpler without UI.
Also I suggest that you provide the codec parameter.
Of course you must be sure that your parameter fromURI: is correct.
mode: SessionMode.modeSpokenAudio, withUI: true,...
await player.startPlayer(Normally, you should call "startPlayerFromTrack()" when withUI is true.
Try to change towithUI: false,: the code is simpler without UI.Also I suggest that you provide the
codecparameter.
Of course you must be sure that your parameterfromURI:is correct.
All of this time, and setting withUI: false seems to have fixed it. WTF. Maybe there is still a bug here to be fixed internally in Tau, but my app seems to be working!
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)
@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
@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
Awesome! Thank you for doing that. Hopefully others can contribute more now :)