iPhone App - 在横向模式下显示 AVFoundation 视频

标签 iphone video rotation avfoundation avcam

我正在使用 Apple 的 AVCam 示例应用程序。

此示例使用 AVFoundation 以便在 View 上显示视频。

我正在尝试从 AVCam 制作一个风景应用程序,但运气不佳。

当屏幕方向改变时,视频在 View 上旋转显示。有没有办法处理这个问题?

最佳答案

当您创建预览层时:

captureVideoPreviewLayer.orientation = UIInterfaceOrientationLandscapeLeft;

以及管理轮换的方法:

-(void)willAnimateRotationToInterfaceOrientation:
        (UIInterfaceOrientation)toInterfaceOrientation 
        duration:(NSTimeInterval)duration {

  [CATransaction begin];
  if (toInterfaceOrientation==UIInterfaceOrientationLandscapeLeft){
    captureVideoPreviewLayer.orientation = UIInterfaceOrientationLandscapeLeft;
  } else {        
    captureVideoPreviewLayer.orientation = UIInterfaceOrientationLandscapeLeft;
  }

 [CATransaction commit];
 [super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
}

-(BOOL)shouldAutorotateToInterfaceOrientation:
        (UIInterfaceOrientation)interfaceOrientation {

  [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft animated:NO];

  return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

这对我有用。

关于iPhone App - 在横向模式下显示 AVFoundation 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6284650/

相关文章:

ios - 我在哪里可以找到用于启动 xamarin IOS 应用程序的 iphone 模拟器

video - 将 mp3 转换为 mp4

android - 使用 min3d/Rajawali 框架(android)在触摸时围绕 3d 对象旋转

r - 为什么矩阵到栅格显示旋转?

iphone - 通过prepareForSegue传递信息时出现问题,我无法弄清楚

iphone - iOS 是否支持 HTTP Live Streaming 之外的任何内容?

iphone - 更新导航栏

video - 使用 GStreamer(不是 ffmpeg)将视频转换为图像序列

android - 在 android 上的 hls 流上选择质量视频

java - Java中使用旋转矩阵旋转矩形