fix: resolve DarwinAudioError on iOS using temporary .mp3 extension and upgrade mock Voice Note base64 to valid silent MP3

This commit is contained in:
Hamza-Ayed
2026-05-18 17:29:24 +03:00
parent e28d985c10
commit e18f4195b9
2 changed files with 15 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:get/get.dart';
@@ -210,7 +211,16 @@ class _InteractiveMediaWidgetState extends State<InteractiveMediaWidget> {
await _player.pause();
} else {
final bytes = base64Decode(base64Data);
await _player.play(BytesSource(bytes));
// Clean special characters from ID to construct a safe filename
final safeId = widget.message.id.replaceAll(RegExp(r'[^a-zA-Z0-9]'), '');
final tempDir = Directory.systemTemp;
final tempFile = File('${tempDir.path}/voice_$safeId.mp3');
if (!await tempFile.exists()) {
await tempFile.writeAsBytes(bytes);
}
await _player.play(DeviceFileSource(tempFile.path));
}
} catch (e) {
print('[AUDIO PLAYBACK ERROR] $e');