1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 08:15:16 +00:00

Integrate an audio player in the application

This commit is contained in:
2021-03-11 20:15:49 +01:00
parent 8f2574a555
commit 3518594eea
5 changed files with 133 additions and 4 deletions

View File

@ -2,6 +2,7 @@
///
/// @author Pierre Hubert
import 'package:comunic/models/conversation_message.dart';
import 'package:comunic/ui/dialogs/audio_player_dialog.dart';
import 'package:comunic/ui/widgets/network_image_widget.dart';
import 'package:filesize/filesize.dart';
import 'package:flutter/material.dart';
@ -47,7 +48,7 @@ class _ConversationFileWidgetState extends State<ConversationFileWidget> {
),
);
// The file is not downloadable, we open it in the browser
// We open it in the browser
default:
return Container(
color: widget.defaultBackgroundColor,
@ -69,11 +70,22 @@ class _ConversationFileWidgetState extends State<ConversationFileWidget> {
Spacer(flex: 2),
],
),
onPressed: () => launch(file.url),
onPressed: _openFile,
),
),
);
break;
}
}
void _openFile() {
switch (file.fileType) {
case ConversationMessageFileType.AUDIO:
showAudioPlayerDialog(context, file.url);
break;
default:
launch(file.url);
}
}
}