Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 3da6bfe

Browse files
Change seekTo method to async so it only completes when [AVPlayer seekTo:completionHandler:] completes
1 parent 07e6f10 commit 3da6bfe

File tree

16 files changed

+53
-33
lines changed

16 files changed

+53
-33
lines changed

packages/video_player/video_player/pubspec.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@ dependencies:
3131
dev_dependencies:
3232
flutter_test:
3333
sdk: flutter
34+
35+
36+
# FOR TESTING ONLY. DO NOT MERGE.
37+
dependency_overrides:
38+
video_player_avfoundation:
39+
path: ../../video_player/video_player_avfoundation

packages/video_player/video_player_avfoundation/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 2.3.9
22

3+
* Makes seekTo async and only complete when AVPlayer.seekTo completes.
34
* Updates minimum Flutter version to 3.0.
45

56
## 2.3.8

packages/video_player/video_player_avfoundation/example/integration_test/video_player_test.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ void main() {
7676

7777
await controller.seekTo(const Duration(seconds: 3));
7878

79-
// TODO(stuartmorgan): Switch to _controller.position once seekTo is
80-
// fixed on the native side to wait for completion, so this is testing
81-
// the native code rather than the MiniController position cache.
82-
expect(controller.value.position, const Duration(seconds: 3));
79+
expect(await controller.position, const Duration(seconds: 3));
8380
});
8481

8582
testWidgets('can be paused', (WidgetTester tester) async {

packages/video_player/video_player_avfoundation/example/ios/Flutter/AppFrameworkInfo.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
<string>arm64</string>
2626
</array>
2727
<key>MinimumOSVersion</key>
28-
<string>9.0</string>
28+
<string>11.0</string>
2929
</dict>
3030
</plist>

packages/video_player/video_player_avfoundation/example/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Uncomment this line to define a global platform for your project
2-
# platform :ios, '9.0'
2+
# platform :ios, '11.0'
33

44
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
55
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

packages/video_player/video_player_avfoundation/example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 46;
6+
objectVersion = 54;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -269,7 +269,7 @@
269269
97C146E61CF9000F007C117D /* Project object */ = {
270270
isa = PBXProject;
271271
attributes = {
272-
LastUpgradeCheck = 1320;
272+
LastUpgradeCheck = 1300;
273273
ORGANIZATIONNAME = "The Flutter Authors";
274274
TargetAttributes = {
275275
97C146ED1CF9000F007C117D = {
@@ -338,6 +338,7 @@
338338
/* Begin PBXShellScriptBuildPhase section */
339339
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
340340
isa = PBXShellScriptBuildPhase;
341+
alwaysOutOfDate = 1;
341342
buildActionMask = 2147483647;
342343
files = (
343344
);
@@ -352,6 +353,7 @@
352353
};
353354
9740EEB61CF901F6004384FC /* Run Script */ = {
354355
isa = PBXShellScriptBuildPhase;
356+
alwaysOutOfDate = 1;
355357
buildActionMask = 2147483647;
356358
files = (
357359
);
@@ -516,7 +518,7 @@
516518
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
517519
GCC_WARN_UNUSED_FUNCTION = YES;
518520
GCC_WARN_UNUSED_VARIABLE = YES;
519-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
521+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
520522
MTL_ENABLE_DEBUG_INFO = YES;
521523
ONLY_ACTIVE_ARCH = YES;
522524
SDKROOT = iphoneos;
@@ -566,7 +568,7 @@
566568
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
567569
GCC_WARN_UNUSED_FUNCTION = YES;
568570
GCC_WARN_UNUSED_VARIABLE = YES;
569-
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
571+
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
570572
MTL_ENABLE_DEBUG_INFO = NO;
571573
SDKROOT = iphoneos;
572574
TARGETED_DEVICE_FAMILY = "1,2";

packages/video_player/video_player_avfoundation/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1320"
3+
LastUpgradeVersion = "1300"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

packages/video_player/video_player_avfoundation/example/ios/Runner/Info.plist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,9 @@
5050
</array>
5151
<key>UIViewControllerBasedStatusBarAppearance</key>
5252
<false/>
53+
<key>CADisableMinimumFrameDurationOnPhone</key>
54+
<true/>
55+
<key>UIApplicationSupportsIndirectInputEvents</key>
56+
<true/>
5357
</dict>
5458
</plist>

packages/video_player/video_player_avfoundation/example/pubspec.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,9 @@ flutter:
3333
assets:
3434
- assets/flutter-mark-square-64.png
3535
- assets/Butterfly-209.mp4
36+
37+
38+
# FOR TESTING ONLY. DO NOT MERGE.
39+
dependency_overrides:
40+
video_player_avfoundation:
41+
path: ../../../video_player/video_player_avfoundation

packages/video_player/video_player_avfoundation/ios/Classes/FLTVideoPlayerPlugin.m

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,11 @@ - (int64_t)duration {
403403
return FLTCMTimeToMillis([[[_player currentItem] asset] duration]);
404404
}
405405

406-
- (void)seekTo:(int)location {
407-
// TODO(stuartmorgan): Update this to use completionHandler: to only return
408-
// once the seek operation is complete once the Pigeon API is updated to a
409-
// version that handles async calls.
406+
- (void)seekTo:(int)location completionHandler:(void (^)(BOOL))completionHandler {
410407
[_player seekToTime:CMTimeMake(location, 1000)
411-
toleranceBefore:kCMTimeZero
412-
toleranceAfter:kCMTimeZero];
408+
toleranceBefore:kCMTimeZero
409+
toleranceAfter:kCMTimeZero
410+
completionHandler:completionHandler];
413411
}
414412

415413
- (void)setIsLooping:(BOOL)isLooping {
@@ -636,10 +634,14 @@ - (FLTPositionMessage *)position:(FLTTextureMessage *)input error:(FlutterError
636634
return result;
637635
}
638636

639-
- (void)seekTo:(FLTPositionMessage *)input error:(FlutterError **)error {
637+
- (void)seekTo:(FLTPositionMessage *)input
638+
completion:(void (^)(FlutterError *_Nullable))completion {
640639
FLTVideoPlayer *player = self.playersByTextureId[input.textureId];
641-
[player seekTo:input.position.intValue];
642-
[self.registry textureFrameAvailable:input.textureId.intValue];
640+
[player seekTo:input.position.intValue
641+
completionHandler:^(BOOL finished) {
642+
[self.registry textureFrameAvailable:input.textureId.intValue];
643+
completion(nil);
644+
}];
643645
}
644646

645647
- (void)pause:(FLTTextureMessage *)input error:(FlutterError **)error {

0 commit comments

Comments
 (0)