Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[video_player_avfoundation] Platform view support #8237

Open
wants to merge 97 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 88 commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
82d5333
Extract FVPFrameUpdater and FVPVideoPlayer from plugin file to separa…
FirentisTFW Nov 21, 2024
a2d3d9f
Add docs for FVPFrameUpdater and FVPVideoPlayer interfaces
FirentisTFW Nov 21, 2024
a74c720
Remove unused imports and #pragma statements
FirentisTFW Nov 21, 2024
9092b71
Add empty lines at the end of files
FirentisTFW Nov 21, 2024
add5719
Bump version to 2.6.4 and update changelog
FirentisTFW Nov 21, 2024
9587ad0
Move GLKit import from header file to source file
FirentisTFW Nov 21, 2024
83cec0c
Add FVPVideoPlayerPlugin_Test import to plugin file
FirentisTFW Nov 22, 2024
99123db
Fix parameter type in interface constructor
FirentisTFW Nov 22, 2024
9545fda
Separate plugin and factory classes by pragma mark
FirentisTFW Nov 25, 2024
75b5ab9
Add nullability type specifiers to FVPVideoPlayer interface
FirentisTFW Nov 25, 2024
5ec766f
Make properties not needed in header of FVPVideoPlayer private
FirentisTFW Dec 2, 2024
c958a4a
Use nonnull macro for the whole header file
FirentisTFW Dec 2, 2024
0a707a5
Make updatePlayingState private for FVPVideoPlayer
FirentisTFW Dec 2, 2024
0055ea3
Make texture registry private for FVPFrameUpdater
FirentisTFW Dec 2, 2024
717315e
Move code from Plugin_Test file to different files
FirentisTFW Dec 2, 2024
489f2a9
Make changelog description more general
FirentisTFW Dec 4, 2024
599adc8
Add a doc comment for FVPDefaultAVFactory
FirentisTFW Dec 4, 2024
513961c
Make lastKnownAvailableTime property of FVPFrameUpdater readonly
FirentisTFW Dec 4, 2024
ff11b63
Add _Test.h file for FVPVideoPlayer
FirentisTFW Dec 4, 2024
12efd58
Add FVPNativeVideoViewFactory and FVPNativeVideoView (everything in o…
FirentisTFW Nov 18, 2024
42c3724
Use platform view in Dart Code (hardcoded)
FirentisTFW Nov 18, 2024
968bbf1
Add PlatformVideoViewType enum to allow choosing between texture view…
FirentisTFW Nov 18, 2024
dc85756
Pass video view type to controller in iOS example project
FirentisTFW Nov 18, 2024
c9f27c5
Add two FVPVideoPlayer implementations - basic and texture-approach o…
FirentisTFW Nov 18, 2024
b3151e2
Split iOS native classes into multiple files
FirentisTFW Nov 19, 2024
db1a943
Only register native view factory for iOS, not MacOS
FirentisTFW Nov 19, 2024
0e3b346
Use only textue view on MacOS in example app
FirentisTFW Nov 19, 2024
6d317a5
Refactor imports
FirentisTFW Nov 19, 2024
9bace40
Allow choosing between texture view and platform view in example app
FirentisTFW Nov 19, 2024
3bf34f9
Remove redundant import
FirentisTFW Nov 19, 2024
40996c4
Add some fixme comments for later
FirentisTFW Nov 19, 2024
674f9d0
Add copyright to each native iOS file
FirentisTFW Nov 19, 2024
3806bd2
Rename viewId to playerId in params
FirentisTFW Nov 19, 2024
87e76ac
Unregister texture from registry only when using texture approach
FirentisTFW Nov 19, 2024
4d11c11
Clean up code, add more context in comments
FirentisTFW Nov 19, 2024
d4dc7e5
Fix most of existing unit tests by creating a player with texture vie…
FirentisTFW Nov 19, 2024
73564c7
Check platform view in UI test
FirentisTFW Nov 19, 2024
30f65c0
Only allow choosing between texture view and platform view in example…
FirentisTFW Nov 20, 2024
3cd5126
Only include native view files on iOS
FirentisTFW Nov 20, 2024
c96ca17
Make comments less ambiguous
FirentisTFW Nov 20, 2024
c26b210
Add unit tests for factory registration and lack of texture registrat…
FirentisTFW Nov 20, 2024
45862e3
Make viewType an optional parameter and default to textureView
FirentisTFW Nov 20, 2024
479dc37
Document new classes in native iOS code
FirentisTFW Nov 20, 2024
7fe29f7
Document VideoViewType on Dart side
FirentisTFW Nov 20, 2024
7f19bd1
Fix variable name
FirentisTFW Nov 20, 2024
f3eb9ea
Format files generated by pigeon
FirentisTFW Nov 20, 2024
a28b580
Use a class for platform view creation params
FirentisTFW Nov 20, 2024
da768fe
Remove unused param from method
FirentisTFW Nov 21, 2024
dd5637c
Fix failing unit test, prevent double factory registration
FirentisTFW Nov 21, 2024
5214aa5
Format pigeon generated file
FirentisTFW Nov 21, 2024
981eb8a
Use correct plugin key in test function
FirentisTFW Nov 21, 2024
85d5ac6
Update dartdocs and comments
FirentisTFW Nov 22, 2024
97490ae
Adjust FVPVideoPlayer interface after rebase
FirentisTFW Nov 25, 2024
fd777bd
Fix Xcode analysis issues
FirentisTFW Nov 25, 2024
bbf2efa
Split code into fiels and fix implementations to separate texture app…
FirentisTFW Nov 26, 2024
39dd125
Adjust tests to use FVPVideoPlayerTextureApproach
FirentisTFW Nov 26, 2024
ad38f1c
Make video_player platform interface backwards compatible
FirentisTFW Nov 26, 2024
fd64cbe
Bump iOS package version to 2.7.0
FirentisTFW Nov 26, 2024
5132b99
Add viewType parameter to VideoPlayerController and use it to display…
FirentisTFW Nov 26, 2024
4df6449
Improve if statements readability
FirentisTFW Nov 26, 2024
a885632
Rename textureId to playerId in onPlayerSetup
FirentisTFW Nov 26, 2024
3cb7389
Fix overriding create method from platform interface on iOS
FirentisTFW Nov 26, 2024
5dc241e
Start non-texture player ids from a high number to avoid collisions
FirentisTFW Nov 26, 2024
fe61a20
Update comments
FirentisTFW Nov 27, 2024
9c38562
Add viewType to FakeController in tests
FirentisTFW Nov 27, 2024
6705387
Use correct view type to create data source in the main package
FirentisTFW Nov 27, 2024
fe88ebf
Add unit tests for passing view type correctly
FirentisTFW Nov 27, 2024
85f088d
Throw an assertion if platform view is used on platform different tha…
FirentisTFW Nov 27, 2024
04d0e8d
Adjust example app to allow changing view type on iOS
FirentisTFW Nov 27, 2024
07874ee
Add missing doc comments
FirentisTFW Nov 27, 2024
eba2c36
Remove placeholder files which are not needed anymore
FirentisTFW Nov 27, 2024
c2defa6
Clean up player's properties after rebase
FirentisTFW Dec 4, 2024
508a212
Remove code related to platform view from the app facing package
FirentisTFW Dec 4, 2024
9a2934a
Merge branch 'main' into feature/video-player-platform-view-support
FirentisTFW Dec 5, 2024
1ee5082
Adjust interfaces after merge
FirentisTFW Dec 5, 2024
d9bb76a
Replace hyphens with asterisks in Changelog
FirentisTFW Dec 5, 2024
cea9254
Update public_header_files path for iOS
FirentisTFW Dec 5, 2024
9ef9355
Rename playersByTextureId to playersById
FirentisTFW Dec 5, 2024
120e756
Move initWithPlayerItem from the public interface to class extension
FirentisTFW Dec 5, 2024
5e8b820
Remove nullable and nonnull annotations from implementation file
FirentisTFW Dec 5, 2024
cfe51ab
Add empty lines at the end of files
FirentisTFW Dec 5, 2024
1d21f18
Improve imports
FirentisTFW Dec 5, 2024
6616a6a
Replace fixme comment with a regular comment
FirentisTFW Dec 5, 2024
a4d82b2
Update names and doc comments in platform interface
FirentisTFW Dec 5, 2024
b267d3d
Update changelogs
FirentisTFW Dec 5, 2024
b19ca86
Bump platform_interface version to 6.3.0
FirentisTFW Dec 5, 2024
f04ed06
Rename textureId to playerId in test file when using platform view
FirentisTFW Dec 5, 2024
c2117a8
Add local dependency overrides for platform interface
FirentisTFW Dec 6, 2024
e7404e3
Format generated iOS files
FirentisTFW Dec 6, 2024
d3f3873
Add native view factory import to test file
FirentisTFW Dec 6, 2024
0ca8f80
Fix iOS source files path in podspec
FirentisTFW Dec 6, 2024
5f31fc3
Add iOS include path to Package.swift
FirentisTFW Dec 6, 2024
b78b61e
Revert "Remove placeholder files which are not needed anymore"
FirentisTFW Dec 10, 2024
dbe39ba
Move header files related to platform views to the main directory
FirentisTFW Dec 10, 2024
7bbf8bf
Add TargetConditionals.h import to FVPNativeVideoView.h
FirentisTFW Dec 10, 2024
2dac440
Add TargetConditionals.h import to FVPNativeVideoViewFactory.h
FirentisTFW Dec 10, 2024
1b77376
Update doc comments for FVPVideoPlayer constructors
FirentisTFW Dec 10, 2024
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
12 changes: 12 additions & 0 deletions packages/video_player/video_player/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,15 @@ flutter:
- assets/bumble_bee_captions.srt
- assets/bumble_bee_captions.vtt
- assets/Audio.mp3

# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
{
video_player_avfoundation:
{ path: ../../../../packages/video_player/video_player_avfoundation },
video_player_platform_interface:
{
path: ../../../../packages/video_player/video_player_platform_interface,
},
}
10 changes: 10 additions & 0 deletions packages/video_player/video_player/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,13 @@ dev_dependencies:
topics:
- video
- video-player

# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
{
video_player_avfoundation:
{ path: ../../../packages/video_player/video_player_avfoundation },
video_player_platform_interface:
{ path: ../../../packages/video_player/video_player_platform_interface },
}
10 changes: 10 additions & 0 deletions packages/video_player/video_player_android/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@ flutter:
assets:
- assets/flutter-mark-square-64.png
- assets/Butterfly-209.mp4

# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
{
video_player_platform_interface:
{
path: ../../../../packages/video_player/video_player_platform_interface,
},
}
8 changes: 8 additions & 0 deletions packages/video_player/video_player_android/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ dev_dependencies:
topics:
- video
- video-player

# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE.
# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins
dependency_overrides:
{
video_player_platform_interface:
{ path: ../../../packages/video_player/video_player_platform_interface },
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.7.0

* Adds support for platform views as an optional way of displaying a video.

## 2.6.4

* Refactors native code structure.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import <OCMock/OCMock.h>
#import <video_player_avfoundation/AVAssetTrackUtils.h>
#import <video_player_avfoundation/FVPVideoPlayerPlugin_Test.h>
#import <video_player_avfoundation/FVPVideoPlayerTextureApproach_Test.h>

// TODO(stuartmorgan): Convert to using mock registrars instead.
NSObject<FlutterPluginRegistry> *GetPluginRegistry(void) {
Expand Down Expand Up @@ -179,17 +180,56 @@ - (void)testBlankVideoBugWithEncryptedVideoStreamAndInvertedAspectRatioBugForSom
uri:@"https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4"
packageName:nil
formatHint:nil
httpHeaders:@{}];
httpHeaders:@{}
viewType:[[FVPPlatformVideoViewTypeBox alloc]
initWithValue:FVPPlatformVideoViewTypeTextureView]];
NSNumber *textureId = [videoPlayerPlugin createWithOptions:create error:&error];
XCTAssertNil(error);
XCTAssertNotNil(textureId);
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureId];
FVPVideoPlayerTextureApproach *player =
(FVPVideoPlayerTextureApproach *)videoPlayerPlugin.playersById[textureId];
XCTAssertNotNil(player);

