From 55515f6ef9daf57a2e6c5de969a0187602cd2b90 Mon Sep 17 00:00:00 2001 From: Gabriel Gava Date: Wed, 15 Mar 2023 11:47:18 -0300 Subject: [PATCH] [video_player] Make video player avfoundation seek to async (#3299) [video_player] Make video player avfoundation seek to async --- .../video_player_avfoundation/CHANGELOG.md | 4 + .../integration_test/video_player_test.dart | 5 +- .../ios/RunnerTests/VideoPlayerTests.m | 25 +- .../ios/Classes/FLTVideoPlayerPlugin.m | 22 +- .../ios/Classes/messages.g.h | 6 +- .../ios/Classes/messages.g.m | 253 +++++++------- .../lib/src/messages.g.dart | 327 ++++++++---------- .../pigeons/messages.dart | 1 + .../video_player_avfoundation/pubspec.yaml | 4 +- .../test/avfoundation_video_player_test.dart | 2 +- .../test/test_api.g.dart | 56 +-- 11 files changed, 365 insertions(+), 340 deletions(-) diff --git a/packages/video_player/video_player_avfoundation/CHANGELOG.md b/packages/video_player/video_player_avfoundation/CHANGELOG.md index faabae22fcb9..b2308dd0fe70 100644 --- a/packages/video_player/video_player_avfoundation/CHANGELOG.md +++ b/packages/video_player/video_player_avfoundation/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.4.2 + +* Makes seekTo async and only complete when AVPlayer.seekTo completes. + ## 2.4.1 * Clarifies explanation of endorsement in README. diff --git a/packages/video_player/video_player_avfoundation/example/integration_test/video_player_test.dart b/packages/video_player/video_player_avfoundation/example/integration_test/video_player_test.dart index 574c4f3be506..ae3cd7e3ea89 100644 --- a/packages/video_player/video_player_avfoundation/example/integration_test/video_player_test.dart +++ b/packages/video_player/video_player_avfoundation/example/integration_test/video_player_test.dart @@ -76,10 +76,7 @@ void main() { await controller.seekTo(const Duration(seconds: 3)); - // TODO(stuartmorgan): Switch to _controller.position once seekTo is - // fixed on the native side to wait for completion, so this is testing - // the native code rather than the MiniController position cache. - expect(controller.value.position, const Duration(seconds: 3)); + expect(await controller.position, const Duration(seconds: 3)); }); testWidgets('can be paused', (WidgetTester tester) async { diff --git a/packages/video_player/video_player_avfoundation/example/ios/RunnerTests/VideoPlayerTests.m b/packages/video_player/video_player_avfoundation/example/ios/RunnerTests/VideoPlayerTests.m index f9f66e04bcb3..1ec18e762ae4 100644 --- a/packages/video_player/video_player_avfoundation/example/ios/RunnerTests/VideoPlayerTests.m +++ b/packages/video_player/video_player_avfoundation/example/ios/RunnerTests/VideoPlayerTests.m @@ -12,6 +12,7 @@ @interface FLTVideoPlayer : NSObject @property(readonly, nonatomic) AVPlayer *player; @property(readonly, nonatomic) AVPlayerLayer *playerLayer; +@property(readonly, nonatomic) int64_t position; @end @interface FLTVideoPlayerPlugin (Test) @@ -106,10 +107,30 @@ - (void)testSeekToInvokesTextureFrameAvailableOnTextureRegistry { OCMStub([partialRegistrar textures]).andReturn(mockTextureRegistry); FLTVideoPlayerPlugin *videoPlayerPlugin = (FLTVideoPlayerPlugin *)[[FLTVideoPlayerPlugin alloc] initWithRegistrar:partialRegistrar]; - FLTPositionMessage *message = [FLTPositionMessage makeWithTextureId:@101 position:@0]; + FlutterError *error; - [videoPlayerPlugin seekTo:message error:&error]; + [videoPlayerPlugin initialize:&error]; + XCTAssertNil(error); + FLTCreateMessage *create = [FLTCreateMessage + makeWithAsset:nil + uri:@"https://flutter.github.io/assets-for-api-docs/assets/videos/hls/bee.m3u8" + packageName:nil + formatHint:nil + httpHeaders:@{}]; + FLTTextureMessage *textureMessage = [videoPlayerPlugin create:create error:&error]; + NSNumber *textureId = textureMessage.textureId; + + XCTestExpectation *initializedExpectation = [self expectationWithDescription:@"seekTo completes"]; + FLTPositionMessage *message = [FLTPositionMessage makeWithTextureId:textureId position:@1234]; + [videoPlayerPlugin seekTo:message + completion:^(FlutterError *_Nullable error) { + [initializedExpectation fulfill]; + }]; + [self waitForExpectationsWithTimeout:30.0 handler:nil]; OCMVerify([mockTextureRegistry textureFrameAvailable:message.textureId.intValue]); + + FLTVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureId]; + XCTAssertEqual([player position], 1234); } - (void)testDeregistersFromPlayer { diff --git a/packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m b/packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m index 3b066769621c..ce0a12154c2f 100644 --- a/packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m +++ b/packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m @@ -403,13 +403,11 @@ - (int64_t)duration { return FLTCMTimeToMillis([[[_player currentItem] asset] duration]); } -- (void)seekTo:(int)location { - // TODO(stuartmorgan): Update this to use completionHandler: to only return - // once the seek operation is complete once the Pigeon API is updated to a - // version that handles async calls. +- (void)seekTo:(int)location completionHandler:(void (^)(BOOL))completionHandler { [_player seekToTime:CMTimeMake(location, 1000) - toleranceBefore:kCMTimeZero - toleranceAfter:kCMTimeZero]; + toleranceBefore:kCMTimeZero + toleranceAfter:kCMTimeZero + completionHandler:completionHandler]; } - (void)setIsLooping:(BOOL)isLooping { @@ -636,10 +634,16 @@ - (FLTPositionMessage *)position:(FLTTextureMessage *)input error:(FlutterError return result; } -- (void)seekTo:(FLTPositionMessage *)input error:(FlutterError **)error { +- (void)seekTo:(FLTPositionMessage *)input + completion:(void (^)(FlutterError *_Nullable))completion { FLTVideoPlayer *player = self.playersByTextureId[input.textureId]; - [player seekTo:input.position.intValue]; - [self.registry textureFrameAvailable:input.textureId.intValue]; + [player seekTo:input.position.intValue + completionHandler:^(BOOL finished) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self.registry textureFrameAvailable:input.textureId.intValue]; + completion(nil); + }); + }]; } - (void)pause:(FLTTextureMessage *)input error:(FlutterError **)error { diff --git a/packages/video_player/video_player_avfoundation/ios/Classes/messages.g.h b/packages/video_player/video_player_avfoundation/ios/Classes/messages.g.h index 130d4849f372..f5152842e4f6 100644 --- a/packages/video_player/video_player_avfoundation/ios/Classes/messages.g.h +++ b/packages/video_player/video_player_avfoundation/ios/Classes/messages.g.h @@ -1,9 +1,11 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v2.0.1), do not edit directly. +// Autogenerated from Pigeon (v8.0.0), do not edit directly. // See also: https://pub.dev/packages/pigeon + #import + @protocol FlutterBinaryMessenger; @protocol FlutterMessageCodec; @class FlutterError; @@ -97,7 +99,7 @@ NSObject *FLTAVFoundationVideoPlayerApiGetCodec(void); /// @return `nil` only when `error != nil`. - (nullable FLTPositionMessage *)position:(FLTTextureMessage *)msg error:(FlutterError *_Nullable *_Nonnull)error; -- (void)seekTo:(FLTPositionMessage *)msg error:(FlutterError *_Nullable *_Nonnull)error; +- (void)seekTo:(FLTPositionMessage *)msg completion:(void (^)(FlutterError *_Nullable))completion; - (void)pause:(FLTTextureMessage *)msg error:(FlutterError *_Nullable *_Nonnull)error; - (void)setMixWithOthers:(FLTMixWithOthersMessage *)msg error:(FlutterError *_Nullable *_Nonnull)error; diff --git a/packages/video_player/video_player_avfoundation/ios/Classes/messages.g.m b/packages/video_player/video_player_avfoundation/ios/Classes/messages.g.m index d82dc386878d..23cc2b5d60cb 100644 --- a/packages/video_player/video_player_avfoundation/ios/Classes/messages.g.m +++ b/packages/video_player/video_player_avfoundation/ios/Classes/messages.g.m @@ -1,8 +1,9 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v2.0.1), do not edit directly. +// Autogenerated from Pigeon (v8.0.0), do not edit directly. // See also: https://pub.dev/packages/pigeon + #import "messages.g.h" #import @@ -10,23 +11,13 @@ #error File requires ARC to be enabled. #endif -static NSDictionary *wrapResult(id result, FlutterError *error) { - NSDictionary *errorDict = (NSDictionary *)[NSNull null]; +static NSArray *wrapResult(id result, FlutterError *error) { if (error) { - errorDict = @{ - @"code" : (error.code ? error.code : [NSNull null]), - @"message" : (error.message ? error.message : [NSNull null]), - @"details" : (error.details ? error.details : [NSNull null]), - }; + return @[ + error.code ?: [NSNull null], error.message ?: [NSNull null], error.details ?: [NSNull null] + ]; } - return @{ - @"result" : (result ? result : [NSNull null]), - @"error" : errorDict, - }; -} -static id GetNullableObject(NSDictionary *dict, id key) { - id result = dict[key]; - return (result == [NSNull null]) ? nil : result; + return @[ result ?: [NSNull null] ]; } static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { id result = array[key]; @@ -34,32 +25,45 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) { } @interface FLTTextureMessage () -+ (FLTTextureMessage *)fromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (FLTTextureMessage *)fromList:(NSArray *)list; ++ (nullable FLTTextureMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end + @interface FLTLoopingMessage () -+ (FLTLoopingMessage *)fromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (FLTLoopingMessage *)fromList:(NSArray *)list; ++ (nullable FLTLoopingMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end + @interface FLTVolumeMessage () -+ (FLTVolumeMessage *)fromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (FLTVolumeMessage *)fromList:(NSArray *)list; ++ (nullable FLTVolumeMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end + @interface FLTPlaybackSpeedMessage () -+ (FLTPlaybackSpeedMessage *)fromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (FLTPlaybackSpeedMessage *)fromList:(NSArray *)list; ++ (nullable FLTPlaybackSpeedMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end + @interface FLTPositionMessage () -+ (FLTPositionMessage *)fromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (FLTPositionMessage *)fromList:(NSArray *)list; ++ (nullable FLTPositionMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end + @interface FLTCreateMessage () -+ (FLTCreateMessage *)fromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (FLTCreateMessage *)fromList:(NSArray *)list; ++ (nullable FLTCreateMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end + @interface FLTMixWithOthersMessage () -+ (FLTMixWithOthersMessage *)fromMap:(NSDictionary *)dict; -- (NSDictionary *)toMap; ++ (FLTMixWithOthersMessage *)fromList:(NSArray *)list; ++ (nullable FLTMixWithOthersMessage *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; @end @implementation FLTTextureMessage @@ -68,16 +72,19 @@ + (instancetype)makeWithTextureId:(NSNumber *)textureId { pigeonResult.textureId = textureId; return pigeonResult; } -+ (FLTTextureMessage *)fromMap:(NSDictionary *)dict { ++ (FLTTextureMessage *)fromList:(NSArray *)list { FLTTextureMessage *pigeonResult = [[FLTTextureMessage alloc] init]; - pigeonResult.textureId = GetNullableObject(dict, @"textureId"); + pigeonResult.textureId = GetNullableObjectAtIndex(list, 0); NSAssert(pigeonResult.textureId != nil, @""); return pigeonResult; } -- (NSDictionary *)toMap { - return - [NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), - @"textureId", nil]; ++ (nullable FLTTextureMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FLTTextureMessage fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + (self.textureId ?: [NSNull null]), + ]; } @end @@ -88,19 +95,22 @@ + (instancetype)makeWithTextureId:(NSNumber *)textureId isLooping:(NSNumber *)is pigeonResult.isLooping = isLooping; return pigeonResult; } -+ (FLTLoopingMessage *)fromMap:(NSDictionary *)dict { ++ (FLTLoopingMessage *)fromList:(NSArray *)list { FLTLoopingMessage *pigeonResult = [[FLTLoopingMessage alloc] init]; - pigeonResult.textureId = GetNullableObject(dict, @"textureId"); + pigeonResult.textureId = GetNullableObjectAtIndex(list, 0); NSAssert(pigeonResult.textureId != nil, @""); - pigeonResult.isLooping = GetNullableObject(dict, @"isLooping"); + pigeonResult.isLooping = GetNullableObjectAtIndex(list, 1); NSAssert(pigeonResult.isLooping != nil, @""); return pigeonResult; } -- (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", - (self.isLooping ? self.isLooping : [NSNull null]), @"isLooping", - nil]; ++ (nullable FLTLoopingMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FLTLoopingMessage fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + (self.textureId ?: [NSNull null]), + (self.isLooping ?: [NSNull null]), + ]; } @end @@ -111,18 +121,22 @@ + (instancetype)makeWithTextureId:(NSNumber *)textureId volume:(NSNumber *)volum pigeonResult.volume = volume; return pigeonResult; } -+ (FLTVolumeMessage *)fromMap:(NSDictionary *)dict { ++ (FLTVolumeMessage *)fromList:(NSArray *)list { FLTVolumeMessage *pigeonResult = [[FLTVolumeMessage alloc] init]; - pigeonResult.textureId = GetNullableObject(dict, @"textureId"); + pigeonResult.textureId = GetNullableObjectAtIndex(list, 0); NSAssert(pigeonResult.textureId != nil, @""); - pigeonResult.volume = GetNullableObject(dict, @"volume"); + pigeonResult.volume = GetNullableObjectAtIndex(list, 1); NSAssert(pigeonResult.volume != nil, @""); return pigeonResult; } -- (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", - (self.volume ? self.volume : [NSNull null]), @"volume", nil]; ++ (nullable FLTVolumeMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FLTVolumeMessage fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + (self.textureId ?: [NSNull null]), + (self.volume ?: [NSNull null]), + ]; } @end @@ -133,18 +147,22 @@ + (instancetype)makeWithTextureId:(NSNumber *)textureId speed:(NSNumber *)speed pigeonResult.speed = speed; return pigeonResult; } -+ (FLTPlaybackSpeedMessage *)fromMap:(NSDictionary *)dict { ++ (FLTPlaybackSpeedMessage *)fromList:(NSArray *)list { FLTPlaybackSpeedMessage *pigeonResult = [[FLTPlaybackSpeedMessage alloc] init]; - pigeonResult.textureId = GetNullableObject(dict, @"textureId"); + pigeonResult.textureId = GetNullableObjectAtIndex(list, 0); NSAssert(pigeonResult.textureId != nil, @""); - pigeonResult.speed = GetNullableObject(dict, @"speed"); + pigeonResult.speed = GetNullableObjectAtIndex(list, 1); NSAssert(pigeonResult.speed != nil, @""); return pigeonResult; } -- (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", - (self.speed ? self.speed : [NSNull null]), @"speed", nil]; ++ (nullable FLTPlaybackSpeedMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FLTPlaybackSpeedMessage fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + (self.textureId ?: [NSNull null]), + (self.speed ?: [NSNull null]), + ]; } @end @@ -155,19 +173,22 @@ + (instancetype)makeWithTextureId:(NSNumber *)textureId position:(NSNumber *)pos pigeonResult.position = position; return pigeonResult; } -+ (FLTPositionMessage *)fromMap:(NSDictionary *)dict { ++ (FLTPositionMessage *)fromList:(NSArray *)list { FLTPositionMessage *pigeonResult = [[FLTPositionMessage alloc] init]; - pigeonResult.textureId = GetNullableObject(dict, @"textureId"); + pigeonResult.textureId = GetNullableObjectAtIndex(list, 0); NSAssert(pigeonResult.textureId != nil, @""); - pigeonResult.position = GetNullableObject(dict, @"position"); + pigeonResult.position = GetNullableObjectAtIndex(list, 1); NSAssert(pigeonResult.position != nil, @""); return pigeonResult; } -- (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId", - (self.position ? self.position : [NSNull null]), @"position", - nil]; ++ (nullable FLTPositionMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FLTPositionMessage fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + (self.textureId ?: [NSNull null]), + (self.position ?: [NSNull null]), + ]; } @end @@ -185,26 +206,27 @@ + (instancetype)makeWithAsset:(nullable NSString *)asset pigeonResult.httpHeaders = httpHeaders; return pigeonResult; } -+ (FLTCreateMessage *)fromMap:(NSDictionary *)dict { ++ (FLTCreateMessage *)fromList:(NSArray *)list { FLTCreateMessage *pigeonResult = [[FLTCreateMessage alloc] init]; - pigeonResult.asset = GetNullableObject(dict, @"asset"); - pigeonResult.uri = GetNullableObject(dict, @"uri"); - pigeonResult.packageName = GetNullableObject(dict, @"packageName"); - pigeonResult.formatHint = GetNullableObject(dict, @"formatHint"); - pigeonResult.httpHeaders = GetNullableObject(dict, @"httpHeaders"); + pigeonResult.asset = GetNullableObjectAtIndex(list, 0); + pigeonResult.uri = GetNullableObjectAtIndex(list, 1); + pigeonResult.packageName = GetNullableObjectAtIndex(list, 2); + pigeonResult.formatHint = GetNullableObjectAtIndex(list, 3); + pigeonResult.httpHeaders = GetNullableObjectAtIndex(list, 4); NSAssert(pigeonResult.httpHeaders != nil, @""); return pigeonResult; } -- (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.asset ? self.asset : [NSNull null]), @"asset", - (self.uri ? self.uri : [NSNull null]), @"uri", - (self.packageName ? self.packageName : [NSNull null]), - @"packageName", - (self.formatHint ? self.formatHint : [NSNull null]), - @"formatHint", - (self.httpHeaders ? self.httpHeaders : [NSNull null]), - @"httpHeaders", nil]; ++ (nullable FLTCreateMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FLTCreateMessage fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + (self.asset ?: [NSNull null]), + (self.uri ?: [NSNull null]), + (self.packageName ?: [NSNull null]), + (self.formatHint ?: [NSNull null]), + (self.httpHeaders ?: [NSNull null]), + ]; } @end @@ -214,16 +236,19 @@ + (instancetype)makeWithMixWithOthers:(NSNumber *)mixWithOthers { pigeonResult.mixWithOthers = mixWithOthers; return pigeonResult; } -+ (FLTMixWithOthersMessage *)fromMap:(NSDictionary *)dict { ++ (FLTMixWithOthersMessage *)fromList:(NSArray *)list { FLTMixWithOthersMessage *pigeonResult = [[FLTMixWithOthersMessage alloc] init]; - pigeonResult.mixWithOthers = GetNullableObject(dict, @"mixWithOthers"); + pigeonResult.mixWithOthers = GetNullableObjectAtIndex(list, 0); NSAssert(pigeonResult.mixWithOthers != nil, @""); return pigeonResult; } -- (NSDictionary *)toMap { - return [NSDictionary - dictionaryWithObjectsAndKeys:(self.mixWithOthers ? self.mixWithOthers : [NSNull null]), - @"mixWithOthers", nil]; ++ (nullable FLTMixWithOthersMessage *)nullableFromList:(NSArray *)list { + return (list) ? [FLTMixWithOthersMessage fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + (self.mixWithOthers ?: [NSNull null]), + ]; } @end @@ -233,26 +258,19 @@ @implementation FLTAVFoundationVideoPlayerApiCodecReader - (nullable id)readValueOfType:(UInt8)type { switch (type) { case 128: - return [FLTCreateMessage fromMap:[self readValue]]; - + return [FLTCreateMessage fromList:[self readValue]]; case 129: - return [FLTLoopingMessage fromMap:[self readValue]]; - + return [FLTLoopingMessage fromList:[self readValue]]; case 130: - return [FLTMixWithOthersMessage fromMap:[self readValue]]; - + return [FLTMixWithOthersMessage fromList:[self readValue]]; case 131: - return [FLTPlaybackSpeedMessage fromMap:[self readValue]]; - + return [FLTPlaybackSpeedMessage fromList:[self readValue]]; case 132: - return [FLTPositionMessage fromMap:[self readValue]]; - + return [FLTPositionMessage fromList:[self readValue]]; case 133: - return [FLTTextureMessage fromMap:[self readValue]]; - + return [FLTTextureMessage fromList:[self readValue]]; case 134: - return [FLTVolumeMessage fromMap:[self readValue]]; - + return [FLTVolumeMessage fromList:[self readValue]]; default: return [super readValueOfType:type]; } @@ -265,25 +283,25 @@ @implementation FLTAVFoundationVideoPlayerApiCodecWriter - (void)writeValue:(id)value { if ([value isKindOfClass:[FLTCreateMessage class]]) { [self writeByte:128]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FLTLoopingMessage class]]) { [self writeByte:129]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FLTMixWithOthersMessage class]]) { [self writeByte:130]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FLTPlaybackSpeedMessage class]]) { [self writeByte:131]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FLTPositionMessage class]]) { [self writeByte:132]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FLTTextureMessage class]]) { [self writeByte:133]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else if ([value isKindOfClass:[FLTVolumeMessage class]]) { [self writeByte:134]; - [self writeValue:[value toMap]]; + [self writeValue:[value toList]]; } else { [super writeValue:value]; } @@ -302,8 +320,8 @@ - (FlutterStandardReader *)readerWithData:(NSData *)data { @end NSObject *FLTAVFoundationVideoPlayerApiGetCodec() { - static dispatch_once_t sPred = 0; static FlutterStandardMessageCodec *sSharedObject = nil; + static dispatch_once_t sPred = 0; dispatch_once(&sPred, ^{ FLTAVFoundationVideoPlayerApiCodecReaderWriter *readerWriter = [[FLTAVFoundationVideoPlayerApiCodecReaderWriter alloc] init]; @@ -484,16 +502,17 @@ void FLTAVFoundationVideoPlayerApiSetup(id binaryMesseng binaryMessenger:binaryMessenger codec:FLTAVFoundationVideoPlayerApiGetCodec()]; if (api) { - NSCAssert( - [api respondsToSelector:@selector(seekTo:error:)], - @"FLTAVFoundationVideoPlayerApi api (%@) doesn't respond to @selector(seekTo:error:)", - api); + NSCAssert([api respondsToSelector:@selector(seekTo:completion:)], + @"FLTAVFoundationVideoPlayerApi api (%@) doesn't respond to " + @"@selector(seekTo:completion:)", + api); [channel setMessageHandler:^(id _Nullable message, FlutterReply callback) { NSArray *args = message; FLTPositionMessage *arg_msg = GetNullableObjectAtIndex(args, 0); - FlutterError *error; - [api seekTo:arg_msg error:&error]; - callback(wrapResult(nil, error)); + [api seekTo:arg_msg + completion:^(FlutterError *_Nullable error) { + callback(wrapResult(nil, error)); + }]; }]; } else { [channel setMessageHandler:nil]; diff --git a/packages/video_player/video_player_avfoundation/lib/src/messages.g.dart b/packages/video_player/video_player_avfoundation/lib/src/messages.g.dart index a745c66322d4..acc59276964f 100644 --- a/packages/video_player/video_player_avfoundation/lib/src/messages.g.dart +++ b/packages/video_player/video_player_avfoundation/lib/src/messages.g.dart @@ -1,14 +1,14 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v2.0.1), do not edit directly. +// Autogenerated from Pigeon (v8.0.0), do not edit directly. // See also: https://pub.dev/packages/pigeon -// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name -// @dart = 2.12 +// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, unused_shown_name, unnecessary_import + import 'dart:async'; -import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; -import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer; +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; import 'package:flutter/services.dart'; class TextureMessage { @@ -19,15 +19,15 @@ class TextureMessage { int textureId; Object encode() { - final Map pigeonMap = {}; - pigeonMap['textureId'] = textureId; - return pigeonMap; + return [ + textureId, + ]; } - static TextureMessage decode(Object message) { - final Map pigeonMap = message as Map; + static TextureMessage decode(Object result) { + result as List; return TextureMessage( - textureId: pigeonMap['textureId']! as int, + textureId: result[0]! as int, ); } } @@ -39,20 +39,21 @@ class LoopingMessage { }); int textureId; + bool isLooping; Object encode() { - final Map pigeonMap = {}; - pigeonMap['textureId'] = textureId; - pigeonMap['isLooping'] = isLooping; - return pigeonMap; + return [ + textureId, + isLooping, + ]; } - static LoopingMessage decode(Object message) { - final Map pigeonMap = message as Map; + static LoopingMessage decode(Object result) { + result as List; return LoopingMessage( - textureId: pigeonMap['textureId']! as int, - isLooping: pigeonMap['isLooping']! as bool, + textureId: result[0]! as int, + isLooping: result[1]! as bool, ); } } @@ -64,20 +65,21 @@ class VolumeMessage { }); int textureId; + double volume; Object encode() { - final Map pigeonMap = {}; - pigeonMap['textureId'] = textureId; - pigeonMap['volume'] = volume; - return pigeonMap; + return [ + textureId, + volume, + ]; } - static VolumeMessage decode(Object message) { - final Map pigeonMap = message as Map; + static VolumeMessage decode(Object result) { + result as List; return VolumeMessage( - textureId: pigeonMap['textureId']! as int, - volume: pigeonMap['volume']! as double, + textureId: result[0]! as int, + volume: result[1]! as double, ); } } @@ -89,20 +91,21 @@ class PlaybackSpeedMessage { }); int textureId; + double speed; Object encode() { - final Map pigeonMap = {}; - pigeonMap['textureId'] = textureId; - pigeonMap['speed'] = speed; - return pigeonMap; + return [ + textureId, + speed, + ]; } - static PlaybackSpeedMessage decode(Object message) { - final Map pigeonMap = message as Map; + static PlaybackSpeedMessage decode(Object result) { + result as List; return PlaybackSpeedMessage( - textureId: pigeonMap['textureId']! as int, - speed: pigeonMap['speed']! as double, + textureId: result[0]! as int, + speed: result[1]! as double, ); } } @@ -114,20 +117,21 @@ class PositionMessage { }); int textureId; + int position; Object encode() { - final Map pigeonMap = {}; - pigeonMap['textureId'] = textureId; - pigeonMap['position'] = position; - return pigeonMap; + return [ + textureId, + position, + ]; } - static PositionMessage decode(Object message) { - final Map pigeonMap = message as Map; + static PositionMessage decode(Object result) { + result as List; return PositionMessage( - textureId: pigeonMap['textureId']! as int, - position: pigeonMap['position']! as int, + textureId: result[0]! as int, + position: result[1]! as int, ); } } @@ -142,30 +146,34 @@ class CreateMessage { }); String? asset; + String? uri; + String? packageName; + String? formatHint; + Map httpHeaders; Object encode() { - final Map pigeonMap = {}; - pigeonMap['asset'] = asset; - pigeonMap['uri'] = uri; - pigeonMap['packageName'] = packageName; - pigeonMap['formatHint'] = formatHint; - pigeonMap['httpHeaders'] = httpHeaders; - return pigeonMap; + return [ + asset, + uri, + packageName, + formatHint, + httpHeaders, + ]; } - static CreateMessage decode(Object message) { - final Map pigeonMap = message as Map; + static CreateMessage decode(Object result) { + result as List; return CreateMessage( - asset: pigeonMap['asset'] as String?, - uri: pigeonMap['uri'] as String?, - packageName: pigeonMap['packageName'] as String?, - formatHint: pigeonMap['formatHint'] as String?, - httpHeaders: (pigeonMap['httpHeaders'] as Map?)! - .cast(), + asset: result[0] as String?, + uri: result[1] as String?, + packageName: result[2] as String?, + formatHint: result[3] as String?, + httpHeaders: + (result[4] as Map?)!.cast(), ); } } @@ -178,15 +186,15 @@ class MixWithOthersMessage { bool mixWithOthers; Object encode() { - final Map pigeonMap = {}; - pigeonMap['mixWithOthers'] = mixWithOthers; - return pigeonMap; + return [ + mixWithOthers, + ]; } - static MixWithOthersMessage decode(Object message) { - final Map pigeonMap = message as Map; + static MixWithOthersMessage decode(Object result) { + result as List; return MixWithOthersMessage( - mixWithOthers: pigeonMap['mixWithOthers']! as bool, + mixWithOthers: result[0]! as bool, ); } } @@ -226,25 +234,18 @@ class _AVFoundationVideoPlayerApiCodec extends StandardMessageCodec { switch (type) { case 128: return CreateMessage.decode(readValue(buffer)!); - case 129: return LoopingMessage.decode(readValue(buffer)!); - case 130: return MixWithOthersMessage.decode(readValue(buffer)!); - case 131: return PlaybackSpeedMessage.decode(readValue(buffer)!); - case 132: return PositionMessage.decode(readValue(buffer)!); - case 133: return TextureMessage.decode(readValue(buffer)!); - case 134: return VolumeMessage.decode(readValue(buffer)!); - default: return super.readValueOfType(type, buffer); } @@ -257,7 +258,6 @@ class AVFoundationVideoPlayerApi { /// BinaryMessenger will be used which routes to the host platform. AVFoundationVideoPlayerApi({BinaryMessenger? binaryMessenger}) : _binaryMessenger = binaryMessenger; - final BinaryMessenger? _binaryMessenger; static const MessageCodec codec = _AVFoundationVideoPlayerApiCodec(); @@ -266,20 +266,17 @@ class AVFoundationVideoPlayerApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.AVFoundationVideoPlayerApi.initialize', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send(null) as Map?; - if (replyMap == null) { + final List? replyList = await channel.send(null) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; @@ -290,28 +287,26 @@ class AVFoundationVideoPlayerApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.AVFoundationVideoPlayerApi.create', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_msg]) as Map?; - if (replyMap == null) { + final List? replyList = + await channel.send([arg_msg]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); - } else if (replyMap['result'] == null) { + } else if (replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyMap['result'] as TextureMessage?)!; + return (replyList[0] as TextureMessage?)!; } } @@ -319,20 +314,18 @@ class AVFoundationVideoPlayerApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.AVFoundationVideoPlayerApi.dispose', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_msg]) as Map?; - if (replyMap == null) { + final List? replyList = + await channel.send([arg_msg]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; @@ -343,20 +336,18 @@ class AVFoundationVideoPlayerApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.AVFoundationVideoPlayerApi.setLooping', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_msg]) as Map?; - if (replyMap == null) { + final List? replyList = + await channel.send([arg_msg]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; @@ -367,20 +358,18 @@ class AVFoundationVideoPlayerApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.AVFoundationVideoPlayerApi.setVolume', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_msg]) as Map?; - if (replyMap == null) { + final List? replyList = + await channel.send([arg_msg]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; @@ -391,20 +380,18 @@ class AVFoundationVideoPlayerApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.AVFoundationVideoPlayerApi.setPlaybackSpeed', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_msg]) as Map?; - if (replyMap == null) { + final List? replyList = + await channel.send([arg_msg]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; @@ -415,20 +402,18 @@ class AVFoundationVideoPlayerApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.AVFoundationVideoPlayerApi.play', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_msg]) as Map?; - if (replyMap == null) { + final List? replyList = + await channel.send([arg_msg]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; @@ -439,28 +424,26 @@ class AVFoundationVideoPlayerApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.AVFoundationVideoPlayerApi.position', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_msg]) as Map?; - if (replyMap == null) { + final List? replyList = + await channel.send([arg_msg]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); - } else if (replyMap['result'] == null) { + } else if (replyList[0] == null) { throw PlatformException( code: 'null-error', message: 'Host platform returned null value for non-null return value.', ); } else { - return (replyMap['result'] as PositionMessage?)!; + return (replyList[0] as PositionMessage?)!; } } @@ -468,20 +451,18 @@ class AVFoundationVideoPlayerApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.AVFoundationVideoPlayerApi.seekTo', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_msg]) as Map?; - if (replyMap == null) { + final List? replyList = + await channel.send([arg_msg]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; @@ -492,20 +473,18 @@ class AVFoundationVideoPlayerApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.AVFoundationVideoPlayerApi.pause', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_msg]) as Map?; - if (replyMap == null) { + final List? replyList = + await channel.send([arg_msg]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; @@ -516,20 +495,18 @@ class AVFoundationVideoPlayerApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.AVFoundationVideoPlayerApi.setMixWithOthers', codec, binaryMessenger: _binaryMessenger); - final Map? replyMap = - await channel.send([arg_msg]) as Map?; - if (replyMap == null) { + final List? replyList = + await channel.send([arg_msg]) as List?; + if (replyList == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', ); - } else if (replyMap['error'] != null) { - final Map error = - (replyMap['error'] as Map?)!; + } else if (replyList.length > 1) { throw PlatformException( - code: (error['code'] as String?)!, - message: error['message'] as String?, - details: error['details'], + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], ); } else { return; diff --git a/packages/video_player/video_player_avfoundation/pigeons/messages.dart b/packages/video_player/video_player_avfoundation/pigeons/messages.dart index 695ff34e3ebd..f4418dbcac65 100644 --- a/packages/video_player/video_player_avfoundation/pigeons/messages.dart +++ b/packages/video_player/video_player_avfoundation/pigeons/messages.dart @@ -75,6 +75,7 @@ abstract class AVFoundationVideoPlayerApi { void play(TextureMessage msg); @ObjCSelector('position:') PositionMessage position(TextureMessage msg); + @async @ObjCSelector('seekTo:') void seekTo(PositionMessage msg); @ObjCSelector('pause:') diff --git a/packages/video_player/video_player_avfoundation/pubspec.yaml b/packages/video_player/video_player_avfoundation/pubspec.yaml index 7618a8e76f8e..cece86e96538 100644 --- a/packages/video_player/video_player_avfoundation/pubspec.yaml +++ b/packages/video_player/video_player_avfoundation/pubspec.yaml @@ -2,7 +2,7 @@ name: video_player_avfoundation description: iOS implementation of the video_player plugin. repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player_avfoundation issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22 -version: 2.4.1 +version: 2.4.2 environment: sdk: ">=2.18.0 <3.0.0" @@ -24,4 +24,4 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - pigeon: ^2.0.1 + pigeon: ^8.0.0 diff --git a/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart b/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart index c01373f05424..a0f37e2175f8 100644 --- a/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart +++ b/packages/video_player/video_player_avfoundation/test/avfoundation_video_player_test.dart @@ -68,7 +68,7 @@ class _ApiLogger implements TestHostVideoPlayerApi { } @override - void seekTo(PositionMessage arg) { + Future seekTo(PositionMessage arg) async { log.add('seekTo'); positionMessage = arg; } diff --git a/packages/video_player/video_player_avfoundation/test/test_api.g.dart b/packages/video_player/video_player_avfoundation/test/test_api.g.dart index c8f7bbd026a5..750ddee7ecdb 100644 --- a/packages/video_player/video_player_avfoundation/test/test_api.g.dart +++ b/packages/video_player/video_player_avfoundation/test/test_api.g.dart @@ -1,20 +1,16 @@ // Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v2.0.1), do not edit directly. +// Autogenerated from Pigeon (v8.0.0), do not edit directly. // See also: https://pub.dev/packages/pigeon -// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis +// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, unnecessary_import // ignore_for_file: avoid_relative_lib_imports -// @dart = 2.12 import 'dart:async'; -import 'dart:typed_data' show Uint8List, Int32List, Int64List, Float64List; -// TODO(a14n): remove this import once Flutter 3.1 or later reaches stable (including flutter/flutter#106316) -// ignore: unnecessary_import -import 'package:flutter/foundation.dart' show WriteBuffer, ReadBuffer; +import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; +import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -// TODO(gaaclarke): The following output had to be tweaked from a relative path to a uri. import 'package:video_player_avfoundation/src/messages.g.dart'; class _TestHostVideoPlayerApiCodec extends StandardMessageCodec { @@ -52,25 +48,18 @@ class _TestHostVideoPlayerApiCodec extends StandardMessageCodec { switch (type) { case 128: return CreateMessage.decode(readValue(buffer)!); - case 129: return LoopingMessage.decode(readValue(buffer)!); - case 130: return MixWithOthersMessage.decode(readValue(buffer)!); - case 131: return PlaybackSpeedMessage.decode(readValue(buffer)!); - case 132: return PositionMessage.decode(readValue(buffer)!); - case 133: return TextureMessage.decode(readValue(buffer)!); - case 134: return VolumeMessage.decode(readValue(buffer)!); - default: return super.readValueOfType(type, buffer); } @@ -81,16 +70,27 @@ abstract class TestHostVideoPlayerApi { static const MessageCodec codec = _TestHostVideoPlayerApiCodec(); void initialize(); + TextureMessage create(CreateMessage msg); + void dispose(TextureMessage msg); + void setLooping(LoopingMessage msg); + void setVolume(VolumeMessage msg); + void setPlaybackSpeed(PlaybackSpeedMessage msg); + void play(TextureMessage msg); + PositionMessage position(TextureMessage msg); - void seekTo(PositionMessage msg); + + Future seekTo(PositionMessage msg); + void pause(TextureMessage msg); + void setMixWithOthers(MixWithOthersMessage msg); + static void setup(TestHostVideoPlayerApi? api, {BinaryMessenger? binaryMessenger}) { { @@ -103,7 +103,7 @@ abstract class TestHostVideoPlayerApi { channel.setMockMessageHandler((Object? message) async { // ignore message api.initialize(); - return {}; + return []; }); } } @@ -122,7 +122,7 @@ abstract class TestHostVideoPlayerApi { assert(arg_msg != null, 'Argument for dev.flutter.pigeon.AVFoundationVideoPlayerApi.create was null, expected non-null CreateMessage.'); final TextureMessage output = api.create(arg_msg!); - return {'result': output}; + return [output]; }); } } @@ -141,7 +141,7 @@ abstract class TestHostVideoPlayerApi { assert(arg_msg != null, 'Argument for dev.flutter.pigeon.AVFoundationVideoPlayerApi.dispose was null, expected non-null TextureMessage.'); api.dispose(arg_msg!); - return {}; + return []; }); } } @@ -160,7 +160,7 @@ abstract class TestHostVideoPlayerApi { assert(arg_msg != null, 'Argument for dev.flutter.pigeon.AVFoundationVideoPlayerApi.setLooping was null, expected non-null LoopingMessage.'); api.setLooping(arg_msg!); - return {}; + return []; }); } } @@ -179,7 +179,7 @@ abstract class TestHostVideoPlayerApi { assert(arg_msg != null, 'Argument for dev.flutter.pigeon.AVFoundationVideoPlayerApi.setVolume was null, expected non-null VolumeMessage.'); api.setVolume(arg_msg!); - return {}; + return []; }); } } @@ -200,7 +200,7 @@ abstract class TestHostVideoPlayerApi { assert(arg_msg != null, 'Argument for dev.flutter.pigeon.AVFoundationVideoPlayerApi.setPlaybackSpeed was null, expected non-null PlaybackSpeedMessage.'); api.setPlaybackSpeed(arg_msg!); - return {}; + return []; }); } } @@ -219,7 +219,7 @@ abstract class TestHostVideoPlayerApi { assert(arg_msg != null, 'Argument for dev.flutter.pigeon.AVFoundationVideoPlayerApi.play was null, expected non-null TextureMessage.'); api.play(arg_msg!); - return {}; + return []; }); } } @@ -238,7 +238,7 @@ abstract class TestHostVideoPlayerApi { assert(arg_msg != null, 'Argument for dev.flutter.pigeon.AVFoundationVideoPlayerApi.position was null, expected non-null TextureMessage.'); final PositionMessage output = api.position(arg_msg!); - return {'result': output}; + return [output]; }); } } @@ -256,8 +256,8 @@ abstract class TestHostVideoPlayerApi { final PositionMessage? arg_msg = (args[0] as PositionMessage?); assert(arg_msg != null, 'Argument for dev.flutter.pigeon.AVFoundationVideoPlayerApi.seekTo was null, expected non-null PositionMessage.'); - api.seekTo(arg_msg!); - return {}; + await api.seekTo(arg_msg!); + return []; }); } } @@ -276,7 +276,7 @@ abstract class TestHostVideoPlayerApi { assert(arg_msg != null, 'Argument for dev.flutter.pigeon.AVFoundationVideoPlayerApi.pause was null, expected non-null TextureMessage.'); api.pause(arg_msg!); - return {}; + return []; }); } } @@ -297,7 +297,7 @@ abstract class TestHostVideoPlayerApi { assert(arg_msg != null, 'Argument for dev.flutter.pigeon.AVFoundationVideoPlayerApi.setMixWithOthers was null, expected non-null MixWithOthersMessage.'); api.setMixWithOthers(arg_msg!); - return {}; + return []; }); } }