fix: resolve DarwinAudioError on iOS using temporary .mp3 extension and upgrade mock Voice Note base64 to valid silent MP3
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user