XCTAssertNotNil(player.playerLayer, @"AVPlayerLayer should be present.");
XCTAssertNotNil(player.playerLayer.superlayer, @"AVPlayerLayer should be added on screen.");
}

- (void)testPlayerForPlatformViewDoesNotRegisterTexture {
NSObject<FlutterTextureRegistry> *mockTextureRegistry =
OCMProtocolMock(@protocol(FlutterTextureRegistry));
NSObject<FlutterPluginRegistrar> *registrar =
[GetPluginRegistry() registrarForPlugin:@"testPlayerForPlatformViewDoesNotRegisterTexture"];
NSObject<FlutterPluginRegistrar> *partialRegistrar = OCMPartialMock(registrar);
OCMStub([partialRegistrar textures]).andReturn(mockTextureRegistry);
FVPDisplayLink *mockDisplayLink =
OCMPartialMock([[FVPDisplayLink alloc] initWithRegistrar:registrar
callback:^(){
}]);
StubFVPDisplayLinkFactory *stubDisplayLinkFactory =
[[StubFVPDisplayLinkFactory alloc] initWithDisplayLink:mockDisplayLink];
AVPlayerItemVideoOutput *mockVideoOutput = OCMPartialMock([[AVPlayerItemVideoOutput alloc] init]);
FVPVideoPlayerPlugin *videoPlayerPlugin = [[FVPVideoPlayerPlugin alloc]
initWithAVFactory:[[StubFVPAVFactory alloc] initWithPlayer:nil output:mockVideoOutput]
displayLinkFactory:stubDisplayLinkFactory
registrar:partialRegistrar];

FlutterError *initalizationError;
[videoPlayerPlugin initialize:&initalizationError];
XCTAssertNil(initalizationError);
FVPCreationOptions *create = [FVPCreationOptions
makeWithAsset:nil
uri:@"https://flutter.github.io/assets-for-api-docs/assets/videos/hls/bee.m3u8"
packageName:nil
formatHint:nil
httpHeaders:@{}
viewType:[[FVPPlatformVideoViewTypeBox alloc]
initWithValue:FVPPlatformVideoViewTypePlatformView]];
FlutterError *createError;
[videoPlayerPlugin createWithOptions:create error:&createError];

OCMVerify(never(), [mockTextureRegistry registerTexture:[OCMArg any]]);
}

- (void)testSeekToWhilePausedStartsDisplayLinkTemporarily {
NSObject<FlutterTextureRegistry> *mockTextureRegistry =
OCMProtocolMock(@protocol(FlutterTextureRegistry));
Expand Down Expand Up @@ -217,7 +257,9 @@ - (void)testSeekToWhilePausedStartsDisplayLinkTemporarily {
uri:@"https://flutter.github.io/assets-for-api-docs/assets/videos/hls/bee.m3u8"
packageName:nil
formatHint:nil
httpHeaders:@{}];
httpHeaders:@{}
viewType:[[FVPPlatformVideoViewTypeBox alloc]
initWithValue:FVPPlatformVideoViewTypeTextureView]];
FlutterError *createError;
NSNumber *textureId = [videoPlayerPlugin createWithOptions:create error:&createError];

Expand All @@ -236,7 +278,8 @@ - (void)testSeekToWhilePausedStartsDisplayLinkTemporarily {
// Seeking to a new position should start the display link temporarily.
OCMVerify([mockDisplayLink setRunning:YES]);

FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureId];
FVPVideoPlayerTextureApproach *player =
(FVPVideoPlayerTextureApproach *)videoPlayerPlugin.playersById[textureId];
XCTAssertEqual([player position], 1234);

// Simulate a buffer being available.
Expand Down Expand Up @@ -283,7 +326,9 @@ - (void)testInitStartsDisplayLinkTemporarily {
uri:@"https://flutter.github.io/assets-for-api-docs/assets/videos/hls/bee.m3u8"
packageName:nil
formatHint:nil
httpHeaders:@{}];
httpHeaders:@{}
viewType:[[FVPPlatformVideoViewTypeBox alloc]
initWithValue:FVPPlatformVideoViewTypeTextureView]];
FlutterError *createError;
NSNumber *textureId = [videoPlayerPlugin createWithOptions:create error:&createError];

