audio_waveforms
audio_waveforms copied to clipboard
fix bug: android call preparePlayer 2nd never callback
Future<void> preparePlayer(String path, [double? volume]) async {
path = Uri.parse(path).path;
await _readAudioFile(path);
if ((_playerState == PlayerState.readingComplete &&
_audioFilePath != null)) {
final isPrepared = await AudioWaveformsInterface.instance
.preparePlayer(path, _playerKey.toString(), volume); <<<<<<<< block here
if (isPrepared) {
_maxDuration = await getDuration();
setPlayerState(PlayerState.initialized);
}
notifyListeners();
} else {
throw "Can not prepare player without reading audio file";
}
}
@leconio Can you please share the issue you were having? And you can use the same player for another audio you need to just call stop
before calling preparePlayer
for another audio
Thanks, I run the example, I found the WaveBubble not update after recode a voice, It's a blank Bubble. The isRecoding
state not update. The reason is preparePlayer not callback.
Then I found the android api preparePlayer just only call once time because of a flag isPlayerPrepared
. And the ios api is work very well.
@leconio isPlayerPrepared
's default value is already false and for updating UI based on the PlayerState I would recommend using the onPlayerStateChanged
stream instead of using a listener or just playerState.
closing this PR due to inactivity.