Skip to content

Commit

Permalink
Merge branch 'minor_interface' into minor
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanheise committed Dec 14, 2024
2 parents 36c65cc + 54fbaad commit a8aaeb6
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 12 deletions.
4 changes: 4 additions & 0 deletions audio_service/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.18.16

* Support MPNowPlayingInfoPropertyIsLiveStream on IOS (@MuradSh, @celsoft).

## 0.18.15

* Add deep link support for FlutterFragmentActivity (@jan-milovanovic).
Expand Down
4 changes: 3 additions & 1 deletion audio_service/darwin/Classes/AudioServicePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -308,7 +311,6 @@ - (void) updateNowPlayingInfo {
// * MPNowPlayingInfoPropertyCurrentPlaybackDate
// * MPNowPlayingInfoPropertyExternalContentIdentifier
// * MPNowPlayingInfoPropertyExternalUserProfileIdentifier
// * MPNowPlayingInfoPropertyIsLiveStream
// * MPNowPlayingInfoPropertyPlaybackProgress
// * MPNowPlayingInfoPropertyPlaybackQueueCount
// * MPNowPlayingInfoPropertyPlaybackQueueIndex
Expand Down
9 changes: 9 additions & 0 deletions audio_service/lib/audio_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -649,6 +652,7 @@ class MediaItem {
this.displaySubtitle,
this.displayDescription,
this.rating,
this.isLive,
this.extras,
});

Expand Down Expand Up @@ -676,6 +680,7 @@ class MediaItem {
displaySubtitle: displaySubtitle,
displayDescription: displayDescription,
rating: rating?._toMessage(),
isLive: isLive,
extras: extras,
);

Expand All @@ -699,6 +704,7 @@ abstract class MediaItemCopyWith {
String? displaySubtitle,
String? displayDescription,
Rating? rating,
bool? isLive,
Map<String, dynamic>? extras,
});
}
Expand Down Expand Up @@ -727,6 +733,7 @@ class _MediaItemCopyWith extends MediaItemCopyWith {
Object? displaySubtitle = _fakeNull,
Object? displayDescription = _fakeNull,
Object? rating = _fakeNull,
Object? isLive = _fakeNull,
Object? extras = _fakeNull,
}) =>
MediaItem(
Expand All @@ -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<String, dynamic>?,
Expand Down Expand Up @@ -3599,6 +3607,7 @@ extension _MediaItemMessageExtension on MediaItemMessage {
displaySubtitle: displaySubtitle,
displayDescription: displayDescription,
rating: rating?.toPlugin(),
isLive: isLive,
extras: extras,
);
}
Expand Down
12 changes: 6 additions & 6 deletions audio_service/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down
10 changes: 7 additions & 3 deletions audio_service_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -642,6 +645,7 @@ class MediaItemMessage {
this.displaySubtitle,
this.displayDescription,
this.rating,
this.isLive,
this.extras,
});

Expand All @@ -667,6 +671,7 @@ class MediaItemMessage {
? RatingMessage.fromMap(
_castMap(raw['rating'] as Map<dynamic, dynamic>)!)
: null,
isLive: raw['isLive'] as bool?,
extras: _castMap(raw['extras'] as Map<dynamic, dynamic>?),
);

Expand All @@ -685,6 +690,7 @@ class MediaItemMessage {
'displaySubtitle': displaySubtitle,
'displayDescription': displayDescription,
'rating': rating?.toMap(),
'isLive': isLive,
'extras': extras,
};
}
Expand Down Expand Up @@ -1415,7 +1421,7 @@ class AudioServiceConfigMessage {
'androidNotificationChannelName': androidNotificationChannelName,
'androidNotificationChannelDescription':
androidNotificationChannelDescription,
'notificationColor': notificationColor?.value,
'notificationColor': notificationColor?._colorValue,
'androidNotificationIcon': androidNotificationIcon,
'androidShowNotificationBadge': androidShowNotificationBadge,
'androidNotificationClickStartsActivity':
Expand All @@ -1438,3 +1444,14 @@ class AudioServiceConfigMessage {
@pragma('vm:prefer-inline')
Map<String, dynamic>? _castMap(Map<dynamic, dynamic>? map) =>
map?.cast<String, dynamic>();

/// 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;
}
2 changes: 1 addition & 1 deletion audio_service_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a8aaeb6

Please sign in to comment.