Expand All @@ -300,7 +345,8 @@ - (void)testInitStartsDisplayLinkTemporarily {
.ignoringNonObjectArgs()
.andReturn(fakeBufferRef);
// Simulate a callback from the engine to request a new frame.
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureId];
FVPVideoPlayerTextureApproach *player =
(FVPVideoPlayerTextureApproach *)videoPlayerPlugin.playersById[textureId];
[player copyPixelBuffer];
// Since a frame was found, and the video is paused, the display link should be paused again.
OCMVerify([mockDisplayLink setRunning:NO]);
Expand Down Expand Up @@ -333,7 +379,9 @@ - (void)testSeekToWhilePlayingDoesNotStopDisplayLink {
uri:@"https://flutter.github.io/assets-for-api-docs/assets/videos/hls/bee.m3u8"
packageName:nil
formatHint:nil
httpHeaders:@{}];
httpHeaders:@{}
viewType:[[FVPPlatformVideoViewTypeBox alloc]
initWithValue:FVPPlatformVideoViewTypeTextureView]];
FlutterError *createError;
NSNumber *textureId = [videoPlayerPlugin createWithOptions:create error:&createError];

Expand All @@ -350,7 +398,8 @@ - (void)testSeekToWhilePlayingDoesNotStopDisplayLink {
[self waitForExpectationsWithTimeout:30.0 handler:nil];
OCMVerify([mockDisplayLink setRunning:YES]);

FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureId];
FVPVideoPlayerTextureApproach *player =
(FVPVideoPlayerTextureApproach *)videoPlayerPlugin.playersById[textureId];
XCTAssertEqual([player position], 1234);

