Merge pull request #3283 from pangeachat/fix-android-audio

chore: don't interupt message audio with button click sound
pull/2245/head
ggurdin 5 months ago committed by GitHub
commit 8c14004303
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -209,28 +209,37 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
// #Pangea // #Pangea
// if (!kIsWeb) { // if (!kIsWeb) {
if (!kIsWeb && matrixFile != null) { if (!kIsWeb) {
// Pangea# if (matrixFile != null) {
final tempDir = await getTemporaryDirectory();
final fileName = Uri.encodeComponent(
// #Pangea
// widget.event.attachmentOrThumbnailMxcUrl()!.pathSegments.last,
widget.event!.attachmentOrThumbnailMxcUrl()!.pathSegments.last,
// Pangea# // Pangea#
); final tempDir = await getTemporaryDirectory();
file = File('${tempDir.path}/${fileName}_${matrixFile.name}'); final fileName = Uri.encodeComponent(
// #Pangea
await file.writeAsBytes(matrixFile.bytes); // widget.event.attachmentOrThumbnailMxcUrl()!.pathSegments.last,
widget.event!.attachmentOrThumbnailMxcUrl()!.pathSegments.last,
if (Platform.isIOS && // Pangea#
matrixFile.mimeType.toLowerCase() == 'audio/ogg') { );
Logs().v('Convert ogg audio file for iOS...'); file = File('${tempDir.path}/${fileName}_${matrixFile.name}');
final convertedFile = File('${file.path}.caf');
if (await convertedFile.exists() == false) { await file.writeAsBytes(matrixFile.bytes);
OpusCaf().convertOpusToCaf(file.path, convertedFile.path);
if (Platform.isIOS &&
matrixFile.mimeType.toLowerCase() == 'audio/ogg') {
Logs().v('Convert ogg audio file for iOS...');
final convertedFile = File('${file.path}.caf');
if (await convertedFile.exists() == false) {
OpusCaf().convertOpusToCaf(file.path, convertedFile.path);
}
file = convertedFile;
} }
file = convertedFile; // #Pangea
} else if (widget.matrixFile != null) {
final tempDir = await getTemporaryDirectory();
file = File('${tempDir.path}/${widget.matrixFile!.name}');
await file.writeAsBytes(widget.matrixFile!.bytes);
} }
// Pangea#
} }
setState(() { setState(() {

@ -206,8 +206,8 @@ class OverlayMessage extends StatelessWidget {
text: overlayController text: overlayController
.transcription!.transcript.text, .transcription!.transcript.text,
textLanguage: PLanguageStore.byLangCode( textLanguage: PLanguageStore.byLangCode(
pangeaMessageEvent! overlayController
.messageDisplayLangCode, .transcription!.langCode,
) ?? ) ??
LanguageModel.unknown, LanguageModel.unknown,
style: AppConfig.messageTextStyle( style: AppConfig.messageTextStyle(

@ -492,7 +492,7 @@ class SelectModeButtonsState extends State<SelectModeButtons> {
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
color: Theme.of(context).colorScheme.primaryContainer, color: Theme.of(context).colorScheme.primaryContainer,
onPressed: () => _updateMode(mode), onPressed: () => _updateMode(mode),
playSound: true, playSound: mode != SelectMode.audio,
colorFactor: Theme.of(context).brightness == Brightness.light colorFactor: Theme.of(context).brightness == Brightness.light
? 0.55 ? 0.55
: 0.3, : 0.3,

Loading…
Cancel
Save