Fix exception in just_audio_media_kit

This commit is contained in:
Daniel 2024-08-14 15:49:50 -04:00
parent c80625d07e
commit 56ec3e3c53
4 changed files with 46 additions and 9 deletions

View file

@ -1,3 +1,5 @@
proto:
protoc -I protobuf/ --dart_out=lib/pb protobuf/stillbox.proto google/protobuf/timestamp.proto
patch:
dart run patch_package apply

View file

@ -0,0 +1,35 @@
diff -ruN /tmp/just_audio_media_kit/lib/mediakit_player.dart /home/dponte/.pub-cache/hosted/pub.dev/just_audio_media_kit-2.0.5/lib/mediakit_player.dart
--- /tmp/just_audio_media_kit/lib/mediakit_player.dart 2024-08-14 15:47:51.698551487 -0400
+++ /home/dponte/.pub-cache/hosted/pub.dev/just_audio_media_kit-2.0.5/lib/mediakit_player.dart 2024-08-14 15:48:02.401944337 -0400
@@ -35,8 +35,11 @@
/// [LoadRequest.initialPosition] or [seek] request before [Player.play] was called and/or finished loading.
Duration? _setPosition;
- Media get _currentMedia =>
- _player.state.playlist.medias[_player.state.playlist.index];
+ Media? get _currentMedia {
+ var medias = _player.state.playlist.medias;
+ if (medias.isEmpty) return null;
+ return medias[_player.state.playlist.index];
+ }
MediaKitPlayer(super.id) {
_player = Player(
@@ -57,7 +60,7 @@
_streamSubscriptions = [
_player.stream.duration.listen((duration) {
- if (_currentMedia.extras?['overrideDuration'] != null) return;
+ if (_currentMedia?.extras?['overrideDuration'] != null) return;
_processingState = ProcessingStateMessage.ready;
if (_setPosition != null && duration.inSeconds > 0) {
@@ -111,7 +114,7 @@
_currentIndex = playlist.index;
}
_updatePlaybackEvent(
- duration: _currentMedia.extras?['overrideDuration']);
+ duration: _currentMedia?.extras?['overrideDuration']);
}),
_player.stream.playlistMode.listen((playlistMode) {
_dataController.add(

View file

@ -110,14 +110,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.0"
flutter_patch_package:
dependency: "direct main"
description:
name: flutter_patch_package
sha256: d24e953a5d223d53fded329e66c9037ddf3ea90f2ee85c730c4c846f287f4738
url: "https://pub.dev"
source: hosted
version: "0.0.11"
flutter_secure_storage:
dependency: "direct main"
description:
@ -352,6 +344,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.0"
patch_package:
dependency: "direct main"
description:
name: patch_package
sha256: ade4baf6e726395435e1d74cfe035978cf089024663e479e80fbe6c9d94b90a3
url: "https://pub.dev"
source: hosted
version: "0.0.8"
path:
dependency: transitive
description:

View file

@ -47,7 +47,7 @@ dependencies:
media_kit_libs_linux: any
media_kit_libs_windows_audio: any
media_kit_native_event_loop: ^1.0.8
flutter_patch_package: '^0.0.11'
patch_package: ^0.0.8
dev_dependencies:
flutter_test: