Skip to content

Commit

Permalink
Merge pull request #70 from pangeachat/audio-fix
Browse files Browse the repository at this point in the history
updated recording package
  • Loading branch information
ggurdin authored Feb 20, 2024
2 parents 9c0b651 + 1ed51c9 commit 88e7922
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 32 deletions.
6 changes: 4 additions & 2 deletions lib/pages/chat/chat.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:go_router/go_router.dart';
import 'package:image_picker/image_picker.dart';
import 'package:matrix/matrix.dart';
import 'package:record/record.dart';
import 'package:scroll_to_index/scroll_to_index.dart';
import 'package:shared_preferences/shared_preferences.dart';

Expand Down Expand Up @@ -784,7 +783,10 @@ class ChatController extends State<ChatPageWithRoom>
}
}

if (await Record().hasPermission() == false) return;
// #Pangea
// if (await Record().hasPermission() == false) return;
// Pangea#

final result = await showDialog<RecordingResult>(
context: context,
barrierDismissible: false,
Expand Down
28 changes: 19 additions & 9 deletions lib/pages/chat/recording_dialog.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import 'dart:async';

import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:path_provider/path_provider.dart';
import 'package:record/record.dart';
import 'package:wakelock_plus/wakelock_plus.dart';

import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'events/audio_player.dart';

class RecordingDialog extends StatefulWidget {
Expand All @@ -28,7 +27,10 @@ class RecordingDialogState extends State<RecordingDialog> {

bool error = false;
String? _recordedPath;
final _audioRecorder = Record();
// #Pangea
// final _audioRecorder = Record();
final _audioRecorder = AudioRecorder();
// Pangea#
final List<double> amplitudeTimeline = [];

static const int bitRate = 64000;
Expand All @@ -53,13 +55,21 @@ class RecordingDialogState extends State<RecordingDialog> {
(await _audioRecorder.isEncoderSupported(AudioEncoder.opus))
? AudioEncoder.opus
: AudioEncoder.aacLc;

// #Pangea
// await _audioRecorder.start(
// path: _recordedPath,
// bitRate: bitRate,
// samplingRate: samplingRate,
// );
await _audioRecorder.start(
encoder: audioCodec,
path: _recordedPath,
bitRate: bitRate,
samplingRate: samplingRate,
RecordConfig(
encoder: audioCodec,
bitRate: bitRate,
// samplingRate: samplingRate,
),
path: _recordedPath!,
);
// Pangea#
setState(() => _duration = Duration.zero);
_recorderSubscription?.cancel();
_recorderSubscription =
Expand Down
4 changes: 2 additions & 2 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import package_info_plus
import pasteboard
import path_provider_foundation
import purchases_flutter
import record_macos
import record_darwin
import sentry_flutter
import share_plus
import shared_preferences_foundation
Expand Down Expand Up @@ -68,7 +68,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
PasteboardPlugin.register(with: registry.registrar(forPlugin: "PasteboardPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
PurchasesFlutterPlugin.register(with: registry.registrar(forPlugin: "PurchasesFlutterPlugin"))
RecordMacosPlugin.register(with: registry.registrar(forPlugin: "RecordMacosPlugin"))
RecordPlugin.register(with: registry.registrar(forPlugin: "RecordPlugin"))
SentryFlutterPlugin.register(with: registry.registrar(forPlugin: "SentryFlutterPlugin"))
SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
Expand Down
40 changes: 24 additions & 16 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1792,50 +1792,58 @@ packages:
dependency: "direct main"
description:
name: record
sha256: f703397f5a60d9b2b655b3acc94ba079b2d9a67dc0725bdb90ef2fee2441ebf7
sha256: "5c8e12c692a4800b33f5f8b6c821ea083b12bfdbd031b36ba9322c40a4eeecc9"
url: "https://pub.dev"
source: hosted
version: "4.4.4"
record_linux:
version: "5.0.4"
record_android:
dependency: transitive
description:
name: record_linux
sha256: "348db92c4ec1b67b1b85d791381c8c99d7c6908de141e7c9edc20dad399b15ce"
name: record_android
sha256: "805ecaa232a671aff2ee9ec4730ef6addb97c548d2db6b1fbd5197f1d4f47a5a"
url: "https://pub.dev"
source: hosted
version: "0.4.1"
record_macos:
version: "1.0.4"
record_darwin:
dependency: transitive
description:
name: record_macos
sha256: d1d0199d1395f05e218207e8cacd03eb9dc9e256ddfe2cfcbbb90e8edea06057
name: record_darwin
sha256: ee8cb1bb1712d7ce38140ecabe70e5c286c02f05296d66043bee865ace7eb1b9
url: "https://pub.dev"
source: hosted
version: "0.2.2"
version: "1.0.1"
record_linux:
dependency: transitive
description:
name: record_linux
sha256: "7d0e70cd51635128fe9d37d89bafd6011d7cbba9af8dc323079ae60f23546aef"
url: "https://pub.dev"
source: hosted
version: "0.7.1"
record_platform_interface:
dependency: transitive
description:
name: record_platform_interface
sha256: "7a2d4ce7ac3752505157e416e4e0d666a54b1d5d8601701b7e7e5e30bec181b4"
sha256: "3a4b56e94ecd2a0b2b43eb1fa6f94c5b8484334f5d38ef43959c4bf97fb374cf"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "1.0.2"
record_web:
dependency: transitive
description:
name: record_web
sha256: "219ffb4ca59b4338117857db56d3ffadbde3169bcaf1136f5f4d4656f4a2372d"
sha256: "24847cdbcf999f7a5762170792f622ac844858766becd0f2370ec8ae22f7526e"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "1.0.5"
record_windows:
dependency: transitive
description:
name: record_windows
sha256: "42d545155a26b20d74f5107648dbb3382dbbc84dc3f1adc767040359e57a1345"
sha256: "39998b3ea7d8d28b04159d82220e6e5e32a7c357c6fb2794f5736beea272f6c3"
url: "https://pub.dev"
source: hosted
version: "0.7.1"
version: "1.0.2"
remove_emoji:
dependency: transitive
description:
Expand Down
9 changes: 6 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ dependencies:
qr_code_scanner: ^1.0.0
qr_flutter: ^4.0.0
receive_sharing_intent: ^1.4.5
record: 4.4.4 # Upgrade to 5 currently breaks playing on iOS
# #Pangea
# record: 4.4.4 # Upgrade to 5 currently breaks playing on iOS
record: ^5.0.4
# Pangea#
scroll_to_index: ^3.0.1
share_plus: ^7.2.1
shared_preferences: ^2.2.0 # Pinned because https://github.com/flutter/flutter/issues/118401
Expand Down Expand Up @@ -149,8 +152,8 @@ flutter:
# #Pangea
# uncomment this to enable mobile builds
# causes error with github actions
# - .env
# - assets/.env
- .env
- assets/.env
- assets/pangea/
- assets/pangea/bot_faces/
# Pangea#
Expand Down

0 comments on commit 88e7922

Please sign in to comment.