-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[video_player_avfoundation] Fix deprecated tracksWithMediaType usage #10553
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -82,32 +82,52 @@ - (instancetype)initWithPlayerItem:(AVPlayerItem *)item | |||||
| AVAsset *asset = [item asset]; | ||||||
| void (^assetCompletionHandler)(void) = ^{ | ||||||
| if ([asset statusOfValueForKey:@"tracks" error:nil] == AVKeyValueStatusLoaded) { | ||||||
| NSArray *tracks = [asset tracksWithMediaType:AVMediaTypeVideo]; | ||||||
| if ([tracks count] > 0) { | ||||||
| AVAssetTrack *videoTrack = tracks[0]; | ||||||
| void (^trackCompletionHandler)(void) = ^{ | ||||||
| if (self->_disposed) return; | ||||||
| if ([videoTrack statusOfValueForKey:@"preferredTransform" | ||||||
| error:nil] == AVKeyValueStatusLoaded) { | ||||||
| // Rotate the video by using a videoComposition and the preferredTransform | ||||||
| self->_preferredTransform = FVPGetStandardizedTransformForTrack(videoTrack); | ||||||
| // Do not use video composition when it is not needed. | ||||||
| if (CGAffineTransformIsIdentity(self->_preferredTransform)) { | ||||||
| return; | ||||||
| void (^processVideoTracks)(NSArray *) = ^(NSArray *tracks) { | ||||||
|
||||||
| void (^processVideoTracks)(NSArray *) = ^(NSArray *tracks) { | |
| void (^processVideoTracks)(NSArray<AVAssetTrack *> *) = ^(NSArray<AVAssetTrack *> *tracks) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The completion handler for loadTracksWithMediaType:completionHandler: checks for error == nil, but if an error occurs, it is not handled or logged. It's good practice to at least log the error to aid in debugging, even if no further action is taken.
if (error == nil && tracks != nil) {
processVideoTracks(tracks);
} else if (error != nil) {
NSLog(@"Error loading tracks: %@", error);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line
* ## 2.8.8appears to be a formatting error. It introduces a nested heading with an asterisk. It should likely be## 2.8.8without the asterisk, or the new entries should be placed directly under the existing## 2.8.8heading.