diff --git a/audio_service/CHANGELOG.md b/audio_service/CHANGELOG.md index ba3f1965..8171b570 100644 --- a/audio_service/CHANGELOG.md +++ b/audio_service/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.18.16 + +* Support MPNowPlayingInfoPropertyIsLiveStream on IOS (@MuradSh, @celsoft). + ## 0.18.15 * Add deep link support for FlutterFragmentActivity (@jan-milovanovic). diff --git a/audio_service/darwin/Classes/AudioServicePlugin.m b/audio_service/darwin/Classes/AudioServicePlugin.m index c5c1f247..aecd590f 100644 --- a/audio_service/darwin/Classes/AudioServicePlugin.m +++ b/audio_service/darwin/Classes/AudioServicePlugin.m @@ -291,6 +291,9 @@ - (void) updateNowPlayingInfo { if (@available(iOS 13.0, macOS 10.12.2, *)) { center.playbackState = playing ? MPNowPlayingPlaybackStatePlaying : MPNowPlayingPlaybackStatePaused; } + if (@available(iOS 10.0, macOS 10.12.2, *)) { + updated |= [self updateNowPlayingField:MPNowPlayingInfoPropertyIsLiveStream value:mediaItem[@"isLive"]]; + } if (updated) { //NSLog(@"### updating nowPlayingInfo"); center.nowPlayingInfo = nowPlayingInfo; @@ -308,7 +311,6 @@ - (void) updateNowPlayingInfo { // * MPNowPlayingInfoPropertyCurrentPlaybackDate // * MPNowPlayingInfoPropertyExternalContentIdentifier // * MPNowPlayingInfoPropertyExternalUserProfileIdentifier - // * MPNowPlayingInfoPropertyIsLiveStream // * MPNowPlayingInfoPropertyPlaybackProgress // * MPNowPlayingInfoPropertyPlaybackQueueCount // * MPNowPlayingInfoPropertyPlaybackQueueIndex diff --git a/audio_service/lib/audio_service.dart b/audio_service/lib/audio_service.dart index 236da843..34363f4c 100644 --- a/audio_service/lib/audio_service.dart +++ b/audio_service/lib/audio_service.dart @@ -627,6 +627,9 @@ class MediaItem { /// The rating of the media item. final Rating? rating; + /// Whether this is a live stream. + final bool? isLive; + /// A map of additional metadata for the media item. /// /// The values must be of type `int`, `String`, `bool` or `double`. @@ -649,6 +652,7 @@ class MediaItem { this.displaySubtitle, this.displayDescription, this.rating, + this.isLive, this.extras, }); @@ -676,6 +680,7 @@ class MediaItem { displaySubtitle: displaySubtitle, displayDescription: displayDescription, rating: rating?._toMessage(), + isLive: isLive, extras: extras, ); @@ -699,6 +704,7 @@ abstract class MediaItemCopyWith { String? displaySubtitle, String? displayDescription, Rating? rating, + bool? isLive, Map? extras, }); } @@ -727,6 +733,7 @@ class _MediaItemCopyWith extends MediaItemCopyWith { Object? displaySubtitle = _fakeNull, Object? displayDescription = _fakeNull, Object? rating = _fakeNull, + Object? isLive = _fakeNull, Object? extras = _fakeNull, }) => MediaItem( @@ -749,6 +756,7 @@ class _MediaItemCopyWith extends MediaItemCopyWith { ? value.displayDescription : displayDescription as String?, rating: rating == _fakeNull ? value.rating : rating as Rating?, + isLive: isLive == _fakeNull ? value.isLive : isLive as bool?, extras: extras == _fakeNull ? value.extras : extras as Map?, @@ -3599,6 +3607,7 @@ extension _MediaItemMessageExtension on MediaItemMessage { displaySubtitle: displaySubtitle, displayDescription: displayDescription, rating: rating?.toPlugin(), + isLive: isLive, extras: extras, ); } diff --git a/audio_service/pubspec.yaml b/audio_service/pubspec.yaml index 0e394a12..8e527672 100644 --- a/audio_service/pubspec.yaml +++ b/audio_service/pubspec.yaml @@ -1,6 +1,6 @@ name: audio_service description: Flutter plugin to play audio in the background while the screen is off. -version: 0.18.15 +version: 0.18.16 repository: https://github.com/ryanheise/audio_service/tree/minor/audio_service issue_tracker: https://github.com/ryanheise/audio_service/issues topics: @@ -13,10 +13,10 @@ environment: dependencies: # Use these deps for local development - #audio_service_platform_interface: - # path: ../audio_service_platform_interface - #audio_service_web: - # path: ../audio_service_web + # audio_service_platform_interface: + # path: ../audio_service_platform_interface + # audio_service_web: + # path: ../audio_service_web # Use these deps when pushing to origin (for the benefit of testers) # audio_service_platform_interface: @@ -31,7 +31,7 @@ dependencies: # path: audio_service_web # Use these deps when publishing. - audio_service_platform_interface: ^0.1.1 + audio_service_platform_interface: ^0.1.2 audio_service_web: ^0.1.3 audio_session: ^0.1.20 diff --git a/audio_service_platform_interface/CHANGELOG.md b/audio_service_platform_interface/CHANGELOG.md index 3a2ebf01..8df42811 100644 --- a/audio_service_platform_interface/CHANGELOG.md +++ b/audio_service_platform_interface/CHANGELOG.md @@ -1,11 +1,15 @@ +## 0.1.2 + +* Support MPNowPlayingInfoPropertyIsLiveStream on IOS (@MuradSh, @celsoft). + ## 0.1.1 -* Add customAction to MediaControlMessage (@defsub) +* Add customAction to MediaControlMessage (@defsub). ## 0.1.0 -* Remove unused androidEnableQueue option -* Add setSpeed to MediaActionMessage enum (@nt4f04uNd) +* Remove unused androidEnableQueue option. +* Add setSpeed to MediaActionMessage enum (@nt4f04uNd). ## 0.0.1 diff --git a/audio_service_platform_interface/lib/audio_service_platform_interface.dart b/audio_service_platform_interface/lib/audio_service_platform_interface.dart index edceee26..d5af801b 100644 --- a/audio_service_platform_interface/lib/audio_service_platform_interface.dart +++ b/audio_service_platform_interface/lib/audio_service_platform_interface.dart @@ -620,6 +620,9 @@ class MediaItemMessage { /// The rating of the MediaItemMessage. final RatingMessage? rating; + // Whether this is a livestream + final bool? isLive; + /// A map of additional metadata for the media item. /// /// The values must be integers or strings. @@ -642,6 +645,7 @@ class MediaItemMessage { this.displaySubtitle, this.displayDescription, this.rating, + this.isLive, this.extras, }); @@ -667,6 +671,7 @@ class MediaItemMessage { ? RatingMessage.fromMap( _castMap(raw['rating'] as Map)!) : null, + isLive: raw['isLive'] as bool?, extras: _castMap(raw['extras'] as Map?), ); @@ -685,6 +690,7 @@ class MediaItemMessage { 'displaySubtitle': displaySubtitle, 'displayDescription': displayDescription, 'rating': rating?.toMap(), + 'isLive': isLive, 'extras': extras, }; } @@ -1415,7 +1421,7 @@ class AudioServiceConfigMessage { 'androidNotificationChannelName': androidNotificationChannelName, 'androidNotificationChannelDescription': androidNotificationChannelDescription, - 'notificationColor': notificationColor?.value, + 'notificationColor': notificationColor?._colorValue, 'androidNotificationIcon': androidNotificationIcon, 'androidShowNotificationBadge': androidShowNotificationBadge, 'androidNotificationClickStartsActivity': @@ -1438,3 +1444,14 @@ class AudioServiceConfigMessage { @pragma('vm:prefer-inline') Map? _castMap(Map? map) => map?.cast(); + +/// Reimplements deprecated Color.value. +extension _ColorExtension on Color { + int get _colorValue => + _floatToInt8(a) << 24 | + _floatToInt8(r) << 16 | + _floatToInt8(g) << 8 | + _floatToInt8(b) << 0; + + int _floatToInt8(double x) => (x * 255.0).round() & 0xff; +} diff --git a/audio_service_platform_interface/pubspec.yaml b/audio_service_platform_interface/pubspec.yaml index 4bc0b3ac..fdcc738b 100644 --- a/audio_service_platform_interface/pubspec.yaml +++ b/audio_service_platform_interface/pubspec.yaml @@ -3,7 +3,7 @@ description: A common platform interface for the audio_service plugin. Different homepage: https://github.com/ryanheise/audio_service/tree/master/audio_service_platform_interface # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 0.1.1 +version: 0.1.2 dependencies: flutter: