fix for audio messages not starting from beginning, switched record package to version fluffychat uses
This commit is contained in:
parent
614f83ad29
commit
40fbdb2ec7
4 changed files with 59 additions and 36 deletions
|
|
@ -31,9 +31,9 @@ class AudioPlayerWidget extends StatefulWidget {
|
|||
this.color = Colors.black,
|
||||
// #Pangea
|
||||
this.matrixFile,
|
||||
super.key,
|
||||
this.autoplay = false,
|
||||
// Pangea#
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
|
|
@ -236,6 +236,27 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
|
|||
|
||||
late final List<int> waveform;
|
||||
|
||||
void _toggleSpeed() async {
|
||||
final audioPlayer = this.audioPlayer;
|
||||
if (audioPlayer == null) return;
|
||||
switch (audioPlayer.speed) {
|
||||
case 1.0:
|
||||
await audioPlayer.setSpeed(1.5);
|
||||
break;
|
||||
case 1.5:
|
||||
await audioPlayer.setSpeed(2.0);
|
||||
break;
|
||||
case 2.0:
|
||||
await audioPlayer.setSpeed(0.5);
|
||||
break;
|
||||
case 0.5:
|
||||
default:
|
||||
await audioPlayer.setSpeed(1.0);
|
||||
break;
|
||||
}
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
// #Pangea
|
||||
Future<void> _downloadMatrixFile() async {
|
||||
if (kIsWeb) return;
|
||||
|
|
@ -272,12 +293,12 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final statusText = this.statusText ??= _durationString ?? '00:00';
|
||||
final audioPlayer = this.audioPlayer;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
const SizedBox(width: 4),
|
||||
SizedBox(
|
||||
width: buttonSize,
|
||||
height: buttonSize,
|
||||
|
|
@ -354,6 +375,35 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
|
|||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Stack(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: buttonSize,
|
||||
height: buttonSize,
|
||||
child: InkWell(
|
||||
splashColor: widget.color.withAlpha(128),
|
||||
borderRadius: BorderRadius.circular(64),
|
||||
onTap: audioPlayer == null ? null : _toggleSpeed,
|
||||
child: Icon(Icons.mic_none_outlined, color: widget.color),
|
||||
),
|
||||
),
|
||||
if (audioPlayer != null)
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Text(
|
||||
'${audioPlayer.speed.toString()}x',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 9.0,
|
||||
color: widget.color,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -27,10 +27,7 @@ class RecordingDialogState extends State<RecordingDialog> {
|
|||
|
||||
bool error = false;
|
||||
String? _recordedPath;
|
||||
// #Pangea
|
||||
// final _audioRecorder = Record();
|
||||
final _audioRecorder = AudioRecorder();
|
||||
// Pangea#
|
||||
final _audioRecorder = Record();
|
||||
final List<double> amplitudeTimeline = [];
|
||||
|
||||
static const int bitRate = 64000;
|
||||
|
|
@ -48,28 +45,11 @@ class RecordingDialogState extends State<RecordingDialog> {
|
|||
return;
|
||||
}
|
||||
await WakelockPlus.enable();
|
||||
|
||||
// We try to pick Opus where supported, since that is a codec optimized
|
||||
// for speech as well as what the voice messages MSC uses.
|
||||
final audioCodec =
|
||||
(await _audioRecorder.isEncoderSupported(AudioEncoder.opus))
|
||||
? AudioEncoder.opus
|
||||
: AudioEncoder.aacLc;
|
||||
// #Pangea
|
||||
// await _audioRecorder.start(
|
||||
// path: _recordedPath,
|
||||
// bitRate: bitRate,
|
||||
// samplingRate: samplingRate,
|
||||
// );
|
||||
await _audioRecorder.start(
|
||||
RecordConfig(
|
||||
encoder: audioCodec,
|
||||
bitRate: bitRate,
|
||||
// samplingRate: samplingRate,
|
||||
),
|
||||
path: _recordedPath!,
|
||||
path: _recordedPath,
|
||||
bitRate: bitRate,
|
||||
samplingRate: samplingRate,
|
||||
);
|
||||
// Pangea#
|
||||
setState(() => _duration = Duration.zero);
|
||||
_recorderSubscription?.cancel();
|
||||
_recorderSubscription =
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import 'dart:convert';
|
|||
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:fluffychat/pangea/constants/model_keys.dart';
|
||||
import 'package:fluffychat/pangea/constants/pangea_message_types.dart';
|
||||
import 'package:fluffychat/pangea/controllers/text_to_speech_controller.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/pangea/models/choreo_record.dart';
|
||||
|
|
@ -462,7 +461,7 @@ class PangeaMessageEvent {
|
|||
_event.room.isSpaceAdmin &&
|
||||
_event.senderId != BotName.byEnvironment &&
|
||||
!room.isUserSpaceAdmin(_event.senderId) &&
|
||||
_event.messageType != PangeaMessageTypes.report;
|
||||
_event.messageType == MessageTypes.Text;
|
||||
|
||||
String get messageDisplayLangCode {
|
||||
final bool immersionMode = MatrixState
|
||||
|
|
|
|||
10
pubspec.yaml
10
pubspec.yaml
|
|
@ -63,10 +63,7 @@ dependencies:
|
|||
http: ^0.13.6
|
||||
image_picker: ^1.0.0
|
||||
intl: any
|
||||
# #Pangea
|
||||
# just_audio: ^0.9.0
|
||||
just_audio: ^0.9.36
|
||||
# Pangea#
|
||||
just_audio: ^0.9.37
|
||||
keyboard_shortcuts: ^0.1.4
|
||||
latlong2: ^0.8.1
|
||||
linkify: ^5.0.0
|
||||
|
|
@ -85,10 +82,7 @@ dependencies:
|
|||
qr_code_scanner: ^1.0.0
|
||||
qr_flutter: ^4.0.0
|
||||
receive_sharing_intent: ^1.4.5
|
||||
# #Pangea
|
||||
# record: 4.4.4 # Upgrade to 5 currently breaks playing on iOS
|
||||
record: ^5.0.4
|
||||
# Pangea#
|
||||
record: 4.4.4 # Upgrade to 5 currently breaks playing on iOS
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue