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

Commit

Permalink
[video_player] Update texture on seekTo (#2758)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinTheGray authored Dec 22, 2021
1 parent 19468e0 commit 09c61ea
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/video_player/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.2.10

* iOS: Updates texture on `seekTo`.

## 2.2.9

* Adds compatibility with `video_player_platform_interface` 5.0, which does not
Expand Down
1 change: 1 addition & 0 deletions packages/video_player/video_player/example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
pod 'OCMock', '3.5'
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,37 @@
@import video_player;
@import XCTest;

#import <OCMock/OCMock.h>

@interface VideoPlayerTests : XCTestCase
@end

@implementation VideoPlayerTests

- (void)testPlugin {
FLTVideoPlayerPlugin* plugin = [[FLTVideoPlayerPlugin alloc] init];
FLTVideoPlayerPlugin *plugin = [[FLTVideoPlayerPlugin alloc] init];
XCTAssertNotNil(plugin);
}

- (void)testSeekToInvokesTextureFrameAvailableOnTextureRegistry {
NSObject<FlutterTextureRegistry> *mockTextureRegistry =
OCMProtocolMock(@protocol(FlutterTextureRegistry));
NSObject<FlutterPluginRegistry> *registry =
(NSObject<FlutterPluginRegistry> *)[[UIApplication sharedApplication] delegate];
NSObject<FlutterPluginRegistrar> *registrar =
[registry registrarForPlugin:@"TEST_FLTVideoPlayerPlugin"];
NSObject<FlutterPluginRegistrar> *partialRegistrar = OCMPartialMock(registrar);
OCMStub([partialRegistrar textures]).andReturn(mockTextureRegistry);
[FLTVideoPlayerPlugin registerWithRegistrar:partialRegistrar];
FLTVideoPlayerPlugin<FLTVideoPlayerApi> *videoPlayerPlugin =
(FLTVideoPlayerPlugin<FLTVideoPlayerApi> *)[[FLTVideoPlayerPlugin alloc]
initWithRegistrar:partialRegistrar];
FLTPositionMessage *message = [[FLTPositionMessage alloc] init];
message.textureId = @101;
message.position = @0;
FlutterError *error;
[videoPlayerPlugin seekTo:message error:&error];
OCMVerify([mockTextureRegistry textureFrameAvailable:message.textureId.intValue]);
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
#import <Flutter/Flutter.h>

@interface FLTVideoPlayerPlugin : NSObject <FlutterPlugin>
- (instancetype)initWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar;
@end
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ - (FLTPositionMessage*)position:(FLTTextureMessage*)input error:(FlutterError**)
- (void)seekTo:(FLTPositionMessage*)input error:(FlutterError**)error {
FLTVideoPlayer* player = _players[input.textureId];
[player seekTo:[input.position intValue]];
[_registry textureFrameAvailable:input.textureId.intValue];
}

- (void)pause:(FLTTextureMessage*)input error:(FlutterError**)error {
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player/video_player/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for displaying inline video with other Flutter
widgets on Android, iOS, and web.
repository: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
version: 2.2.9
version: 2.2.10

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down

0 comments on commit 09c61ea

Please sign in to comment.