From 4134a0ca1339fd5459e1c9ed20bef0ceba3c716a Mon Sep 17 00:00:00 2001 From: gianlucaparadise Date: Tue, 30 Nov 2021 06:28:00 +0100 Subject: [PATCH] RemoteMediaClient playerState pigeons --- .../flutter_cast_framework/PlatformBridgeApis.java | 4 ++-- ios/Classes/PlatformBridgeApis.h | 2 +- ios/Classes/PlatformBridgeApis.m | 4 ++-- lib/src/PlatformBridgeApis.dart | 9 ++++++--- lib/src/PlatformBridgeApisDefinition.dart | 3 ++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/android/src/main/java/com/gianlucaparadise/flutter_cast_framework/PlatformBridgeApis.java b/android/src/main/java/com/gianlucaparadise/flutter_cast_framework/PlatformBridgeApis.java index b1156c0..ec3dcba 100644 --- a/android/src/main/java/com/gianlucaparadise/flutter_cast_framework/PlatformBridgeApis.java +++ b/android/src/main/java/com/gianlucaparadise/flutter_cast_framework/PlatformBridgeApis.java @@ -639,10 +639,10 @@ public class PlatformBridgeApis { callback.reply(null); }); } - public void onStatusUpdated(Reply callback) { + public void onStatusUpdated(Long playerStateRawArg, Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.CastFlutterApi.onStatusUpdated", getCodec()); - channel.send(null, channelReply -> { + channel.send(new ArrayList(Arrays.asList(playerStateRawArg)), channelReply -> { callback.reply(null); }); } diff --git a/ios/Classes/PlatformBridgeApis.h b/ios/Classes/PlatformBridgeApis.h index 715edb8..cd5bbee 100644 --- a/ios/Classes/PlatformBridgeApis.h +++ b/ios/Classes/PlatformBridgeApis.h @@ -120,7 +120,7 @@ NSObject *CastFlutterApiGetCodec(void); - (void)onSessionResumedWithCompletion:(void(^)(NSError *_Nullable))completion; - (void)onSessionResumeFailedWithCompletion:(void(^)(NSError *_Nullable))completion; - (void)onSessionSuspendedWithCompletion:(void(^)(NSError *_Nullable))completion; -- (void)onStatusUpdatedWithCompletion:(void(^)(NSError *_Nullable))completion; +- (void)onStatusUpdatedPlayerStateRaw:(NSNumber *)playerStateRaw completion:(void(^)(NSError *_Nullable))completion; - (void)onMetadataUpdatedWithCompletion:(void(^)(NSError *_Nullable))completion; - (void)onQueueStatusUpdatedWithCompletion:(void(^)(NSError *_Nullable))completion; - (void)onPreloadStatusUpdatedWithCompletion:(void(^)(NSError *_Nullable))completion; diff --git a/ios/Classes/PlatformBridgeApis.m b/ios/Classes/PlatformBridgeApis.m index 229f840..1860306 100644 --- a/ios/Classes/PlatformBridgeApis.m +++ b/ios/Classes/PlatformBridgeApis.m @@ -586,13 +586,13 @@ NSObject *CastFlutterApiGetCodec() { completion(nil); }]; } -- (void)onStatusUpdatedWithCompletion:(void(^)(NSError *_Nullable))completion { +- (void)onStatusUpdatedPlayerStateRaw:(NSNumber *)arg_playerStateRaw completion:(void(^)(NSError *_Nullable))completion { FlutterBasicMessageChannel *channel = [FlutterBasicMessageChannel messageChannelWithName:@"dev.flutter.pigeon.CastFlutterApi.onStatusUpdated" binaryMessenger:self.binaryMessenger codec:CastFlutterApiGetCodec()]; - [channel sendMessage:nil reply:^(id reply) { + [channel sendMessage:@[arg_playerStateRaw] reply:^(id reply) { completion(nil); }]; } diff --git a/lib/src/PlatformBridgeApis.dart b/lib/src/PlatformBridgeApis.dart index 353ece8..a911751 100644 --- a/lib/src/PlatformBridgeApis.dart +++ b/lib/src/PlatformBridgeApis.dart @@ -466,7 +466,7 @@ abstract class CastFlutterApi { void onSessionResumed(); void onSessionResumeFailed(); void onSessionSuspended(); - void onStatusUpdated(); + void onStatusUpdated(int playerStateRaw); void onMetadataUpdated(); void onQueueStatusUpdated(); void onPreloadStatusUpdated(); @@ -644,8 +644,11 @@ abstract class CastFlutterApi { channel.setMessageHandler(null); } else { channel.setMessageHandler((Object? message) async { - // ignore message - api.onStatusUpdated(); + assert(message != null, 'Argument for dev.flutter.pigeon.CastFlutterApi.onStatusUpdated was null.'); + final List args = (message as List?)!; + final int? arg_playerStateRaw = args[0] as int?; + assert(arg_playerStateRaw != null, 'Argument for dev.flutter.pigeon.CastFlutterApi.onStatusUpdated was null, expected non-null int.'); + api.onStatusUpdated(arg_playerStateRaw!); return; }); } diff --git a/lib/src/PlatformBridgeApisDefinition.dart b/lib/src/PlatformBridgeApisDefinition.dart index a0c57e9..a257c1f 100644 --- a/lib/src/PlatformBridgeApisDefinition.dart +++ b/lib/src/PlatformBridgeApisDefinition.dart @@ -247,7 +247,8 @@ abstract class CastFlutterApi { //endregion //region RemoteMediaClient callbacks - void onStatusUpdated(); + // I can't use enum here because of: https://github.com/flutter/flutter/issues/87307 + void onStatusUpdated(int playerStateRaw); void onMetadataUpdated(); void onQueueStatusUpdated(); void onPreloadStatusUpdated();