Merge branch 'main' into phonetic-audio-color

This commit is contained in:
ggurdin 2025-06-18 15:57:40 -04:00 committed by GitHub
commit b386458b05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 32 additions and 10 deletions

View file

@ -1651,6 +1651,13 @@ class ChatController extends State<ChatPageWithRoom>
showEmojiPicker = false;
});
}
void setSelectedEvent(Event event) {
setState(() {
selectedEvents.clear();
selectedEvents.add(event);
});
}
// Pangea#
void clearSingleSelectedEvent() {

View file

@ -35,7 +35,7 @@ class TtsController {
static final StreamController<bool> loadingChoreoStream =
StreamController<bool>.broadcast();
static final audioPlayer = AudioPlayer();
static AudioPlayer? audioPlayer;
static bool get _useAlternativeTTS {
return PlatformInfos.isWindows;
@ -122,7 +122,7 @@ class TtsController {
// https://pub.dev/packages/flutter_tts
final result =
await (_useAlternativeTTS ? _alternativeTTS.stop() : _tts.stop());
audioPlayer.stop();
audioPlayer?.stop();
if (!_useAlternativeTTS && result != 1) {
ErrorHandler.logError(
@ -173,8 +173,6 @@ class TtsController {
onStart: onStart,
onStop: onStop,
);
onStop?.call();
}
/// A safer version of speak, that handles the case of
@ -314,13 +312,15 @@ class TtsController {
try {
Logs().i('Speaking from choreo: $text, langCode: $langCode');
final audioContent = base64Decode(ttsRes.audioContent);
await audioPlayer.setAudioSource(
audioPlayer?.dispose();
audioPlayer = AudioPlayer();
await audioPlayer!.setAudioSource(
BytesAudioSource(
audioContent,
ttsRes.mimeType,
),
);
await audioPlayer.play();
await audioPlayer!.play();
} catch (e, s) {
ErrorHandler.logError(
e: 'Error playing audio',
@ -330,6 +330,9 @@ class TtsController {
'text': text,
},
);
} finally {
audioPlayer?.dispose();
audioPlayer = null;
}
}

View file

@ -109,8 +109,19 @@ class MessageOverlayController extends State<MessageSelectionOverlay>
@override
void initState() {
initializeTokensAndMode();
super.initState();
initializeTokensAndMode();
WidgetsBinding.instance.addPostFrameCallback(
(_) => widget.chatController.setSelectedEvent(event),
);
}
@override
void dispose() {
WidgetsBinding.instance.addPostFrameCallback(
(_) => widget.chatController.clearSelectedEvents(),
);
super.dispose();
}
Future<void> initializeTokensAndMode() async {

View file

@ -36,9 +36,10 @@ class OverlayHeaderState extends State<OverlayHeader> {
Widget build(BuildContext context) {
final l10n = L10n.of(context);
final theme = Theme.of(context);
final pinned = controller.room.pinnedEventIds.contains(
controller.selectedEvents.first.eventId,
);
final pinned = controller.selectedEvents.length == 1 &&
controller.room.pinnedEventIds.contains(
controller.selectedEvents.first.eventId,
);
return Container(
padding: const EdgeInsets.symmetric(horizontal: 10),
decoration: BoxDecoration(