[video_player] Update iOS/macOS to Pigeon 13 (#5270)

Picks up several breaking changes, including the switch to unwrapped BOOL properties.
This commit is contained in:
stuartmorgan
2023-10-31 12:09:46 -07:00
committed by GitHub
parent e7ebc2071f
commit 1ac75cfbc7
9 changed files with 210 additions and 130 deletions

View File

@ -1,3 +1,7 @@
## 2.5.1
* Updates to Pigeon 13.
## 2.5.0
* Adds support for macOS.

View File

@ -512,7 +512,7 @@ NS_INLINE CGFloat radiansToDegrees(CGFloat radians) {
return FVPCMTimeToMillis([[[_player currentItem] asset] duration]);
}
- (void)seekTo:(int)location completionHandler:(void (^)(BOOL))completionHandler {
- (void)seekTo:(int64_t)location completionHandler:(void (^)(BOOL))completionHandler {
CMTime locationCMT = CMTimeMake(location, 1000);
CMTimeValue duration = _player.currentItem.asset.duration.value;
// Without adding tolerance when seeking to duration,
@ -670,7 +670,7 @@ NS_INLINE CGFloat radiansToDegrees(CGFloat radians) {
// https://github.com/flutter/flutter/issues/135320
[registrar publish:instance];
#endif
FVPAVFoundationVideoPlayerApiSetup(registrar.messenger, instance);
SetUpFVPAVFoundationVideoPlayerApi(registrar.messenger, instance);
}
- (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
@ -709,7 +709,7 @@ NS_INLINE CGFloat radiansToDegrees(CGFloat radians) {
[eventChannel setStreamHandler:player];
player.eventChannel = eventChannel;
self.playersByTextureId[@(textureId)] = player;
FVPTextureMessage *result = [FVPTextureMessage makeWithTextureId:@(textureId)];
FVPTextureMessage *result = [FVPTextureMessage makeWithTextureId:textureId];
return result;
}
@ -761,9 +761,10 @@ NS_INLINE CGFloat radiansToDegrees(CGFloat radians) {
}
- (void)dispose:(FVPTextureMessage *)input error:(FlutterError **)error {
FVPVideoPlayer *player = self.playersByTextureId[input.textureId];
[self.registry unregisterTexture:input.textureId.intValue];
[self.playersByTextureId removeObjectForKey:input.textureId];
NSNumber *playerKey = @(input.textureId);
FVPVideoPlayer *player = self.playersByTextureId[playerKey];
[self.registry unregisterTexture:input.textureId];
[self.playersByTextureId removeObjectForKey:playerKey];
// If the Flutter contains https://github.com/flutter/engine/pull/12695,
// the `player` is disposed via `onTextureUnregistered` at the right time.
// Without https://github.com/flutter/engine/pull/12695, there is no guarantee that the
@ -783,46 +784,46 @@ NS_INLINE CGFloat radiansToDegrees(CGFloat radians) {
}
- (void)setLooping:(FVPLoopingMessage *)input error:(FlutterError **)error {
FVPVideoPlayer *player = self.playersByTextureId[input.textureId];
player.isLooping = input.isLooping.boolValue;
FVPVideoPlayer *player = self.playersByTextureId[@(input.textureId)];
player.isLooping = input.isLooping;
}
- (void)setVolume:(FVPVolumeMessage *)input error:(FlutterError **)error {
FVPVideoPlayer *player = self.playersByTextureId[input.textureId];
[player setVolume:input.volume.doubleValue];
FVPVideoPlayer *player = self.playersByTextureId[@(input.textureId)];
[player setVolume:input.volume];
}
- (void)setPlaybackSpeed:(FVPPlaybackSpeedMessage *)input error:(FlutterError **)error {
FVPVideoPlayer *player = self.playersByTextureId[input.textureId];
[player setPlaybackSpeed:input.speed.doubleValue];
FVPVideoPlayer *player = self.playersByTextureId[@(input.textureId)];
[player setPlaybackSpeed:input.speed];
}
- (void)play:(FVPTextureMessage *)input error:(FlutterError **)error {
FVPVideoPlayer *player = self.playersByTextureId[input.textureId];
FVPVideoPlayer *player = self.playersByTextureId[@(input.textureId)];
[player play];
}
- (FVPPositionMessage *)position:(FVPTextureMessage *)input error:(FlutterError **)error {
FVPVideoPlayer *player = self.playersByTextureId[input.textureId];
FVPVideoPlayer *player = self.playersByTextureId[@(input.textureId)];
FVPPositionMessage *result = [FVPPositionMessage makeWithTextureId:input.textureId
position:@([player position])];
position:[player position]];
return result;
}
- (void)seekTo:(FVPPositionMessage *)input
completion:(void (^)(FlutterError *_Nullable))completion {
FVPVideoPlayer *player = self.playersByTextureId[input.textureId];
[player seekTo:input.position.intValue
FVPVideoPlayer *player = self.playersByTextureId[@(input.textureId)];
[player seekTo:input.position
completionHandler:^(BOOL finished) {
dispatch_async(dispatch_get_main_queue(), ^{
[self.registry textureFrameAvailable:input.textureId.intValue];
[self.registry textureFrameAvailable:input.textureId];
completion(nil);
});
}];
}
- (void)pause:(FVPTextureMessage *)input error:(FlutterError **)error {
FVPVideoPlayer *player = self.playersByTextureId[input.textureId];
FVPVideoPlayer *player = self.playersByTextureId[@(input.textureId)];
[player pause];
}
@ -831,7 +832,7 @@ NS_INLINE CGFloat radiansToDegrees(CGFloat radians) {
#if TARGET_OS_OSX
// AVAudioSession doesn't exist on macOS, and audio always mixes, so just no-op.
#else
if (input.mixWithOthers.boolValue) {
if (input.mixWithOthers) {
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback
withOptions:AVAudioSessionCategoryOptionMixWithOthers
error:nil];

View File

@ -1,7 +1,7 @@
// 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 (v11.0.1), do not edit directly.
// Autogenerated from Pigeon (v13.0.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon
#import <Foundation/Foundation.h>
@ -24,40 +24,40 @@ NS_ASSUME_NONNULL_BEGIN
@interface FVPTextureMessage : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithTextureId:(NSNumber *)textureId;
@property(nonatomic, strong) NSNumber *textureId;
+ (instancetype)makeWithTextureId:(NSInteger)textureId;
@property(nonatomic, assign) NSInteger textureId;
@end
@interface FVPLoopingMessage : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithTextureId:(NSNumber *)textureId isLooping:(NSNumber *)isLooping;
@property(nonatomic, strong) NSNumber *textureId;
@property(nonatomic, strong) NSNumber *isLooping;
+ (instancetype)makeWithTextureId:(NSInteger)textureId isLooping:(BOOL)isLooping;
@property(nonatomic, assign) NSInteger textureId;
@property(nonatomic, assign) BOOL isLooping;
@end
@interface FVPVolumeMessage : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithTextureId:(NSNumber *)textureId volume:(NSNumber *)volume;
@property(nonatomic, strong) NSNumber *textureId;
@property(nonatomic, strong) NSNumber *volume;
+ (instancetype)makeWithTextureId:(NSInteger)textureId volume:(double)volume;
@property(nonatomic, assign) NSInteger textureId;
@property(nonatomic, assign) double volume;
@end
@interface FVPPlaybackSpeedMessage : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithTextureId:(NSNumber *)textureId speed:(NSNumber *)speed;
@property(nonatomic, strong) NSNumber *textureId;
@property(nonatomic, strong) NSNumber *speed;
+ (instancetype)makeWithTextureId:(NSInteger)textureId speed:(double)speed;
@property(nonatomic, assign) NSInteger textureId;
@property(nonatomic, assign) double speed;
@end
@interface FVPPositionMessage : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithTextureId:(NSNumber *)textureId position:(NSNumber *)position;
@property(nonatomic, strong) NSNumber *textureId;
@property(nonatomic, strong) NSNumber *position;
+ (instancetype)makeWithTextureId:(NSInteger)textureId position:(NSInteger)position;
@property(nonatomic, assign) NSInteger textureId;
@property(nonatomic, assign) NSInteger position;
@end
@interface FVPCreateMessage : NSObject
@ -72,14 +72,14 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, copy, nullable) NSString *uri;
@property(nonatomic, copy, nullable) NSString *packageName;
@property(nonatomic, copy, nullable) NSString *formatHint;
@property(nonatomic, strong) NSDictionary<NSString *, NSString *> *httpHeaders;
@property(nonatomic, copy) NSDictionary<NSString *, NSString *> *httpHeaders;
@end
@interface FVPMixWithOthersMessage : NSObject
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)makeWithMixWithOthers:(NSNumber *)mixWithOthers;
@property(nonatomic, strong) NSNumber *mixWithOthers;
+ (instancetype)makeWithMixWithOthers:(BOOL)mixWithOthers;
@property(nonatomic, assign) BOOL mixWithOthers;
@end
/// The codec used by FVPAVFoundationVideoPlayerApi.
@ -105,7 +105,7 @@ NSObject<FlutterMessageCodec> *FVPAVFoundationVideoPlayerApiGetCodec(void);
error:(FlutterError *_Nullable *_Nonnull)error;
@end
extern void FVPAVFoundationVideoPlayerApiSetup(
extern void SetUpFVPAVFoundationVideoPlayerApi(
id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FVPAVFoundationVideoPlayerApi> *_Nullable api);

View File

@ -1,7 +1,7 @@
// 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 (v11.0.1), do not edit directly.
// Autogenerated from Pigeon (v13.0.0), do not edit directly.
// See also: https://pub.dev/packages/pigeon
#import "messages.g.h"
@ -72,15 +72,14 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
@end
@implementation FVPTextureMessage
+ (instancetype)makeWithTextureId:(NSNumber *)textureId {
+ (instancetype)makeWithTextureId:(NSInteger)textureId {
FVPTextureMessage *pigeonResult = [[FVPTextureMessage alloc] init];
pigeonResult.textureId = textureId;
return pigeonResult;
}
+ (FVPTextureMessage *)fromList:(NSArray *)list {
FVPTextureMessage *pigeonResult = [[FVPTextureMessage alloc] init];
pigeonResult.textureId = GetNullableObjectAtIndex(list, 0);
NSAssert(pigeonResult.textureId != nil, @"");
pigeonResult.textureId = [GetNullableObjectAtIndex(list, 0) integerValue];
return pigeonResult;
}
+ (nullable FVPTextureMessage *)nullableFromList:(NSArray *)list {
@ -88,13 +87,13 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
}
- (NSArray *)toList {
return @[
(self.textureId ?: [NSNull null]),
@(self.textureId),
];
}
@end
@implementation FVPLoopingMessage
+ (instancetype)makeWithTextureId:(NSNumber *)textureId isLooping:(NSNumber *)isLooping {
+ (instancetype)makeWithTextureId:(NSInteger)textureId isLooping:(BOOL)isLooping {
FVPLoopingMessage *pigeonResult = [[FVPLoopingMessage alloc] init];
pigeonResult.textureId = textureId;
pigeonResult.isLooping = isLooping;
@ -102,10 +101,8 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
}
+ (FVPLoopingMessage *)fromList:(NSArray *)list {
FVPLoopingMessage *pigeonResult = [[FVPLoopingMessage alloc] init];
pigeonResult.textureId = GetNullableObjectAtIndex(list, 0);
NSAssert(pigeonResult.textureId != nil, @"");
pigeonResult.isLooping = GetNullableObjectAtIndex(list, 1);
NSAssert(pigeonResult.isLooping != nil, @"");
pigeonResult.textureId = [GetNullableObjectAtIndex(list, 0) integerValue];
pigeonResult.isLooping = [GetNullableObjectAtIndex(list, 1) boolValue];
return pigeonResult;
}
+ (nullable FVPLoopingMessage *)nullableFromList:(NSArray *)list {
@ -113,14 +110,14 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
}
- (NSArray *)toList {
return @[
(self.textureId ?: [NSNull null]),
(self.isLooping ?: [NSNull null]),
@(self.textureId),
@(self.isLooping),
];
}
@end
@implementation FVPVolumeMessage
+ (instancetype)makeWithTextureId:(NSNumber *)textureId volume:(NSNumber *)volume {
+ (instancetype)makeWithTextureId:(NSInteger)textureId volume:(double)volume {
FVPVolumeMessage *pigeonResult = [[FVPVolumeMessage alloc] init];
pigeonResult.textureId = textureId;
pigeonResult.volume = volume;
@ -128,10 +125,8 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
}
+ (FVPVolumeMessage *)fromList:(NSArray *)list {
FVPVolumeMessage *pigeonResult = [[FVPVolumeMessage alloc] init];
pigeonResult.textureId = GetNullableObjectAtIndex(list, 0);
NSAssert(pigeonResult.textureId != nil, @"");
pigeonResult.volume = GetNullableObjectAtIndex(list, 1);
NSAssert(pigeonResult.volume != nil, @"");
pigeonResult.textureId = [GetNullableObjectAtIndex(list, 0) integerValue];
pigeonResult.volume = [GetNullableObjectAtIndex(list, 1) doubleValue];
return pigeonResult;
}
+ (nullable FVPVolumeMessage *)nullableFromList:(NSArray *)list {
@ -139,14 +134,14 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
}
- (NSArray *)toList {
return @[
(self.textureId ?: [NSNull null]),
(self.volume ?: [NSNull null]),
@(self.textureId),
@(self.volume),
];
}
@end
@implementation FVPPlaybackSpeedMessage
+ (instancetype)makeWithTextureId:(NSNumber *)textureId speed:(NSNumber *)speed {
+ (instancetype)makeWithTextureId:(NSInteger)textureId speed:(double)speed {
FVPPlaybackSpeedMessage *pigeonResult = [[FVPPlaybackSpeedMessage alloc] init];
pigeonResult.textureId = textureId;
pigeonResult.speed = speed;
@ -154,10 +149,8 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
}
+ (FVPPlaybackSpeedMessage *)fromList:(NSArray *)list {
FVPPlaybackSpeedMessage *pigeonResult = [[FVPPlaybackSpeedMessage alloc] init];
pigeonResult.textureId = GetNullableObjectAtIndex(list, 0);
NSAssert(pigeonResult.textureId != nil, @"");
pigeonResult.speed = GetNullableObjectAtIndex(list, 1);
NSAssert(pigeonResult.speed != nil, @"");
pigeonResult.textureId = [GetNullableObjectAtIndex(list, 0) integerValue];
pigeonResult.speed = [GetNullableObjectAtIndex(list, 1) doubleValue];
return pigeonResult;
}
+ (nullable FVPPlaybackSpeedMessage *)nullableFromList:(NSArray *)list {
@ -165,14 +158,14 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
}
- (NSArray *)toList {
return @[
(self.textureId ?: [NSNull null]),
(self.speed ?: [NSNull null]),
@(self.textureId),
@(self.speed),
];
}
@end
@implementation FVPPositionMessage
+ (instancetype)makeWithTextureId:(NSNumber *)textureId position:(NSNumber *)position {
+ (instancetype)makeWithTextureId:(NSInteger)textureId position:(NSInteger)position {
FVPPositionMessage *pigeonResult = [[FVPPositionMessage alloc] init];
pigeonResult.textureId = textureId;
pigeonResult.position = position;
@ -180,10 +173,8 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
}
+ (FVPPositionMessage *)fromList:(NSArray *)list {
FVPPositionMessage *pigeonResult = [[FVPPositionMessage alloc] init];
pigeonResult.textureId = GetNullableObjectAtIndex(list, 0);
NSAssert(pigeonResult.textureId != nil, @"");
pigeonResult.position = GetNullableObjectAtIndex(list, 1);
NSAssert(pigeonResult.position != nil, @"");
pigeonResult.textureId = [GetNullableObjectAtIndex(list, 0) integerValue];
pigeonResult.position = [GetNullableObjectAtIndex(list, 1) integerValue];
return pigeonResult;
}
+ (nullable FVPPositionMessage *)nullableFromList:(NSArray *)list {
@ -191,8 +182,8 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
}
- (NSArray *)toList {
return @[
(self.textureId ?: [NSNull null]),
(self.position ?: [NSNull null]),
@(self.textureId),
@(self.position),
];
}
@end
@ -218,7 +209,6 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
pigeonResult.packageName = GetNullableObjectAtIndex(list, 2);
pigeonResult.formatHint = GetNullableObjectAtIndex(list, 3);
pigeonResult.httpHeaders = GetNullableObjectAtIndex(list, 4);
NSAssert(pigeonResult.httpHeaders != nil, @"");
return pigeonResult;
}
+ (nullable FVPCreateMessage *)nullableFromList:(NSArray *)list {
@ -226,25 +216,24 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
}
- (NSArray *)toList {
return @[
(self.asset ?: [NSNull null]),
(self.uri ?: [NSNull null]),
(self.packageName ?: [NSNull null]),
(self.formatHint ?: [NSNull null]),
(self.httpHeaders ?: [NSNull null]),
self.asset ?: [NSNull null],
self.uri ?: [NSNull null],
self.packageName ?: [NSNull null],
self.formatHint ?: [NSNull null],
self.httpHeaders ?: [NSNull null],
];
}
@end
@implementation FVPMixWithOthersMessage
+ (instancetype)makeWithMixWithOthers:(NSNumber *)mixWithOthers {
+ (instancetype)makeWithMixWithOthers:(BOOL)mixWithOthers {
FVPMixWithOthersMessage *pigeonResult = [[FVPMixWithOthersMessage alloc] init];
pigeonResult.mixWithOthers = mixWithOthers;
return pigeonResult;
}
+ (FVPMixWithOthersMessage *)fromList:(NSArray *)list {
FVPMixWithOthersMessage *pigeonResult = [[FVPMixWithOthersMessage alloc] init];
pigeonResult.mixWithOthers = GetNullableObjectAtIndex(list, 0);
NSAssert(pigeonResult.mixWithOthers != nil, @"");
pigeonResult.mixWithOthers = [GetNullableObjectAtIndex(list, 0) boolValue];
return pigeonResult;
}
+ (nullable FVPMixWithOthersMessage *)nullableFromList:(NSArray *)list {
@ -252,7 +241,7 @@ static id GetNullableObjectAtIndex(NSArray *array, NSInteger key) {
}
- (NSArray *)toList {
return @[
(self.mixWithOthers ?: [NSNull null]),
@(self.mixWithOthers),
];
}
@end
@ -335,7 +324,7 @@ NSObject<FlutterMessageCodec> *FVPAVFoundationVideoPlayerApiGetCodec(void) {
return sSharedObject;
}
void FVPAVFoundationVideoPlayerApiSetup(id<FlutterBinaryMessenger> binaryMessenger,
void SetUpFVPAVFoundationVideoPlayerApi(id<FlutterBinaryMessenger> binaryMessenger,
NSObject<FVPAVFoundationVideoPlayerApi> *api) {
{
FlutterBasicMessageChannel *channel = [[FlutterBasicMessageChannel alloc]

View File

@ -141,7 +141,7 @@ NSObject<FlutterPluginRegistry> *GetPluginRegistry(void) {
FVPTextureMessage *textureMessage = [videoPlayerPlugin create:create error:&error];
XCTAssertNil(error);
XCTAssertNotNil(textureMessage);
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureMessage.textureId];
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[@(textureMessage.textureId)];
XCTAssertNotNil(player);
XCTAssertNotNil(player.playerLayer, @"AVPlayerLayer should be present.");
@ -169,18 +169,18 @@ NSObject<FlutterPluginRegistry> *GetPluginRegistry(void) {
httpHeaders:@{}];
FlutterError *createError;
FVPTextureMessage *textureMessage = [videoPlayerPlugin create:create error:&createError];
NSNumber *textureId = textureMessage.textureId;
NSInteger textureId = textureMessage.textureId;
XCTestExpectation *initializedExpectation = [self expectationWithDescription:@"seekTo completes"];
FVPPositionMessage *message = [FVPPositionMessage makeWithTextureId:textureId position:@1234];
FVPPositionMessage *message = [FVPPositionMessage 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]);
OCMVerify([mockTextureRegistry textureFrameAvailable:message.textureId]);
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureId];
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[@(textureId)];
XCTAssertEqual([player position], 1234);
}
@ -203,7 +203,7 @@ NSObject<FlutterPluginRegistry> *GetPluginRegistry(void) {
FVPTextureMessage *textureMessage = [videoPlayerPlugin create:create error:&error];
XCTAssertNil(error);
XCTAssertNotNil(textureMessage);
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureMessage.textureId];
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[@(textureMessage.textureId)];
XCTAssertNotNil(player);
AVPlayer *avPlayer = player.player;
@ -234,7 +234,7 @@ NSObject<FlutterPluginRegistry> *GetPluginRegistry(void) {
FVPTextureMessage *textureMessage = [videoPlayerPlugin create:create error:&error];
XCTAssertNil(error);
XCTAssertNotNil(textureMessage);
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureMessage.textureId];
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[@(textureMessage.textureId)];
XCTAssertNotNil(player);
AVPlayer *avPlayer = player.player;
[avPlayer play];
@ -340,11 +340,11 @@ NSObject<FlutterPluginRegistry> *GetPluginRegistry(void) {
httpHeaders:@{}];
FlutterError *createError;
FVPTextureMessage *textureMessage = [pluginWithMockAVPlayer create:create error:&createError];
NSNumber *textureId = textureMessage.textureId;
NSInteger textureId = textureMessage.textureId;
XCTestExpectation *initializedExpectation =
[self expectationWithDescription:@"seekTo has zero tolerance when seeking not to end"];
FVPPositionMessage *message = [FVPPositionMessage makeWithTextureId:textureId position:@1234];
FVPPositionMessage *message = [FVPPositionMessage makeWithTextureId:textureId position:1234];
[pluginWithMockAVPlayer seekTo:message
completion:^(FlutterError *_Nullable error) {
[initializedExpectation fulfill];
@ -377,12 +377,12 @@ NSObject<FlutterPluginRegistry> *GetPluginRegistry(void) {
httpHeaders:@{}];
FlutterError *createError;
FVPTextureMessage *textureMessage = [pluginWithMockAVPlayer create:create error:&createError];
NSNumber *textureId = textureMessage.textureId;
NSInteger textureId = textureMessage.textureId;
XCTestExpectation *initializedExpectation =
[self expectationWithDescription:@"seekTo has non-zero tolerance when seeking to end"];
// The duration of this video is "0" due to the non standard initiliatazion process.
FVPPositionMessage *message = [FVPPositionMessage makeWithTextureId:textureId position:@0];
FVPPositionMessage *message = [FVPPositionMessage makeWithTextureId:textureId position:0];
[pluginWithMockAVPlayer seekTo:message
completion:^(FlutterError *_Nullable error) {
[initializedExpectation fulfill];
@ -405,8 +405,8 @@ NSObject<FlutterPluginRegistry> *GetPluginRegistry(void) {
httpHeaders:@{}];
FVPTextureMessage *textureMessage = [videoPlayerPlugin create:create error:&error];
NSNumber *textureId = textureMessage.textureId;
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureId];
NSInteger textureId = textureMessage.textureId;
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[@(textureId)];
XCTAssertNotNil(player);
XCTestExpectation *initializedExpectation = [self expectationWithDescription:@"initialized"];
@ -428,15 +428,14 @@ NSObject<FlutterPluginRegistry> *GetPluginRegistry(void) {
XCTAssertEqual(avPlayer.timeControlStatus, AVPlayerTimeControlStatusPaused);
// Change playback speed.
FVPPlaybackSpeedMessage *playback = [FVPPlaybackSpeedMessage makeWithTextureId:textureId
speed:@2];
FVPPlaybackSpeedMessage *playback = [FVPPlaybackSpeedMessage makeWithTextureId:textureId speed:2];
[videoPlayerPlugin setPlaybackSpeed:playback error:&error];
XCTAssertNil(error);
XCTAssertEqual(avPlayer.rate, 2);
XCTAssertEqual(avPlayer.timeControlStatus, AVPlayerTimeControlStatusWaitingToPlayAtSpecifiedRate);
// Volume
FVPVolumeMessage *volume = [FVPVolumeMessage makeWithTextureId:textureId volume:@0.1];
FVPVolumeMessage *volume = [FVPVolumeMessage makeWithTextureId:textureId volume:0.1];
[videoPlayerPlugin setVolume:volume error:&error];
XCTAssertNil(error);
XCTAssertEqual(avPlayer.volume, 0.1f);
@ -476,7 +475,7 @@ NSObject<FlutterPluginRegistry> *GetPluginRegistry(void) {
XCTAssertNil(error);
XCTAssertNotNil(textureMessage);
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureMessage.textureId];
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[@(textureMessage.textureId)];
XCTAssertNotNil(player);
weakPlayer = player;
avPlayer = player.player;
@ -530,7 +529,7 @@ NSObject<FlutterPluginRegistry> *GetPluginRegistry(void) {
XCTAssertNil(error);
XCTAssertNotNil(textureMessage);
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureMessage.textureId];
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[@(textureMessage.textureId)];
XCTAssertNotNil(player);
weakPlayer = player;

View File

@ -1,7 +1,7 @@
// 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 (v11.0.1), do not edit directly.
// Autogenerated from Pigeon (v13.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, unnecessary_import
@ -11,6 +11,17 @@ import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List;
import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer;
import 'package:flutter/services.dart';
List<Object?> wrapResponse(
{Object? result, PlatformException? error, bool empty = false}) {
if (empty) {
return <Object?>[];
}
if (error == null) {
return <Object?>[result];
}
return <Object?>[error.code, error.message, error.details];
}
class TextureMessage {
TextureMessage({
required this.textureId,

View File

@ -7,8 +7,8 @@ import 'package:pigeon/pigeon.dart';
@ConfigurePigeon(PigeonOptions(
dartOut: 'lib/src/messages.g.dart',
dartTestOut: 'test/test_api.g.dart',
objcHeaderOut: 'ios/Classes/messages.g.h',
objcSourceOut: 'ios/Classes/messages.g.m',
objcHeaderOut: 'darwin/Classes/messages.g.h',
objcSourceOut: 'darwin/Classes/messages.g.m',
objcOptions: ObjcOptions(
prefix: 'FVP',
),

View File

@ -2,7 +2,7 @@ name: video_player_avfoundation
description: iOS and macOS 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.5.0
version: 2.5.1
environment:
sdk: ">=3.1.0 <4.0.0"
@ -29,7 +29,7 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
pigeon: ^11.0.1
pigeon: ^13.0.0
topics:
- video

View File

@ -1,7 +1,7 @@
// 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 (v11.0.1), do not edit directly.
// Autogenerated from Pigeon (v13.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, unnecessary_import
// ignore_for_file: avoid_relative_lib_imports
@ -107,9 +107,15 @@ abstract class TestHostVideoPlayerApi {
_testBinaryMessengerBinding!.defaultBinaryMessenger
.setMockDecodedMessageHandler<Object?>(channel,
(Object? message) async {
// ignore message
api.initialize();
return <Object?>[];
try {
api.initialize();
return wrapResponse(empty: true);
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}
@ -131,8 +137,15 @@ abstract class TestHostVideoPlayerApi {
final CreateMessage? arg_msg = (args[0] as CreateMessage?);
assert(arg_msg != null,
'Argument for dev.flutter.pigeon.video_player_avfoundation.AVFoundationVideoPlayerApi.create was null, expected non-null CreateMessage.');
final TextureMessage output = api.create(arg_msg!);
return <Object?>[output];
try {
final TextureMessage output = api.create(arg_msg!);
return <Object?>[output];
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}
@ -154,8 +167,15 @@ abstract class TestHostVideoPlayerApi {
final TextureMessage? arg_msg = (args[0] as TextureMessage?);
assert(arg_msg != null,
'Argument for dev.flutter.pigeon.video_player_avfoundation.AVFoundationVideoPlayerApi.dispose was null, expected non-null TextureMessage.');
api.dispose(arg_msg!);
return <Object?>[];
try {
api.dispose(arg_msg!);
return wrapResponse(empty: true);
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}
@ -177,8 +197,15 @@ abstract class TestHostVideoPlayerApi {
final LoopingMessage? arg_msg = (args[0] as LoopingMessage?);
assert(arg_msg != null,
'Argument for dev.flutter.pigeon.video_player_avfoundation.AVFoundationVideoPlayerApi.setLooping was null, expected non-null LoopingMessage.');
api.setLooping(arg_msg!);
return <Object?>[];
try {
api.setLooping(arg_msg!);
return wrapResponse(empty: true);
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}
@ -200,8 +227,15 @@ abstract class TestHostVideoPlayerApi {
final VolumeMessage? arg_msg = (args[0] as VolumeMessage?);
assert(arg_msg != null,
'Argument for dev.flutter.pigeon.video_player_avfoundation.AVFoundationVideoPlayerApi.setVolume was null, expected non-null VolumeMessage.');
api.setVolume(arg_msg!);
return <Object?>[];
try {
api.setVolume(arg_msg!);
return wrapResponse(empty: true);
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}
@ -224,8 +258,15 @@ abstract class TestHostVideoPlayerApi {
(args[0] as PlaybackSpeedMessage?);
assert(arg_msg != null,
'Argument for dev.flutter.pigeon.video_player_avfoundation.AVFoundationVideoPlayerApi.setPlaybackSpeed was null, expected non-null PlaybackSpeedMessage.');
api.setPlaybackSpeed(arg_msg!);
return <Object?>[];
try {
api.setPlaybackSpeed(arg_msg!);
return wrapResponse(empty: true);
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}
@ -247,8 +288,15 @@ abstract class TestHostVideoPlayerApi {
final TextureMessage? arg_msg = (args[0] as TextureMessage?);
assert(arg_msg != null,
'Argument for dev.flutter.pigeon.video_player_avfoundation.AVFoundationVideoPlayerApi.play was null, expected non-null TextureMessage.');
api.play(arg_msg!);
return <Object?>[];
try {
api.play(arg_msg!);
return wrapResponse(empty: true);
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}
@ -270,8 +318,15 @@ abstract class TestHostVideoPlayerApi {
final TextureMessage? arg_msg = (args[0] as TextureMessage?);
assert(arg_msg != null,
'Argument for dev.flutter.pigeon.video_player_avfoundation.AVFoundationVideoPlayerApi.position was null, expected non-null TextureMessage.');
final PositionMessage output = api.position(arg_msg!);
return <Object?>[output];
try {
final PositionMessage output = api.position(arg_msg!);
return <Object?>[output];
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}
@ -293,8 +348,15 @@ abstract class TestHostVideoPlayerApi {
final PositionMessage? arg_msg = (args[0] as PositionMessage?);
assert(arg_msg != null,
'Argument for dev.flutter.pigeon.video_player_avfoundation.AVFoundationVideoPlayerApi.seekTo was null, expected non-null PositionMessage.');
await api.seekTo(arg_msg!);
return <Object?>[];
try {
await api.seekTo(arg_msg!);
return wrapResponse(empty: true);
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}
@ -316,8 +378,15 @@ abstract class TestHostVideoPlayerApi {
final TextureMessage? arg_msg = (args[0] as TextureMessage?);
assert(arg_msg != null,
'Argument for dev.flutter.pigeon.video_player_avfoundation.AVFoundationVideoPlayerApi.pause was null, expected non-null TextureMessage.');
api.pause(arg_msg!);
return <Object?>[];
try {
api.pause(arg_msg!);
return wrapResponse(empty: true);
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}
@ -340,8 +409,15 @@ abstract class TestHostVideoPlayerApi {
(args[0] as MixWithOthersMessage?);
assert(arg_msg != null,
'Argument for dev.flutter.pigeon.video_player_avfoundation.AVFoundationVideoPlayerApi.setMixWithOthers was null, expected non-null MixWithOthersMessage.');
api.setMixWithOthers(arg_msg!);
return <Object?>[];
try {
api.setMixWithOthers(arg_msg!);
return wrapResponse(empty: true);
} on PlatformException catch (e) {
return wrapResponse(error: e);
} catch (e) {
return wrapResponse(
error: PlatformException(code: 'error', message: e.toString()));
}
});
}
}