feat: Add audio message support to linux

This commit is contained in:
Krille Fear 2022-12-30 10:51:26 +01:00
parent e9d02336e1
commit ca203608fa
4 changed files with 34 additions and 8 deletions

View File

@ -102,6 +102,7 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
}
onAudioPositionChanged ??= audioPlayer.positionStream.listen((state) {
if (maxPosition <= 0) return;
setState(() {
statusText =
'${state.inMinutes.toString().padLeft(2, '0')}:${(state.inSeconds % 60).toString().padLeft(2, '0')}';
@ -110,9 +111,10 @@ class AudioPlayerState extends State<AudioPlayerWidget> {
.round();
});
});
onDurationChanged ??= audioPlayer.durationStream.listen((max) => max == null
? null
: setState(() => maxPosition = max.inMilliseconds.toDouble()));
onDurationChanged ??= audioPlayer.durationStream.listen((max) {
if (max == null || max == Duration.zero) return;
setState(() => maxPosition = max.inMilliseconds.toDouble());
});
onPlayerStateChanged ??=
audioPlayer.playingStream.listen((_) => setState(() {}));
audioPlayer.setFilePath(audioFile!.path);

View File

@ -112,7 +112,9 @@ class MessageContent extends StatelessWidget {
case CuteEventContent.eventType:
return CuteContent(event);
case MessageTypes.Audio:
if (PlatformInfos.isMobile || PlatformInfos.isMacOS) {
if (PlatformInfos.isMobile ||
PlatformInfos.isMacOS ||
PlatformInfos.isLinux) {
return AudioPlayerWidget(
event,
color: textColor,

View File

@ -77,7 +77,7 @@ packages:
name: audio_session
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.6+1"
version: "0.1.13"
badges:
dependency: "direct main"
description:
@ -358,6 +358,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
eventify:
dependency: transitive
description:
name: eventify
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
fake_async:
dependency: transitive
description:
@ -865,14 +872,21 @@ packages:
name: just_audio
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.20"
version: "0.9.30"
just_audio_mpv:
dependency: "direct main"
description:
name: just_audio_mpv
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.6"
just_audio_platform_interface:
dependency: transitive
description:
name: just_audio_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "4.1.0"
version: "4.2.0"
just_audio_web:
dependency: transitive
description:
@ -994,6 +1008,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
mpv_dart:
dependency: transitive
description:
name: mpv_dart
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1"
msix:
dependency: "direct dev"
description:

View File

@ -56,7 +56,8 @@ dependencies:
image: ^3.1.1
image_picker: ^0.8.4+8
intl: any
just_audio: ^0.9.20
just_audio: ^0.9.30
just_audio_mpv: ^0.1.6
keyboard_shortcuts: ^0.1.4
latlong2: ^0.8.1
matrix: ^0.15.11