Merge pull request #3029 from pangeachat/3027-cant-play-audio-again-in-an-audio-message
chore: reset audio when playing ends
This commit is contained in:
commit
cea4888290
1 changed files with 11 additions and 1 deletions
|
|
@ -79,6 +79,7 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
|
|||
|
||||
// #Pangea
|
||||
StreamSubscription? _onAudioPositionChanged;
|
||||
StreamSubscription? _onAudioStateChanged;
|
||||
// Pangea#
|
||||
|
||||
@override
|
||||
|
|
@ -164,6 +165,7 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
|
|||
matrix.voiceMessageEventId.value = matrix.audioPlayer = null;
|
||||
// #Pangea
|
||||
_onAudioPositionChanged?.cancel();
|
||||
_onAudioStateChanged?.cancel();
|
||||
// Pangea#
|
||||
}
|
||||
}
|
||||
|
|
@ -251,7 +253,6 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
|
|||
// #Pangea
|
||||
// if (matrix.voiceMessageEventId.value != widget.event.eventId) return;
|
||||
if (matrix.voiceMessageEventId.value != widget.eventId) return;
|
||||
|
||||
matrix.audioPlayer?.dispose();
|
||||
// Pangea#
|
||||
|
||||
|
|
@ -269,6 +270,15 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
|
|||
);
|
||||
}
|
||||
});
|
||||
|
||||
_onAudioStateChanged?.cancel();
|
||||
_onAudioStateChanged =
|
||||
matrix.audioPlayer!.playerStateStream.listen((state) {
|
||||
if (state.processingState == ProcessingState.completed) {
|
||||
matrix.audioPlayer!.stop();
|
||||
matrix.audioPlayer!.seek(Duration.zero);
|
||||
}
|
||||
});
|
||||
// Pangea#
|
||||
|
||||
// #Pangea
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue