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 133 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 99 commits
Commits
Show all changes
133 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
277b805
Merge branch 'main' into feature/video-player-platform-view-support
FirentisTFW Dec 20, 2024
404fad2
Merge branch 'main' into feature/video-player-platform-view-support
FirentisTFW Jan 2, 2025
d2778a1
Remove dependency overrides for packages that have no other changes
FirentisTFW Jan 7, 2025
4a8d0bd
Remove redundant sentence from a comment
FirentisTFW Jan 7, 2025
b6f2e2c
Use INT_MAX as the initial non-texture player ID, and then decrement
FirentisTFW Jan 7, 2025
6702c6f
Make viewType parameter in CreationOptions non-nullable
FirentisTFW Jan 7, 2025
4d7ca15
Rename FVPVideoPlayerTextureApproach to FVPTextureBasedVideoPlayer
FirentisTFW Jan 7, 2025
7bb4de3
Remove redeclaration of view method from the interface
FirentisTFW Jan 7, 2025
f753253
Use a block instead of passing a mutable dictionary
FirentisTFW Jan 7, 2025
16fb48e
Do not use "we" in comments
FirentisTFW Jan 7, 2025
b1dd379
Inherit from NSView instead of NSWindow
FirentisTFW Jan 7, 2025
7d7121a
Do not override dealloc in FVPNativeVideoView
FirentisTFW Jan 7, 2025
3eddd81
Fix typo
FirentisTFW Jan 7, 2025
97bd780
Remove "we" from comments
FirentisTFW Jan 7, 2025
8fe7428
Fix initialization of viewType in test file
FirentisTFW Jan 7, 2025
9b7f9ad
Fix (hopefully) a flaky test - wait for the assertion to happen inste…
FirentisTFW Jan 7, 2025
cacfd26
Add back license that was removed by mistake
FirentisTFW Jan 7, 2025
576a005
Rename variables for better consistency
FirentisTFW Jan 7, 2025
b7b58e2
Do not use @synchronized when decrementing next player ID
FirentisTFW Jan 7, 2025
8a71cfa
Introduce createWithOptions method
FirentisTFW Jan 7, 2025
fe409ed
Add a todo
FirentisTFW Jan 7, 2025
057285f
Fix dartdoc
FirentisTFW Jan 7, 2025
3610b34
Remove - unnecessary casts
FirentisTFW Jan 10, 2025
93ec315
Convert static variable to an ivar
FirentisTFW Jan 10, 2025
551e2b1
Add missing newline at the end of file
FirentisTFW Jan 10, 2025
9fbc43d
Use private properties instead of ivars
FirentisTFW Jan 10, 2025
2c1f5c4
Fix textureBased condition
FirentisTFW Jan 10, 2025
f78d7da
Reuse common code in seekTo method
FirentisTFW Jan 10, 2025
65b2614
Add pragma sections to texture-based video player file
FirentisTFW Jan 10, 2025
a48f432
Merge branch 'main' into feature/video-player-platform-view-support
FirentisTFW Jan 15, 2025
2915bad
Simplfy platform interface, do not expose internal details about play…
FirentisTFW Jan 15, 2025
af1d7eb
Adjust iOS implementation to the new platform interface
FirentisTFW Jan 15, 2025
9453edc
Adjust example app's controller to the new platform interface
FirentisTFW Jan 15, 2025
37c8dab
Test playerViewTypes in iOS implementation
FirentisTFW Jan 15, 2025
4f09736
Merge branch 'main' into feature/video-player-platform-view-support
FirentisTFW Jan 15, 2025
0045c27
Adjust new test's setup after merging main
FirentisTFW Jan 15, 2025
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.
FirentisTFW marked this conversation as resolved.
Show resolved Hide resolved
# 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,5 +1,6 @@
## NEXT
## 2.7.0

* Adds support for platform views as an optional way of displaying a video.
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.

## 2.6.5
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,8 @@
static void *playbackLikelyToKeepUpContext = &playbackLikelyToKeepUpContext;
static void *rateContext = &rateContext;

