Skip to content
Merged
Prev Previous commit
Next Next commit
Merge branch 'main' into speed_reset
  • Loading branch information
misos1 authored Nov 22, 2024
commit 7755c4f71a7cb51595410dad39dea8181758bcaf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

* Fixes playback speed resetting.

## 2.6.3

* Fixes VideoPlayerController.initialize() future never resolving with invalid video file.
* Adds more details to the error message returned by VideoPlayerController.initialize().

## 2.6.2

* Updates Pigeon for non-nullable collection type support.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,39 @@ - (void)testPublishesInRegistration {
XCTAssertTrue([publishedValue isKindOfClass:[FVPVideoPlayerPlugin class]]);
}

- (void)testFailedToLoadVideoEventShouldBeAlwaysSent {
NSObject<FlutterPluginRegistrar> *registrar =
[GetPluginRegistry() registrarForPlugin:@"testFailedToLoadVideoEventShouldBeAlwaysSent"];
FVPVideoPlayerPlugin *videoPlayerPlugin =
[[FVPVideoPlayerPlugin alloc] initWithRegistrar:registrar];
FlutterError *error;

[videoPlayerPlugin initialize:&error];

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

[self keyValueObservingExpectationForObject:(id)player.player.currentItem
keyPath:@"status"
expectedValue:@(AVPlayerItemStatusFailed)];
[self waitForExpectationsWithTimeout:10.0 handler:nil];

XCTestExpectation *failedExpectation = [self expectationWithDescription:@"failed"];
[player onListenWithArguments:nil
eventSink:^(FlutterError *event) {
if ([event isKindOfClass:FlutterError.class]) {
[failedExpectation fulfill];
}
}];
[self waitForExpectationsWithTimeout:10.0 handler:nil];
}

- (void)testUpdatePlayingStateShouldNotResetRate {
NSObject<FlutterPluginRegistrar> *registrar =
[GetPluginRegistry() registrarForPlugin:@"testUpdatePlayingStateShouldNotResetRate"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,32 @@ - (void)updateRate {
_player.rate = speed;
}

- (void)sendFailedToLoadVideoEvent {
if (_eventSink == nil) {
return;
}
// Prefer more detailed error information from tracks loading.
NSError *error;
if ([self.player.currentItem.asset statusOfValueForKey:@"tracks"
error:&error] != AVKeyValueStatusFailed) {
error = self.player.currentItem.error;
}
__block NSMutableOrderedSet<NSString *> *details =
[NSMutableOrderedSet orderedSetWithObject:@"Failed to load video"];
void (^add)(NSString *) = ^(NSString *detail) {
if (detail != nil) {
[details addObject:detail];
}
};
NSError *underlyingError = error.userInfo[NSUnderlyingErrorKey];
add(error.localizedDescription);
add(error.localizedFailureReason);
add(underlyingError.localizedDescription);
add(underlyingError.localizedFailureReason);
NSString *message = [details.array componentsJoinedByString:@": "];
_eventSink([FlutterError errorWithCode:@"VideoError" message:message details:nil]);
}

- (void)setupEventSinkIfReadyToPlay {
if (_eventSink && !_isInitialized) {
AVPlayerItem *currentItem = self.player.currentItem;
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.