我試圖構建一個應用程序,它可以從URL播放視頻並同時使用前置攝像頭錄製視頻。我試過了,但是當相機開始拍攝時視頻停止播放,反之亦然。請幫助我。提前致謝!! 這裏是我的代碼,我使用DIYCam(使用AVFoundation)框架,它完美記錄,並使用AVPlayer播放從URL播放視頻並通過相機同時錄製視頻 - 目標C
- (IBAction)startRecording:(id)sender {
self.cam = [[DIYCam alloc] initWithFrame:CGRectMake(0, 0, 320, 300)];
self.cam.layer.anchorPoint = CGPointMake(0.f, 0.f);
self.cam.frame = CGRectMake(0, 0, 320, 300);
self.cam.delegate = self;
[self.cam setupWithOptions:nil];
[self.cam setCamMode:DIYAVModeVideo];
self.cam.backgroundColor = [UIColor greenColor];
[self.cam captureVideoStart];
}
- (空)的playVideo {
NSURL *url = [[NSBundle mainBundle] URLForResource:@"responcevideo"
withExtension:@"mp4"
subdirectory:nil];
AVPlayer *_avPlayer;
_avPlayer = [AVPlayer playerWithURL:url] ;
AVPlayerLayer * _avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:_avPlayer];
_avPlayerLayer.frame = self.view.layer.bounds;
[self.view.layer addSublayer:_avPlayerLayer];
[_avPlayer play];
}
你能分享一些代碼嗎? – bryanmac 2013-03-07 12:41:54
用相機記錄視頻......在播放視頻時?好奇目的是什麼? – 2013-03-07 12:43:04
這也是我的問題... – MJB 2013-03-07 12:43:27