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

Commit 09c61ea

Browse files
authored
[video_player] Update texture on seekTo (#2758)
1 parent 19468e0 commit 09c61ea

File tree

6 files changed

+32
-2
lines changed

6 files changed

+32
-2
lines changed

packages/video_player/video_player/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.2.10
2+
3+
* iOS: Updates texture on `seekTo`.
4+
15
## 2.2.9
26

37
* Adds compatibility with `video_player_platform_interface` 5.0, which does not

packages/video_player/video_player/example/ios/Podfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ target 'Runner' do
3131
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
3232
target 'RunnerTests' do
3333
inherit! :search_paths
34+
pod 'OCMock', '3.5'
3435
end
3536
end
3637

packages/video_player/video_player/example/ios/RunnerTests/VideoPlayerTests.m

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,37 @@
55
@import video_player;
66
@import XCTest;
77

8+
#import <OCMock/OCMock.h>
9+
810
@interface VideoPlayerTests : XCTestCase
911
@end
1012

1113
@implementation VideoPlayerTests
1214

1315
- (void)testPlugin {
14-
FLTVideoPlayerPlugin* plugin = [[FLTVideoPlayerPlugin alloc] init];
16+
FLTVideoPlayerPlugin *plugin = [[FLTVideoPlayerPlugin alloc] init];
1517
XCTAssertNotNil(plugin);
1618
}
1719

20+
- (void)testSeekToInvokesTextureFrameAvailableOnTextureRegistry {
21+
NSObject<FlutterTextureRegistry> *mockTextureRegistry =
22+
OCMProtocolMock(@protocol(FlutterTextureRegistry));
23+
NSObject<FlutterPluginRegistry> *registry =
24+
(NSObject<FlutterPluginRegistry> *)[[UIApplication sharedApplication] delegate];
25+
NSObject<FlutterPluginRegistrar> *registrar =
26+
[registry registrarForPlugin:@"TEST_FLTVideoPlayerPlugin"];
27+
NSObject<FlutterPluginRegistrar> *partialRegistrar = OCMPartialMock(registrar);
28+
OCMStub([partialRegistrar textures]).andReturn(mockTextureRegistry);
29+
[FLTVideoPlayerPlugin registerWithRegistrar:partialRegistrar];
30+
FLTVideoPlayerPlugin<FLTVideoPlayerApi> *videoPlayerPlugin =
31+
(FLTVideoPlayerPlugin<FLTVideoPlayerApi> *)[[FLTVideoPlayerPlugin alloc]
32+
initWithRegistrar:partialRegistrar];
33+
FLTPositionMessage *message = [[FLTPositionMessage alloc] init];
34+
message.textureId = @101;
35+
message.position = @0;
36+
FlutterError *error;
37+
[videoPlayerPlugin seekTo:message error:&error];
38+
OCMVerify([mockTextureRegistry textureFrameAvailable:message.textureId.intValue]);
39+
}
40+
1841
@end

packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
#import <Flutter/Flutter.h>
66

77
@interface FLTVideoPlayerPlugin : NSObject <FlutterPlugin>
8+
- (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar;
89
@end

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ - (FLTPositionMessage*)position:(FLTTextureMessage*)input error:(FlutterError**)
616616
- (void)seekTo:(FLTPositionMessage*)input error:(FlutterError**)error {
617617
FLTVideoPlayer* player = _players[input.textureId];
618618
[player seekTo:[input.position intValue]];
619+
[_registry textureFrameAvailable:input.textureId.intValue];
619620
}
620621

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

packages/video_player/video_player/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for displaying inline video with other Flutter
33
widgets on Android, iOS, and web.
44
repository: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
6-
version: 2.2.9
6+
version: 2.2.10
77

88
environment:
99
sdk: ">=2.14.0 <3.0.0"

0 commit comments

Comments
 (0)