diff --git a/audio_service/CHANGELOG.md b/audio_service/CHANGELOG.md index c9299c9c..5ce976e2 100644 --- a/audio_service/CHANGELOG.md +++ b/audio_service/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.18.13 * Fix setAndroidPlaybackInfo call blocking (@julianscheel). +* Pass through missing extras to playFrom.../prepareFrom... (@Ruchit2759). ## 0.18.12 diff --git a/audio_service/example/lib/example_android13.dart b/audio_service/example/lib/example_android13.dart index 27593cac..90a7e1bd 100644 --- a/audio_service/example/lib/example_android13.dart +++ b/audio_service/example/lib/example_android13.dart @@ -114,6 +114,7 @@ class MainScreen extends StatelessWidget { final processingState = snapshot.data ?? AudioProcessingState.idle; return Text( + // ignore: deprecated_member_use "Processing state: ${describeEnum(processingState)}"); }, ), diff --git a/audio_service/example/lib/example_multiple_handlers.dart b/audio_service/example/lib/example_multiple_handlers.dart index b998a764..d270d4b3 100644 --- a/audio_service/example/lib/example_multiple_handlers.dart +++ b/audio_service/example/lib/example_multiple_handlers.dart @@ -178,6 +178,7 @@ class MainScreen extends StatelessWidget { final processingState = snapshot.data ?? AudioProcessingState.idle; return Text( + // ignore: deprecated_member_use "Processing state: ${describeEnum(processingState)}"); }, ), diff --git a/audio_service/example/lib/main.dart b/audio_service/example/lib/main.dart index d65cf70b..91e5c79f 100644 --- a/audio_service/example/lib/main.dart +++ b/audio_service/example/lib/main.dart @@ -120,6 +120,7 @@ class MainScreen extends StatelessWidget { final processingState = snapshot.data ?? AudioProcessingState.idle; return Text( + // ignore: deprecated_member_use "Processing state: ${describeEnum(processingState)}"); }, ), diff --git a/audio_service/lib/audio_service.dart b/audio_service/lib/audio_service.dart index 52964506..88fe1de4 100644 --- a/audio_service/lib/audio_service.dart +++ b/audio_service/lib/audio_service.dart @@ -1,3 +1,5 @@ +// ignore_for_file: close_sinks + import 'dart:async'; import 'dart:isolate'; import 'dart:ui'; @@ -963,7 +965,6 @@ class AudioService { /// The root media ID for browsing the most recently played item(s). static const String recentRootId = 'recent'; - // ignore: close_sinks static final BehaviorSubject _notificationClicked = BehaviorSubject.seeded(false); @@ -1013,13 +1014,13 @@ class AudioService { } static Future _observeMediaItem() async { - Object? _artFetchOperationId; + Object? artFetchOperationId; _handler.mediaItem.listen((mediaItem) async { if (mediaItem == null) { return; } final operationId = Object(); - _artFetchOperationId = operationId; + artFetchOperationId = operationId; final artUri = mediaItem.artUri; if (artUri == null || artUri.scheme == 'content') { _platform.setMediaItem( @@ -1027,7 +1028,7 @@ class AudioService { } else { /// Sends media item to the platform. /// We potentially need to fetch the art before that. - Future _sendToPlatform(String? filePath) async { + Future sendToPlatform(String? filePath) async { final extras = mediaItem.extras; final platformMediaItem = mediaItem.copyWith( extras: { @@ -1040,35 +1041,35 @@ class AudioService { } if (artUri.scheme == 'file') { - _sendToPlatform(artUri.toFilePath()); + sendToPlatform(artUri.toFilePath()); } else { // Try to load a cached file from memory. final fileInfo = await cacheManager.getFileFromMemory(artUri.toString()); final filePath = fileInfo?.file.path; - if (operationId != _artFetchOperationId) { + if (operationId != artFetchOperationId) { return; } if (filePath != null) { // If we successfully downloaded the art call to platform. - _sendToPlatform(filePath); + sendToPlatform(filePath); } else { // We haven't fetched the art yet, so show the metadata now, and again // after we load the art. await _platform.setMediaItem( SetMediaItemRequest(mediaItem: mediaItem._toMessage())); - if (operationId != _artFetchOperationId) { + if (operationId != artFetchOperationId) { return; } // Load the art. final loadedFilePath = await _loadArtwork(mediaItem); - if (operationId != _artFetchOperationId) { + if (operationId != artFetchOperationId) { return; } // If we successfully downloaded the art, call to platform. if (loadedFilePath != null) { - _sendToPlatform(loadedFilePath); + sendToPlatform(loadedFilePath); } } } @@ -1115,7 +1116,7 @@ class AudioService { /// no slower than once every 200ms. /// /// See [createPositionStream] for more control over the stream parameters. - static late final Stream position = createPositionStream( + static final Stream position = createPositionStream( steps: 800, minPeriod: const Duration(milliseconds: 16), maxPeriod: const Duration(milliseconds: 200)); @@ -1137,7 +1138,6 @@ class AudioService { assert(minPeriod <= maxPeriod); assert(minPeriod > Duration.zero); Duration? last; - // ignore: close_sinks late StreamController controller; late StreamSubscription mediaItemSubscription; late StreamSubscription playbackStateSubscription; @@ -1511,7 +1511,7 @@ class AudioService { /// Deprecated. Use [position] instead. @Deprecated("Use position instead.") - static late final ValueStream positionStream = + static final ValueStream positionStream = BehaviorSubject.seeded(Duration.zero, sync: true) ..addStream(position) ..stream; @@ -2948,7 +2948,6 @@ class BaseAudioHandler extends AudioHandler { /// The state changes broadcast via this stream can be listened to via the /// Flutter app's UI @override - // ignore: close_sinks final BehaviorSubject playbackState = BehaviorSubject.seeded(PlaybackState()); @@ -2969,7 +2968,6 @@ class BaseAudioHandler extends AudioHandler { /// queueTitle.add(newTitle); /// ``` @override - // ignore: close_sinks final BehaviorSubject queueTitle = BehaviorSubject.seeded(''); /// A controller for broadcasting the current media item to the app's UI, @@ -2979,7 +2977,6 @@ class BaseAudioHandler extends AudioHandler { /// mediaItem.add(item); /// ``` @override - // ignore: close_sinks final BehaviorSubject mediaItem = BehaviorSubject.seeded(null); /// A controller for broadcasting the current [AndroidPlaybackInfo] to the app's UI, @@ -2989,7 +2986,6 @@ class BaseAudioHandler extends AudioHandler { /// androidPlaybackInfo.add(newPlaybackInfo); /// ``` @override - // ignore: close_sinks final BehaviorSubject androidPlaybackInfo = BehaviorSubject(); @@ -3000,7 +2996,6 @@ class BaseAudioHandler extends AudioHandler { /// ratingStyle.add(style); /// ``` @override - // ignore: close_sinks final BehaviorSubject ratingStyle = BehaviorSubject(); /// A controller for broadcasting a custom event to the app's UI. @@ -3011,7 +3006,6 @@ class BaseAudioHandler extends AudioHandler { /// customEventSubject.add(MyCustomEvent(arg: 3)); /// ``` @override - // ignore: close_sinks final PublishSubject customEvent = PublishSubject(); /// A controller for broadcasting the current custom state to the app's UI. @@ -3021,7 +3015,6 @@ class BaseAudioHandler extends AudioHandler { /// customState.add(MyCustomState(...)); /// ``` @override - // ignore: close_sinks final BehaviorSubject customState = BehaviorSubject(); /// Constructor. Normally this is called from subclasses via `super`. @@ -3891,15 +3884,15 @@ class _HandlerCallbacks extends AudioHandlerCallbacks { @override Future playFromMediaId(PlayFromMediaIdRequest request) async => - (await handlerFuture).playFromMediaId(request.mediaId); + (await handlerFuture).playFromMediaId(request.mediaId, request.extras); @override Future playFromSearch(PlayFromSearchRequest request) async => - (await handlerFuture).playFromSearch(request.query); + (await handlerFuture).playFromSearch(request.query, request.extras); @override Future playFromUri(PlayFromUriRequest request) async => - (await handlerFuture).playFromUri(request.uri); + (await handlerFuture).playFromUri(request.uri, request.extras); @override Future playMediaItem(PlayMediaItemRequest request) async => @@ -3911,15 +3904,15 @@ class _HandlerCallbacks extends AudioHandlerCallbacks { @override Future prepareFromMediaId(PrepareFromMediaIdRequest request) async => - (await handlerFuture).prepareFromMediaId(request.mediaId); + (await handlerFuture).prepareFromMediaId(request.mediaId, request.extras); @override Future prepareFromSearch(PrepareFromSearchRequest request) async => - (await handlerFuture).prepareFromSearch(request.query); + (await handlerFuture).prepareFromSearch(request.query, request.extras); @override Future prepareFromUri(PrepareFromUriRequest request) async => - (await handlerFuture).prepareFromUri(request.uri); + (await handlerFuture).prepareFromUri(request.uri, request.extras); @override Future removeQueueItem(RemoveQueueItemRequest request) async => diff --git a/audio_service/pubspec.yaml b/audio_service/pubspec.yaml index ff137cb6..8124cb76 100644 --- a/audio_service/pubspec.yaml +++ b/audio_service/pubspec.yaml @@ -49,7 +49,7 @@ dev_dependencies: sdk: flutter mockito: ^5.0.0 fake_async: ^1.2.0 - flutter_lints: ^1.0.4 + flutter_lints: ^3.0.1 flutter: plugin: diff --git a/audio_service/test/isolates_test.dart b/audio_service/test/isolates_test.dart index 6d06b33a..e8c99983 100644 --- a/audio_service/test/isolates_test.dart +++ b/audio_service/test/isolates_test.dart @@ -1,3 +1,5 @@ +// ignore_for_file: close_sinks + import 'dart:isolate'; import 'package:audio_service/audio_service.dart'; @@ -265,7 +267,6 @@ void isolateEntryPoint(SendPort sendPort) { class _MockAudioHandler implements BaseAudioHandler { @override - // ignore: close_sinks final BehaviorSubject playbackState = BehaviorSubject.seeded(PlaybackState()); @@ -274,28 +275,22 @@ class _MockAudioHandler implements BaseAudioHandler { BehaviorSubject.seeded([]); @override - // ignore: close_sinks final BehaviorSubject queueTitle = BehaviorSubject.seeded(''); @override - // ignore: close_sinks final BehaviorSubject mediaItem = BehaviorSubject.seeded(null); @override - // ignore: close_sinks final BehaviorSubject androidPlaybackInfo = BehaviorSubject(); @override - // ignore: close_sinks final BehaviorSubject ratingStyle = BehaviorSubject(); @override - // ignore: close_sinks final PublishSubject customEvent = PublishSubject(); @override - // ignore: close_sinks final BehaviorSubject customState = BehaviorSubject(); final Map invocationCounts = {};