【发布时间】:2016-07-13 14:01:55
【问题描述】:
我在我的项目中使用AVPlayer 创建了一个视频播放器。我创建了播放、暂停和转发视频播放的选项。我现在面临一个问题,当用户旋转视频播放器时,要在 landscape(FULL SCREEN) 中显示视频播放器。我的应用仅适用于纵向。
请给我任何建议,让我的视频播放器全屏显示横向视频。
请在下面找到我用来创建avPlayer的代码
// self.avPlayer is @property(nonatomin,strong)AvPlayer avPlayer;
self.avPlayer= [[AVPlayer alloc] initWithURL:[NSURL fileURLWithPath:videoPath]];
layerr = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer];
AVPlayerItem *currentItem = self.avPlayer.currentItem;
currentTime = currentItem.cu`enter code here`rrentTime; //playing time
CMTime duration = self.avPlayer.currentItem.asset.duration;
float seconds = CMTimeGetSeconds(duration);
self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
layerr.frame = self.view.bounds;
[self.view.layer addSublayer: layerr];
[self.avPlayer play];
[self.view addSubview:self.btnPause];
【问题讨论】:
-
您是否在supportedInterfaceOrientations 中添加横向?
-
请查看解释如何设置支持的界面方向的答案
-
我的应用只能在纵向模式下工作。仅对于视频播放器,屏幕应变为横向。请为此掌舵。
标签: ios objective-c avplayer landscape-portrait screen-rotation