Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move interface
  • Loading branch information
tarrinneal committed May 5, 2023
commit d130337bf774aa0bbb057939165afb8892bf848e
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import <OCMock/OCMock.h>
#import <video_player_avfoundation/AVAssetTrackUtils.h>
#import <video_player_avfoundation/FLTVideoPlayerPlugin_test.h>
#import <video_player_avfoundation/FLTVideoPlayerPlugin_Test.h>

@interface FLTVideoPlayer : NSObject <FlutterStreamHandler>
@property(readonly, nonatomic) AVPlayer *player;
Expand Down Expand Up @@ -78,7 +78,12 @@ - (void)seekToTime:(CMTime)time

@end

@implementation AVPlayerFactory

@interface AVPlayerFactoryFake : NSObject <AVPlayerFactoryProtocol>

@end

@implementation AVPlayerFactoryFake
- (AVPlayer *)playerWithPlayerItem:(AVPlayerItem *)playerItem {
return [AVPlayerMock playerWithPlayerItem:playerItem];
}
Expand Down Expand Up @@ -254,7 +259,7 @@ - (void)testSeekToleranceWhenSeekingToEndFix {
NSObject<FlutterPluginRegistry> *registry =
(NSObject<FlutterPluginRegistry> *)[[UIApplication sharedApplication] delegate];
NSObject<FlutterPluginRegistrar> *registrar = [registry registrarForPlugin:@"TestSeekTolerance"];
FLTVideoPlayerPlugin *pluginWithMockAVPlayer = [[FLTVideoPlayerPlugin alloc] initWithAVPlayerFactory:[[AVPlayerFactory alloc] init] registrar: registrar];
FLTVideoPlayerPlugin *pluginWithMockAVPlayer = [[FLTVideoPlayerPlugin alloc] initWithAVPlayerFactory:[[AVPlayerFactoryFake alloc] init] registrar: registrar];

FlutterError *error;
[pluginWithMockAVPlayer initialize:&error];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// found in the LICENSE file.

#import "FLTVideoPlayerPlugin.h"
#import "FLTVideoPlayerPlugin_test.h"
#import "FLTVideoPlayerPlugin_Test.h"

#import <AVFoundation/AVFoundation.h>
#import <GLKit/GLKit.h>
Expand Down Expand Up @@ -34,6 +34,16 @@ - (void)onDisplayLink:(CADisplayLink *)link {
}
@end

@interface AVPlayerFactory : NSObject <AVPlayerFactoryProtocol>
@end

@implementation AVPlayerFactory
- (AVPlayer *)playerWithPlayerItem:(AVPlayerItem *)playerItem {
return [AVPlayer playerWithPlayerItem:playerItem];
}

@end

@interface FLTVideoPlayer : NSObject <FlutterTexture, FlutterStreamHandler>
@property(readonly, nonatomic) AVPlayer *player;
@property(readonly, nonatomic) AVPlayerItemVideoOutput *videoOutput;
Expand All @@ -54,7 +64,7 @@ @interface FLTVideoPlayer : NSObject <FlutterTexture, FlutterStreamHandler>
- (instancetype)initWithURL:(NSURL *)url
frameUpdater:(FLTFrameUpdater *)frameUpdater
httpHeaders:(nonnull NSDictionary<NSString *, NSString *> *)headers
playerFactory:(AVPlayerFactory *)playerFactory;
playerFactory:(id<AVPlayerFactoryProtocol> *)playerFactory;
@end

static void *timeRangeContext = &timeRangeContext;
Expand All @@ -69,7 +79,7 @@ - (instancetype)initWithURL:(NSURL *)url
@implementation FLTVideoPlayer
- (instancetype)initWithAsset:(NSString *)asset
frameUpdater:(FLTFrameUpdater *)frameUpdater
playerFactory:(AVPlayerFactory *)playerFactory {
playerFactory:(id<AVPlayerFactoryProtocol> *)playerFactory {
NSString *path = [[NSBundle mainBundle] pathForResource:asset ofType:nil];
return [self initWithURL:[NSURL fileURLWithPath:path]
frameUpdater:frameUpdater
Expand Down Expand Up @@ -211,7 +221,7 @@ - (void)createVideoOutputAndDisplayLink:(FLTFrameUpdater *)frameUpdater {
- (instancetype)initWithURL:(NSURL *)url
frameUpdater:(FLTFrameUpdater *)frameUpdater
httpHeaders:(nonnull NSDictionary<NSString *, NSString *> *)headers
playerFactory:(AVPlayerFactory *)playerFactory {
playerFactory:(id<AVPlayerFactoryProtocol> *)playerFactory {
NSDictionary<NSString *, id> *options = nil;
if ([headers count] != 0) {
options = @{@"AVURLAssetHTTPHeaderFieldsKey" : headers};
Expand All @@ -223,7 +233,7 @@ - (instancetype)initWithURL:(NSURL *)url

- (instancetype)initWithPlayerItem:(AVPlayerItem *)item
frameUpdater:(FLTFrameUpdater *)frameUpdater
playerFactory:(AVPlayerFactory *)playerFactory {
playerFactory:(id<AVPlayerFactoryProtocol> *)playerFactory {
self = [super init];
NSAssert(self, @"super init cannot be nil");

Expand Down Expand Up @@ -707,10 +717,3 @@ - (void)setMixWithOthers:(FLTMixWithOthersMessage *)input
}

@end

@implementation AVPlayerFactory
- (AVPlayer *)playerWithPlayerItem:(AVPlayerItem *)playerItem {
return [AVPlayer playerWithPlayerItem:playerItem];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
- (AVPlayer *)playerWithPlayerItem:(AVPlayerItem *)playerItem;
@end

@interface AVPlayerFactory : NSObject <AVPlayerFactoryProtocol>
@end

@interface FLTVideoPlayerPlugin ()

- (instancetype)initWithAVPlayerFactory:(AVPlayerFactory *)playerFactory
- (instancetype)initWithAVPlayerFactory:(id<AVPlayerFactoryProtocol>)playerFactory
registrar:(NSObject<FlutterPluginRegistrar> *)registrar;
@end