mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-27 14:59:29 +01:00
feat: Display amplitude
This commit is contained in:
parent
ddba6c2ad6
commit
47bce19d4a
@ -24,6 +24,7 @@ class _RecordingDialogState extends State<RecordingDialog> {
|
|||||||
bool error = false;
|
bool error = false;
|
||||||
String _recordedPath;
|
String _recordedPath;
|
||||||
final _audioRecorder = Record();
|
final _audioRecorder = Record();
|
||||||
|
Amplitude _amplitude;
|
||||||
|
|
||||||
void startRecording() async {
|
void startRecording() async {
|
||||||
try {
|
try {
|
||||||
@ -41,8 +42,12 @@ class _RecordingDialogState extends State<RecordingDialog> {
|
|||||||
path: _recordedPath, encoder: AudioEncoder.AAC);
|
path: _recordedPath, encoder: AudioEncoder.AAC);
|
||||||
setState(() => _duration = Duration.zero);
|
setState(() => _duration = Duration.zero);
|
||||||
_recorderSubscription?.cancel();
|
_recorderSubscription?.cancel();
|
||||||
_recorderSubscription = Timer.periodic(Duration(seconds: 1),
|
_recorderSubscription = Timer.periodic(Duration(seconds: 1), (_) async {
|
||||||
(_) => setState(() => _duration += Duration(seconds: 1)));
|
_amplitude = await _audioRecorder.getAmplitude();
|
||||||
|
setState(() {
|
||||||
|
_duration += Duration(seconds: 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
SentryController.captureException(e, s);
|
SentryController.captureException(e, s);
|
||||||
setState(() => error = true);
|
setState(() => error = true);
|
||||||
@ -66,8 +71,8 @@ class _RecordingDialogState extends State<RecordingDialog> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
const maxDecibalWidth = 64.0;
|
const maxDecibalWidth = 64.0;
|
||||||
final decibalWidth =
|
final decibalWidth = ((_amplitude.current / _amplitude.max) * 2) *
|
||||||
((_duration.inSeconds % 2) + 1) * (maxDecibalWidth / 4).toDouble();
|
(maxDecibalWidth / 4).toDouble();
|
||||||
final time =
|
final time =
|
||||||
'${_duration.inMinutes.toString().padLeft(2, '0')}:${(_duration.inSeconds % 60).toString().padLeft(2, '0')}';
|
'${_duration.inMinutes.toString().padLeft(2, '0')}:${(_duration.inSeconds % 60).toString().padLeft(2, '0')}';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user