Merge pull request #4904 from pangeachat/4902-fix-word-audio-not-playing-on-token-click
feat: play audio on token click and on construct click in vocab analy…
This commit is contained in:
commit
d92de722ce
3 changed files with 19 additions and 14 deletions
|
|
@ -10,7 +10,6 @@ import 'package:fluffychat/pages/chat/events/video_player.dart';
|
|||
import 'package:fluffychat/pangea/events/event_wrappers/pangea_message_event.dart';
|
||||
import 'package:fluffychat/pangea/events/extensions/pangea_event_extension.dart';
|
||||
import 'package:fluffychat/pangea/events/models/pangea_token_model.dart';
|
||||
import 'package:fluffychat/pangea/text_to_speech/tts_controller.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/layout/reading_assistance_mode_enum.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/message_selection_overlay.dart';
|
||||
import 'package:fluffychat/utils/event_checkbox_extension.dart';
|
||||
|
|
@ -135,16 +134,6 @@ class MessageContent extends StatelessWidget {
|
|||
if (overlayController != null) {
|
||||
overlayController?.onClickOverlayMessageToken(token);
|
||||
return;
|
||||
} else {
|
||||
Future.delayed(
|
||||
const Duration(
|
||||
milliseconds: AppConfig.overlayAnimationDuration,
|
||||
), () {
|
||||
TtsController.tryToSpeak(
|
||||
token.text.content,
|
||||
langCode: pangeaMessageEvent!.messageDisplayLangCode,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
controller.showToolbar(
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import 'package:fluffychat/pangea/analytics_misc/construct_use_model.dart';
|
|||
import 'package:fluffychat/pangea/constructs/construct_level_enum.dart';
|
||||
import 'package:fluffychat/pangea/instructions/instructions_enum.dart';
|
||||
import 'package:fluffychat/pangea/instructions/instructions_inline_tooltip.dart';
|
||||
import 'package:fluffychat/pangea/text_to_speech/tts_controller.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
|
||||
/// Displays vocab analytics, sorted into categories
|
||||
|
|
@ -174,9 +175,16 @@ class VocabAnalyticsListView extends StatelessWidget {
|
|||
(context, index) {
|
||||
final vocabItem = _filteredVocab[index];
|
||||
return VocabAnalyticsListTile(
|
||||
onTap: () => context.go(
|
||||
"/rooms/analytics/${vocabItem.id.type.string}/${Uri.encodeComponent(vocabItem.id.string)}",
|
||||
),
|
||||
onTap: () {
|
||||
TtsController.tryToSpeak(
|
||||
vocabItem.id.lemma,
|
||||
langCode: MatrixState.pangeaController
|
||||
.userController.userL2Code!,
|
||||
);
|
||||
context.go(
|
||||
"/rooms/analytics/${vocabItem.id.type.string}/${Uri.encodeComponent(vocabItem.id.string)}",
|
||||
);
|
||||
},
|
||||
constructId: vocabItem.id,
|
||||
textColor:
|
||||
Theme.of(context).brightness == Brightness.light
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import 'package:fluffychat/pangea/events/event_wrappers/pangea_representation_ev
|
|||
import 'package:fluffychat/pangea/events/models/pangea_token_model.dart';
|
||||
import 'package:fluffychat/pangea/events/models/pangea_token_text_model.dart';
|
||||
import 'package:fluffychat/pangea/text_to_speech/text_to_speech_response_model.dart';
|
||||
import 'package:fluffychat/pangea/text_to_speech/tts_controller.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/layout/message_selection_positioner.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/message_practice/practice_controller.dart';
|
||||
import 'package:fluffychat/pangea/toolbar/reading_assistance/select_mode_buttons.dart';
|
||||
|
|
@ -202,6 +203,13 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
|
|||
selectedTokenNotifier.value = selectedToken;
|
||||
selectModeController.setPlayingToken(selectedToken?.text);
|
||||
|
||||
if (selectedToken != null) {
|
||||
TtsController.tryToSpeak(
|
||||
selectedToken!.text.content,
|
||||
langCode: pangeaMessageEvent.messageDisplayLangCode,
|
||||
);
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
if (selectedToken != null && isNewToken(selectedToken!)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue