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

View File

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

View File

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

View File

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