|
|
|
|
@ -209,28 +209,37 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
|
|
|
|
|
|
|
|
|
|
// #Pangea
|
|
|
|
|
// if (!kIsWeb) {
|
|
|
|
|
if (!kIsWeb && matrixFile != null) {
|
|
|
|
|
// Pangea#
|
|
|
|
|
final tempDir = await getTemporaryDirectory();
|
|
|
|
|
final fileName = Uri.encodeComponent(
|
|
|
|
|
// #Pangea
|
|
|
|
|
// widget.event.attachmentOrThumbnailMxcUrl()!.pathSegments.last,
|
|
|
|
|
widget.event!.attachmentOrThumbnailMxcUrl()!.pathSegments.last,
|
|
|
|
|
if (!kIsWeb) {
|
|
|
|
|
if (matrixFile != null) {
|
|
|
|
|
// Pangea#
|
|
|
|
|
);
|
|
|
|
|
file = File('${tempDir.path}/${fileName}_${matrixFile.name}');
|
|
|
|
|
|
|
|
|
|
await file.writeAsBytes(matrixFile.bytes);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
final tempDir = await getTemporaryDirectory();
|
|
|
|
|
final fileName = Uri.encodeComponent(
|
|
|
|
|
// #Pangea
|
|
|
|
|
// widget.event.attachmentOrThumbnailMxcUrl()!.pathSegments.last,
|
|
|
|
|
widget.event!.attachmentOrThumbnailMxcUrl()!.pathSegments.last,
|
|
|
|
|
// Pangea#
|
|
|
|
|
);
|
|
|
|
|
file = File('${tempDir.path}/${fileName}_${matrixFile.name}');
|
|
|
|
|
|
|
|
|
|
await file.writeAsBytes(matrixFile.bytes);
|
|
|
|
|
|
|
|
|
|
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(() {
|
|
|
|
|
|