don't play token text if null message audio is playing
This commit is contained in:
parent
7a5b687ed7
commit
9e3111f97c
5 changed files with 28 additions and 7 deletions
|
|
@ -21,6 +21,7 @@ class AudioPlayerWidget extends StatefulWidget {
|
|||
final Event? event;
|
||||
final PangeaAudioFile? matrixFile;
|
||||
final bool autoplay;
|
||||
final Function(bool)? setIsPlayingAudio;
|
||||
// Pangea#
|
||||
|
||||
static String? currentId;
|
||||
|
|
@ -41,6 +42,7 @@ class AudioPlayerWidget extends StatefulWidget {
|
|||
this.autoplay = false,
|
||||
this.sectionStartMS,
|
||||
this.sectionEndMS,
|
||||
this.setIsPlayingAudio,
|
||||
// Pangea#
|
||||
super.key,
|
||||
});
|
||||
|
|
@ -204,8 +206,13 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
|
|||
if (max == null || max == Duration.zero) return;
|
||||
setState(() => maxPosition = max.inMilliseconds.toDouble());
|
||||
});
|
||||
onPlayerStateChanged ??=
|
||||
audioPlayer.playingStream.listen((_) => setState(() {}));
|
||||
onPlayerStateChanged ??= audioPlayer.playingStream.listen(
|
||||
(isPlaying) => setState(() {
|
||||
// #Pangea
|
||||
widget.setIsPlayingAudio?.call(isPlaying);
|
||||
// Pangea#
|
||||
}),
|
||||
);
|
||||
final audioFile = this.audioFile;
|
||||
if (audioFile != null) {
|
||||
audioPlayer.setFilePath(audioFile.path);
|
||||
|
|
|
|||
|
|
@ -22,12 +22,14 @@ class MessageAudioCard extends StatefulWidget {
|
|||
final MessageOverlayController overlayController;
|
||||
final PangeaTokenText? selection;
|
||||
final TtsController tts;
|
||||
final Function(bool) setIsPlayingAudio;
|
||||
|
||||
const MessageAudioCard({
|
||||
super.key,
|
||||
required this.messageEvent,
|
||||
required this.overlayController,
|
||||
required this.tts,
|
||||
required this.setIsPlayingAudio,
|
||||
this.selection,
|
||||
});
|
||||
|
||||
|
|
@ -56,7 +58,7 @@ class MessageAudioCardState extends State<MessageAudioCard> {
|
|||
|
||||
@override
|
||||
void didUpdateWidget(covariant oldWidget) {
|
||||
if (oldWidget.selection != widget.selection) {
|
||||
if (oldWidget.selection != widget.selection && widget.selection != null) {
|
||||
debugPrint('selection changed');
|
||||
setSectionStartAndEndFromSelection();
|
||||
playSelectionAudio();
|
||||
|
|
@ -65,6 +67,7 @@ class MessageAudioCardState extends State<MessageAudioCard> {
|
|||
}
|
||||
|
||||
Future<void> playSelectionAudio() async {
|
||||
if (widget.selection == null) return;
|
||||
final PangeaTokenText selection = widget.selection!;
|
||||
final tokenText = selection.content;
|
||||
|
||||
|
|
@ -203,6 +206,7 @@ class MessageAudioCardState extends State<MessageAudioCard> {
|
|||
sectionEndMS: sectionEndMS,
|
||||
color:
|
||||
Theme.of(context).colorScheme.onPrimaryContainer,
|
||||
setIsPlayingAudio: widget.setIsPlayingAudio,
|
||||
),
|
||||
widget.tts.missingVoiceButton,
|
||||
],
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
|
|||
PangeaMessageEvent get pangeaMessageEvent => widget._pangeaMessageEvent;
|
||||
|
||||
final TtsController tts = TtsController();
|
||||
bool isPlayingAudio = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
@ -200,9 +201,10 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
|
|||
PangeaToken token,
|
||||
) {
|
||||
if ([
|
||||
MessageMode.practiceActivity,
|
||||
// MessageMode.textToSpeech
|
||||
].contains(toolbarMode)) {
|
||||
MessageMode.practiceActivity,
|
||||
// MessageMode.textToSpeech
|
||||
].contains(toolbarMode) ||
|
||||
isPlayingAudio) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -273,6 +275,13 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
|
|||
double get reactionsHeight => hasReactions ? 28 : 0;
|
||||
double get belowMessageHeight => toolbarButtonsHeight + reactionsHeight;
|
||||
|
||||
void setIsPlayingAudio(bool isPlaying) {
|
||||
if (mounted) {
|
||||
setState(() => isPlayingAudio = isPlaying);
|
||||
debugPrint("IS PLAYING AUDIO: $isPlaying");
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ class MessageToolbar extends StatelessWidget {
|
|||
overlayController: overLayController,
|
||||
selection: overLayController.selectedSpan,
|
||||
tts: tts,
|
||||
setIsPlayingAudio: overLayController.setIsPlayingAudio,
|
||||
);
|
||||
case MessageMode.speechToText:
|
||||
return MessageSpeechToTextCard(
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ description: Learn a language while texting your friends.
|
|||
# Pangea#
|
||||
publish_to: none
|
||||
# On version bump also increase the build number for F-Droid
|
||||
version: 1.22.5+3555
|
||||
version: 1.22.6+3556
|
||||
|
||||
environment:
|
||||
sdk: ">=3.0.0 <4.0.0"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue