autoplay audio in toolbar

This commit is contained in:
Gabby Gurdin 2024-02-21 14:39:16 -05:00
parent 40c7ef49c5
commit c24619beb1
2 changed files with 19 additions and 1 deletions

View file

@ -15,12 +15,22 @@ import '../../../utils/matrix_sdk_extensions/event_extension.dart';
class AudioPlayerWidget extends StatefulWidget {
final Color color;
final Event event;
// #Pangea
final bool autoplay;
// Pangea#
static String? currentId;
static const int wavesCount = 40;
const AudioPlayerWidget(this.event, {this.color = Colors.black, super.key});
const AudioPlayerWidget(
this.event, {
this.color = Colors.black,
super.key,
// #Pangea
this.autoplay = false,
// Pangea#
});
@override
AudioPlayerState createState() => AudioPlayerState();
@ -205,6 +215,13 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
void initState() {
super.initState();
waveform = _getWaveform();
// #Pangea
if (widget.autoplay) {
status == AudioPlayerStatus.downloaded
? _playAction()
: _downloadAction();
// Pangea#
}
}
@override

View file

@ -95,6 +95,7 @@ class MessageAudioCardState extends State<MessageAudioCard> {
AudioPlayerWidget(
localAudioEvent!,
color: Theme.of(context).colorScheme.onPrimaryContainer,
autoplay: true,
),
],
),