From 30722b0615e1b907f2e22d1e60a49a3ab6fd7f9f Mon Sep 17 00:00:00 2001 From: ggurdin <46800240+ggurdin@users.noreply.github.com> Date: Mon, 2 Dec 2024 14:34:45 -0500 Subject: [PATCH] don't play individual audios while main audio is playing (#1130) * don't play individual audios while main audio is playing * bump version --- lib/pangea/choreographer/widgets/choice_array.dart | 7 ++++++- lib/pangea/widgets/chat/message_selection_overlay.dart | 6 +++--- .../practice_activity/multiple_choice_activity.dart | 2 ++ pubspec.yaml | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/pangea/choreographer/widgets/choice_array.dart b/lib/pangea/choreographer/widgets/choice_array.dart index b175a6430..4b2f9de59 100644 --- a/lib/pangea/choreographer/widgets/choice_array.dart +++ b/lib/pangea/choreographer/widgets/choice_array.dart @@ -25,6 +25,8 @@ class ChoicesArray extends StatefulWidget { /// We don't want tts in the case of L1 options final TtsController? tts; + final bool enableAudio; + /// Used to unqiuely identify the keys for choices, in cases where multiple /// choices could have identical text, like in back-to-back practice activities final String? id; @@ -41,6 +43,7 @@ class ChoicesArray extends StatefulWidget { required this.uniqueKeyForLayerLink, required this.selectedChoiceIndex, required this.tts, + this.enableAudio = true, this.isActive = true, this.onLongPress, this.id, @@ -87,7 +90,9 @@ class ChoicesArrayState extends State { ? (String value, int index) { widget.onPressed(value, index); // TODO - what to pass here as eventID? - widget.tts?.tryToSpeak(value, context, null); + if (widget.enableAudio && widget.tts != null) { + widget.tts?.tryToSpeak(value, context, null); + } } : (String value, int index) { debugger(when: kDebugMode); diff --git a/lib/pangea/widgets/chat/message_selection_overlay.dart b/lib/pangea/widgets/chat/message_selection_overlay.dart index 7bef4225b..ecdaa21bf 100644 --- a/lib/pangea/widgets/chat/message_selection_overlay.dart +++ b/lib/pangea/widgets/chat/message_selection_overlay.dart @@ -66,7 +66,7 @@ class MessageOverlayController extends State PangeaMessageEvent? get pangeaMessageEvent => widget._pangeaMessageEvent; - bool _isPlayingAudio = false; + bool isPlayingAudio = false; bool get showToolbarButtons => pangeaMessageEvent != null && @@ -276,7 +276,7 @@ class MessageOverlayController extends State MessageMode.practiceActivity, // MessageMode.textToSpeech ].contains(toolbarMode) || - _isPlayingAudio) { + isPlayingAudio) { return; } @@ -360,7 +360,7 @@ class MessageOverlayController extends State void setIsPlayingAudio(bool isPlaying) { if (mounted) { - setState(() => _isPlayingAudio = isPlaying); + setState(() => isPlayingAudio = isPlaying); } } diff --git a/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart b/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart index ee741dda7..e3121d81d 100644 --- a/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart +++ b/lib/pangea/widgets/practice_activity/multiple_choice_activity.dart @@ -214,6 +214,8 @@ class MultipleChoiceActivityState extends State { isActive: true, id: currentRecordModel?.hashCode.toString(), tts: practiceActivity.activityType.includeTTSOnClick ? tts : null, + enableAudio: !widget + .practiceCardController.widget.overlayController.isPlayingAudio, ), ], ); diff --git a/pubspec.yaml b/pubspec.yaml index b23de53f7..2f388c952 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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.23.11+3570 +version: 1.23.12+3571 environment: sdk: ">=3.0.0 <4.0.0"