// Simulate a buffer being available.
Expand Down Expand Up @@ -395,7 +444,9 @@ - (void)testPauseWhileWaitingForFrameDoesNotStopDisplayLink {
uri:@"https://flutter.github.io/assets-for-api-docs/assets/videos/hls/bee.m3u8"
packageName:nil
formatHint:nil
httpHeaders:@{}];
httpHeaders:@{}
viewType:[[FVPPlatformVideoViewTypeBox alloc]
initWithValue:FVPPlatformVideoViewTypeTextureView]];
FlutterError *createError;
NSNumber *textureId = [videoPlayerPlugin createWithOptions:create error:&createError];

Expand Down Expand Up @@ -423,18 +474,20 @@ - (void)testDeregistersFromPlayer {
uri:@"https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4"
packageName:nil
formatHint:nil
httpHeaders:@{}];
httpHeaders:@{}
viewType:[[FVPPlatformVideoViewTypeBox alloc]
initWithValue:FVPPlatformVideoViewTypeTextureView]];
NSNumber *textureId = [videoPlayerPlugin createWithOptions:create error:&error];
XCTAssertNil(error);
XCTAssertNotNil(textureId);
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureId];
FVPVideoPlayer *player = videoPlayerPlugin.playersById[textureId];
XCTAssertNotNil(player);
AVPlayer *avPlayer = player.player;

[self keyValueObservingExpectationForObject:avPlayer keyPath:@"currentItem" expectedValue:nil];

