From 0919d75b04055930a2e698917a0b64cd211ae950 Mon Sep 17 00:00:00 2001 From: Krille Date: Mon, 30 Oct 2023 16:32:21 +0100 Subject: [PATCH] chore: Downgrade record back to 4.4.4 --- lib/pages/chat/chat.dart | 2 +- lib/pages/chat/recording_dialog.dart | 29 +++++------- macos/Flutter/GeneratedPluginRegistrant.swift | 4 +- pubspec.lock | 44 ++++++++----------- pubspec.yaml | 2 +- 5 files changed, 32 insertions(+), 49 deletions(-) diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index 59f3063c..b2b2c12f 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -621,7 +621,7 @@ class ChatController extends State { } } - if (await AudioRecorder().hasPermission() == false) return; + if (await Record().hasPermission() == false) return; final result = await showDialog( context: context, barrierDismissible: false, diff --git a/lib/pages/chat/recording_dialog.dart b/lib/pages/chat/recording_dialog.dart index 2546cdbd..300d5d9b 100644 --- a/lib/pages/chat/recording_dialog.dart +++ b/lib/pages/chat/recording_dialog.dart @@ -4,7 +4,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; -import 'package:matrix/matrix.dart'; import 'package:path_provider/path_provider.dart'; import 'package:record/record.dart'; import 'package:wakelock_plus/wakelock_plus.dart'; @@ -14,6 +13,7 @@ import 'package:fluffychat/utils/platform_infos.dart'; import 'events/audio_player.dart'; class RecordingDialog extends StatefulWidget { + static const String recordingFileType = 'm4a'; const RecordingDialog({ super.key, }); @@ -28,37 +28,28 @@ class RecordingDialogState extends State { bool error = false; String? _recordedPath; - final _audioRecorder = AudioRecorder(); + final _audioRecorder = Record(); final List amplitudeTimeline = []; + static const int bitRate = 64000; + static const int samplingRate = 22050; + Future startRecording() async { try { - // We try to pick Opus where supported, since that is a codec optimized - // for speech as well as what the voice messages MSC uses. - // Notice: Opus seems not to work on iOS. - const audioCodec = AudioEncoder.aacLc; - // see https://pub.dev/documentation/record/latest/record/AudioEncoder.html - const fileExtension = "m4a"; final tempDir = await getTemporaryDirectory(); - final path = _recordedPath = - '${tempDir.path}/recording${DateTime.now().microsecondsSinceEpoch}.$fileExtension'; + _recordedPath = + '${tempDir.path}/recording${DateTime.now().microsecondsSinceEpoch}.${RecordingDialog.recordingFileType}'; - Logs().v('Store audio file at', path); final result = await _audioRecorder.hasPermission(); if (result != true) { setState(() => error = true); return; } await WakelockPlus.enable(); - await _audioRecorder.start( - const RecordConfig( - encoder: audioCodec, - autoGain: true, - noiseSuppress: true, - echoCancel: true, - ), - path: path, + path: _recordedPath, + bitRate: bitRate, + samplingRate: samplingRate, ); setState(() => _duration = Duration.zero); _recorderSubscription?.cancel(); diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 8c747268..8ccdbb83 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -24,7 +24,7 @@ import macos_window_utils import package_info_plus import pasteboard import path_provider_foundation -import record_darwin +import record_macos import share_plus import shared_preferences_foundation import sqflite @@ -53,7 +53,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PasteboardPlugin.register(with: registry.registrar(forPlugin: "PasteboardPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) - RecordPlugin.register(with: registry.registrar(forPlugin: "RecordPlugin")) + RecordMacosPlugin.register(with: registry.registrar(forPlugin: "RecordMacosPlugin")) SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin")) diff --git a/pubspec.lock b/pubspec.lock index b1f16f19..818c6e09 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1473,58 +1473,50 @@ packages: dependency: "direct main" description: name: record - sha256: be9b710f42edf94f939dda1a1688e82a68dcd391be0a836c01e639a249f133d3 + sha256: f703397f5a60d9b2b655b3acc94ba079b2d9a67dc0725bdb90ef2fee2441ebf7 url: "https://pub.dev" source: hosted - version: "5.0.1" - record_android: - dependency: transitive - description: - name: record_android - sha256: f2d72c8e86d275967b9e9d1ced58c775958b94d3e2dac3d5416df46d23924ade - url: "https://pub.dev" - source: hosted - version: "1.0.2" - record_darwin: - dependency: transitive - description: - name: record_darwin - sha256: "78dba641ae271e555035ee68b637f7605ba9f8c60ccfd5c03b835e0b77ea201f" - url: "https://pub.dev" - source: hosted - version: "1.0.0" + version: "4.4.4" record_linux: dependency: transitive description: name: record_linux - sha256: "7d0e70cd51635128fe9d37d89bafd6011d7cbba9af8dc323079ae60f23546aef" + sha256: "348db92c4ec1b67b1b85d791381c8c99d7c6908de141e7c9edc20dad399b15ce" url: "https://pub.dev" source: hosted - version: "0.7.1" + version: "0.4.1" + record_macos: + dependency: transitive + description: + name: record_macos + sha256: d1d0199d1395f05e218207e8cacd03eb9dc9e256ddfe2cfcbbb90e8edea06057 + url: "https://pub.dev" + source: hosted + version: "0.2.2" record_platform_interface: dependency: transitive description: name: record_platform_interface - sha256: "3a4b56e94ecd2a0b2b43eb1fa6f94c5b8484334f5d38ef43959c4bf97fb374cf" + sha256: "7a2d4ce7ac3752505157e416e4e0d666a54b1d5d8601701b7e7e5e30bec181b4" url: "https://pub.dev" source: hosted - version: "1.0.2" + version: "0.5.0" record_web: dependency: transitive description: name: record_web - sha256: f1c0427dcf5af68dcfe06439d04771d65f73bd040eb0dcd98fbe4c02263a7d35 + sha256: "219ffb4ca59b4338117857db56d3ffadbde3169bcaf1136f5f4d4656f4a2372d" url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "0.5.0" record_windows: dependency: transitive description: name: record_windows - sha256: "326bfbe6f5232dd773ad6b848cd94f78148f02557abff1dd4627d056b688dbdb" + sha256: "42d545155a26b20d74f5107648dbb3382dbbc84dc3f1adc767040359e57a1345" url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "0.7.1" remove_emoji: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 405fdfd5..b0bc68a8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -74,7 +74,7 @@ dependencies: qr_code_scanner: ^1.0.0 qr_flutter: ^4.0.0 receive_sharing_intent: ^1.4.5 - record: ^5.0.1 + record: ^4.4.4 # Upgrade to 5 currently breaks playing on iOS scroll_to_index: ^3.0.1 share_plus: ^7.0.0 shared_preferences: ^2.2.0 # Pinned because https://github.com/flutter/flutter/issues/118401