Skip to content

Commit

Permalink
fix(sampledisplaylayerrender): change bounds to enable videoGravity c…
Browse files Browse the repository at this point in the history
…hange

Signed-off-by: pingkai <[email protected]>
  • Loading branch information
pingkai committed Feb 9, 2021
1 parent 6f9f2ca commit aee6899
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ - (void)setVideoScale:(IVideoRender::Scale)scale
{
switch (scale) {
case IVideoRender::Scale_AspectFit:
videoGravity = AVLayerVideoGravityResizeAspectFill;
videoGravity = AVLayerVideoGravityResizeAspect;
break;
case IVideoRender::Scale_AspectFill:
videoGravity = AVLayerVideoGravityResizeAspectFill;
Expand All @@ -91,12 +91,15 @@ - (void)setVideoScale:(IVideoRender::Scale)scale
videoGravity = AVLayerVideoGravityResize;
break;
default:
break;
return;
}

if (self.displayLayer) {
dispatch_async(dispatch_get_main_queue(), ^{
self.displayLayer.videoGravity = AVLayerVideoGravityResizeAspect;
self.displayLayer.videoGravity = videoGravity;
CGRect bounds = self.displayLayer.bounds;
self.displayLayer.bounds = CGRectZero;
self.displayLayer.bounds = bounds;
});
}
}
Expand Down

0 comments on commit aee6899

Please sign in to comment.