@interface FVPVideoPlayer ()
/// The AVPlayerItemVideoOutput associated with this video player.
@property(nonatomic, readonly) AVPlayerItemVideoOutput *videoOutput;
/// The plugin registrar, to obtain view information from.
@property(nonatomic, readonly) NSObject<FlutterPluginRegistrar> *registrar;
/// The CALayer associated with the Flutter view this plugin is associated with, if any.
@property(nonatomic, readonly) CALayer *flutterViewLayer;
/// The Flutter event sink used to send events to the Flutter engine.
@property(nonatomic) FlutterEventSink eventSink;
/// The preferred transform for the video. It can be used to handle the rotation of the video.
@property(nonatomic) CGAffineTransform preferredTransform;
/// Indicates whether the video player is currently playing.
@property(nonatomic, readonly) BOOL isPlaying;
/// Indicates whether the video player has been initialized.
@property(nonatomic, readonly) BOOL isInitialized;
/// The updater that drives callbacks to the engine to indicate that a new frame is ready.
@property(nonatomic) FVPFrameUpdater *frameUpdater;
/// The display link that drives frameUpdater.
@property(nonatomic) FVPDisplayLink *displayLink;
/// Whether a new frame needs to be provided to the engine regardless of the current play/pause
/// state (e.g., after a seek while paused). If YES, the display link should continue to run until
/// the next frame is successfully provided.
@property(nonatomic, assign) BOOL waitingForFrame;

/// Updates the playing state of the video player.
- (void)updatePlayingState;
@end

@implementation FVPVideoPlayer
- (instancetype)initWithAsset:(NSString *)asset
frameUpdater:(FVPFrameUpdater *)frameUpdater
displayLink:(FVPDisplayLink *)displayLink
avFactory:(id<FVPAVFactory>)avFactory
registrar:(NSObject<FlutterPluginRegistrar> *)registrar {
NSString *path = [[NSBundle mainBundle] pathForResource:asset ofType:nil];
Expand All @@ -59,16 +29,12 @@ - (instancetype)initWithAsset:(NSString *)asset
}
#endif
return [self initWithURL:[NSURL fileURLWithPath:path]
frameUpdater:frameUpdater
displayLink:displayLink
httpHeaders:@{}
avFactory:avFactory
registrar:registrar];
}

- (instancetype)initWithURL:(NSURL *)url
frameUpdater:(FVPFrameUpdater *)frameUpdater
displayLink:(FVPDisplayLink *)displayLink
httpHeaders:(nonnull NSDictionary<NSString *, NSString *> *)headers
avFactory:(id<FVPAVFactory>)avFactory
registrar:(NSObject<FlutterPluginRegistrar> *)registrar {
Expand All @@ -78,23 +44,16 @@ - (instancetype)initWithURL:(NSURL *)url
}
AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:url options:options];
AVPlayerItem *item = [AVPlayerItem playerItemWithAsset:urlAsset];
return [self initWithPlayerItem:item
frameUpdater:frameUpdater
displayLink:(FVPDisplayLink *)displayLink
avFactory:avFactory
registrar:registrar];
return [self initWithPlayerItem:item avFactory:avFactory registrar:registrar];
}

- (instancetype)initWithPlayerItem:(AVPlayerItem *)item
frameUpdater:(FVPFrameUpdater *)frameUpdater
displayLink:(FVPDisplayLink *)displayLink
avFactory:(id<FVPAVFactory>)avFactory
registrar:(NSObject<FlutterPluginRegistrar> *)registrar {
self = [super init];
NSAssert(self, @"super init cannot be nil");

_registrar = registrar;
_frameUpdater = frameUpdater;

AVAsset *asset = [item asset];
void (^assetCompletionHandler)(void) = ^{
Expand Down Expand Up @@ -128,22 +87,12 @@ - (instancetype)initWithPlayerItem:(AVPlayerItem *)item
_player = [avFactory playerWithPlayerItem:item];
_player.actionAtItemEnd = AVPlayerActionAtItemEndNone;

// This is to fix 2 bugs: 1. blank video for encrypted video streams on iOS 16
// (https://github.com/flutter/flutter/issues/111457) and 2. swapped width and height for some
// video streams (not just iOS 16). (https://github.com/flutter/flutter/issues/109116). An
// invisible AVPlayerLayer is used to overwrite the protection of pixel buffers in those streams
// for issue #1, and restore the correct width and height for issue #2.
_playerLayer = [AVPlayerLayer playerLayerWithPlayer:_player];
[self.flutterViewLayer addSublayer:_playerLayer];
FirentisTFW marked this conversation as resolved.
Show resolved Hide resolved

// Configure output.
_displayLink = displayLink;
NSDictionary *pixBuffAttributes = @{
(id)kCVPixelBufferPixelFormatTypeKey : @(kCVPixelFormatType_32BGRA),
(id)kCVPixelBufferIOSurfacePropertiesKey : @{}
};
_videoOutput = [avFactory videoOutputWithPixelBufferAttributes:pixBuffAttributes];
frameUpdater.videoOutput = _videoOutput;

[self addObserversForItem:item player:_player];

Expand Down Expand Up @@ -327,9 +276,6 @@ - (void)updatePlayingState {
} else {
[_player pause];
}
// If the texture is still waiting for an expected frame, the display link needs to keep
// running until it arrives regardless of the play/pause state.
_displayLink.running = _isPlaying || self.waitingForFrame;
}

- (void)sendFailedToLoadVideoEvent {
Expand Down Expand Up @@ -432,7 +378,6 @@ - (int64_t)duration {
}

- (void)seekTo:(int64_t)location completionHandler:(void (^)(BOOL))completionHandler {
CMTime previousCMTime = _player.currentTime;
CMTime targetCMTime = CMTimeMake(location, 1000);
CMTimeValue duration = _player.currentItem.asset.duration.value;
// Without adding tolerance when seeking to duration,
Expand All @@ -443,27 +388,12 @@ - (void)seekTo:(int64_t)location completionHandler:(void (^)(BOOL))completionHan
toleranceBefore:tolerance
toleranceAfter:tolerance
completionHandler:^(BOOL completed) {
if (CMTimeCompare(self.player.currentTime, previousCMTime) != 0) {
// Ensure that a frame is drawn once available, even if currently paused. In theory a race
// is possible here where the new frame has already drawn by the time this code runs, and
// the display link stays on indefinitely, but that should be relatively harmless. This
// must use the display link rather than just informing the engine that a new frame is
// available because the seek completing doesn't guarantee that the pixel buffer is
// already available.
[self expectFrame];
}

if (completionHandler) {
completionHandler(completed);
}
}];
}

- (void)expectFrame {
self.waitingForFrame = YES;
self.displayLink.running = YES;
}

- (void)setIsLooping:(BOOL)isLooping {
_isLooping = isLooping;
}
Expand Down Expand Up @@ -496,38 +426,6 @@ - (void)setPlaybackSpeed:(double)speed {
_player.rate = speed;
}

- (CVPixelBufferRef)copyPixelBuffer {
CVPixelBufferRef buffer = NULL;
CMTime outputItemTime = [_videoOutput itemTimeForHostTime:CACurrentMediaTime()];
if ([_videoOutput hasNewPixelBufferForItemTime:outputItemTime]) {
buffer = [_videoOutput copyPixelBufferForItemTime:outputItemTime itemTimeForDisplay:NULL];
} else {
// If the current time isn't available yet, use the time that was checked when informing the
// engine that a frame was available (if any).
CMTime lastAvailableTime = self.frameUpdater.lastKnownAvailableTime;
if (CMTIME_IS_VALID(lastAvailableTime)) {
buffer = [_videoOutput copyPixelBufferForItemTime:lastAvailableTime itemTimeForDisplay:NULL];
}
}

if (self.waitingForFrame && buffer) {
self.waitingForFrame = NO;
// If the display link was only running temporarily to pick up a new frame while the video was
// paused, stop it again.
if (!self.isPlaying) {
self.displayLink.running = NO;
}
}

return buffer;
}

- (void)onTextureUnregistered:(NSObject<FlutterTexture> *)texture {
dispatch_async(dispatch_get_main_queue(), ^{
[self dispose];
});
}

- (FlutterError *_Nullable)onCancelWithArguments:(id _Nullable)arguments {
_eventSink = nil;
return nil;
Expand Down Expand Up @@ -565,8 +463,6 @@ - (void)disposeSansEventChannel {
}

_disposed = YES;
[_playerLayer removeFromSuperlayer];
_displayLink = nil;
[self removeKeyValueObservers];

[self.player replaceCurrentItemWithPlayerItem:nil];
Expand All @@ -578,20 +474,6 @@ - (void)dispose {
[_eventChannel setStreamHandler:nil];
}

- (CALayer *)flutterViewLayer {
#if TARGET_OS_OSX
return self.registrar.view.layer;
#else
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// TODO(hellohuanlin): Provide a non-deprecated codepath. See
// https://github.com/flutter/flutter/issues/104117
UIViewController *root = UIApplication.sharedApplication.keyWindow.rootViewController;
#pragma clang diagnostic pop
return root.view.layer;
#endif
}

/// Removes all key-value observers set up for the player.
///
/// This is called from dealloc, so must not use any methods on self.
Expand Down
Loading
Loading