RemoteMediaClient playerState pigeons

This commit is contained in:
gianlucaparadise 2021-11-30 06:28:00 +01:00
parent 186549c6f0
commit 4134a0ca13
5 changed files with 13 additions and 9 deletions

View file

@ -639,10 +639,10 @@ public class PlatformBridgeApis {
callback.reply(null);
});
}
public void onStatusUpdated(Reply<Void> callback) {
public void onStatusUpdated(Long playerStateRawArg, Reply<Void> callback) {
BasicMessageChannel<Object> channel =
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.CastFlutterApi.onStatusUpdated", getCodec());
channel.send(null, channelReply -> {
channel.send(new ArrayList<Object>(Arrays.asList(playerStateRawArg)), channelReply -> {
callback.reply(null);
});
}

View file

@ -120,7 +120,7 @@ NSObject<FlutterMessageCodec> *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;

View file

@ -586,13 +586,13 @@ NSObject<FlutterMessageCodec> *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);
}];
}

View file

@ -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<Object?> args = (message as List<Object?>?)!;
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;
});
}

View file

@ -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();