[videoPlayerPlugin disposePlayer:textureId.integerValue error:&error];
XCTAssertEqual(videoPlayerPlugin.playersByTextureId.count, 0);
XCTAssertEqual(videoPlayerPlugin.playersById.count, 0);
XCTAssertNil(error);

[self waitForExpectationsWithTimeout:30.0 handler:nil];
Expand All @@ -455,11 +508,13 @@ - (void)testBufferingStateFromPlayer {
uri:@"https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4"
packageName:nil
formatHint:nil
httpHeaders:@{}];
httpHeaders:@{}
viewType:[[FVPPlatformVideoViewTypeBox alloc]
initWithValue:FVPPlatformVideoViewTypeTextureView]];
NSNumber *textureId = [videoPlayerPlugin createWithOptions:create error:&error];
XCTAssertNil(error);
XCTAssertNotNil(textureId);
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureId];
FVPVideoPlayer *player = videoPlayerPlugin.playersById[textureId];
XCTAssertNotNil(player);
AVPlayer *avPlayer = player.player;
[avPlayer play];
Expand Down Expand Up @@ -564,7 +619,9 @@ - (void)testSeekToleranceWhenNotSeekingToEnd {
uri:@"https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4"
packageName:nil
formatHint:nil
httpHeaders:@{}];
httpHeaders:@{}
viewType:[[FVPPlatformVideoViewTypeBox alloc]
initWithValue:FVPPlatformVideoViewTypeTextureView]];
FlutterError *createError;
NSNumber *textureId = [pluginWithMockAVPlayer createWithOptions:create error:&createError];

Expand Down Expand Up @@ -602,7 +659,9 @@ - (void)testSeekToleranceWhenSeekingToEnd {
uri:@"https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4"
packageName:nil
formatHint:nil
httpHeaders:@{}];
httpHeaders:@{}
viewType:[[FVPPlatformVideoViewTypeBox alloc]
initWithValue:FVPPlatformVideoViewTypeTextureView]];
FlutterError *createError;
NSNumber *textureId = [pluginWithMockAVPlayer createWithOptions:create error:&createError];

Expand All @@ -625,14 +684,17 @@ - (void)testSeekToleranceWhenSeekingToEnd {
[videoPlayerPlugin initialize:&error];
XCTAssertNil(error);

FVPCreationOptions *create = [FVPCreationOptions makeWithAsset:nil
uri:uri
packageName:nil
formatHint:nil
httpHeaders:@{}];
FVPCreationOptions *create =
[FVPCreationOptions makeWithAsset:nil
uri:uri
packageName:nil
formatHint:nil
httpHeaders:@{}
viewType:[[FVPPlatformVideoViewTypeBox alloc]
initWithValue:FVPPlatformVideoViewTypeTextureView]];
NSNumber *textureId = [videoPlayerPlugin createWithOptions:create error:&error];

FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureId];
FVPVideoPlayer *player = videoPlayerPlugin.playersById[textureId];
XCTAssertNotNil(player);

XCTestExpectation *initializedExpectation = [self expectationWithDescription:@"initialized"];
Expand Down Expand Up @@ -694,12 +756,14 @@ - (void)testDoesNotCrashOnRateObservationAfterDisposal {
uri:@"https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4"
packageName:nil
formatHint:nil
httpHeaders:@{}];
httpHeaders:@{}
viewType:[[FVPPlatformVideoViewTypeBox alloc]
initWithValue:FVPPlatformVideoViewTypeTextureView]];
NSNumber *textureId = [videoPlayerPlugin createWithOptions:create error:&error];
XCTAssertNil(error);
XCTAssertNotNil(textureId);

FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureId];
FVPVideoPlayer *player = videoPlayerPlugin.playersById[textureId];
XCTAssertNotNil(player);
weakPlayer = player;
avPlayer = player.player;
Expand Down Expand Up @@ -748,12 +812,15 @@ - (void)testHotReloadDoesNotCrash {
uri:@"https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4"
packageName:nil
formatHint:nil
httpHeaders:@{}];
httpHeaders:@{}
viewType:[[FVPPlatformVideoViewTypeBox alloc]
initWithValue:FVPPlatformVideoViewTypeTextureView]];
NSNumber *textureId = [videoPlayerPlugin createWithOptions:create error:&error];
XCTAssertNil(error);
XCTAssertNotNil(textureId);

FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureId];
FVPVideoPlayerTextureApproach *player =
(FVPVideoPlayerTextureApproach *)videoPlayerPlugin.playersById[textureId];
XCTAssertNotNil(player);
weakPlayer = player;

Expand All @@ -777,12 +844,34 @@ - (void)testHotReloadDoesNotCrash {
handler:nil]; // No assertions needed. Lack of crash is a success.
}

#if TARGET_OS_IOS
- (void)testNativeVideoViewFactoryRegistration {
NSObject<FlutterPluginRegistry> *registry = GetPluginRegistry();
NSObject<FlutterPluginRegistrar> *registrar =
[registry registrarForPlugin:@"testNativeVideoViewFactoryRegistration"];
id mockRegistrar = OCMPartialMock(registrar);

OCMExpect([mockRegistrar
registerViewFactory:[OCMArg isKindOfClass:[FVPNativeVideoViewFactory class]]
withId:@"plugins.flutter.dev/video_player_ios"]);
[FVPVideoPlayerPlugin registerWithRegistrar:mockRegistrar];

OCMVerifyAll(mockRegistrar);
}
#endif

- (void)testPublishesInRegistration {
NSString *pluginKey = @"TestRegistration";
NSObject<FlutterPluginRegistry> *registry = GetPluginRegistry();
NSObject<FlutterPluginRegistrar> *registrar = [registry registrarForPlugin:pluginKey];
id mockRegistrar = OCMPartialMock(registrar);
// Empty stub to pass a check in Flutter's engine (double factory registration).
// registerWithRegistrar gets called at the beginning of the test, and factory is registered
// there. Additional call would try to register the same factory another time, which would fail a
// check in the engine.
OCMStub([mockRegistrar registerViewFactory:[OCMArg any] withId:[OCMArg any]]);

[FVPVideoPlayerPlugin registerWithRegistrar:registrar];
[FVPVideoPlayerPlugin registerWithRegistrar:mockRegistrar];

id publishedValue = [registry valuePublishedByPlugin:pluginKey];

Expand All @@ -799,13 +888,16 @@ - (void)testFailedToLoadVideoEventShouldBeAlwaysSent {

[videoPlayerPlugin initialize:&error];

FVPCreationOptions *create = [FVPCreationOptions makeWithAsset:nil
uri:@""
packageName:nil
formatHint:nil
httpHeaders:@{}];
FVPCreationOptions *create =
[FVPCreationOptions makeWithAsset:nil
uri:@""
packageName:nil
formatHint:nil
httpHeaders:@{}
viewType:[[FVPPlatformVideoViewTypeBox alloc]
initWithValue:FVPPlatformVideoViewTypeTextureView]];
NSNumber *textureId = [videoPlayerPlugin createWithOptions:create error:&error];
FVPVideoPlayer *player = videoPlayerPlugin.playersByTextureId[textureId];
FVPVideoPlayer *player = videoPlayerPlugin.playersById[textureId];
XCTAssertNotNil(player);

[self keyValueObservingExpectationForObject:(id)player.player.currentItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Downloaded by pub (not CocoaPods).
s.ios.source_files = 'video_player_avfoundation/Sources/video_player_avfoundation_ios/*'
s.osx.source_files = 'video_player_avfoundation/Sources/video_player_avfoundation_macos/*'
s.public_header_files = 'video_player_avfoundation/Sources/video_player_avfoundation/include/**/*.h'
s.ios.public_header_files = 'video_player_avfoundation/Sources/video_player_avfoundation_ios/include/**/*.h'
s.ios.dependency 'Flutter'
s.osx.dependency 'FlutterMacOS'
s.ios.deployment_target = '12.0'
Expand Down
Loading
Loading