我能够录制视频并将电影正确输出到文件中.但是,在尝试使用AVAudioPlayer播放某些音频时,我遇到了视频录制(没有视频输出)的问题.这是否意味着我不能同时使用AVCaptureSession和AVAudioPlayer?这是我创建捕获会话和播放音频的代码.首先启动视频捕获,然后在捕获期间,我想播放一些音频.非常感谢您的帮助.
用于创建捕获会话以记录视频(带音频)的代码 - 输出到.mov文件:
- (void)addVideoInput
AVCaptureDevice *audioDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
//... also some code for setting up videoDevice/frontCamera
NSError *error;
AVCaptureDeviceInput *videoIn = [AVCaptureDeviceInput
deviceInputWithDevice:frontCamera error:&error];
AVCaptureDeviceInput *audioIn = [AVCaptureDeviceInput
deviceInputWithDevice:audioDevice error:&error];
if (!error) {
if ([captureSession canAddInput:audioIn])
[captureSession addInput:audioIn];
else
NSLog(@"Couldn't add audio input.");
if ([captureSession canAddInput:videoIn])
[captureSession addInput:videoIn];
else
NSLog(@"Couldn't add video input.");
}
- (void)addVideoOutput
{
AVCaptureMovieFileOutput *m_captureFileOutput = [[AVCaptureMovieFileOutput alloc] init];
[captureSession addOutput:m_captureFileOutput];
[captureSession startRunning];
NSString *docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSMutableString *filePath = …Run Code Online (Sandbox Code Playgroud) 是否可以检测到每个被触摸的像素?更具体地,当用户触摸屏幕时,是否可以跟踪用户触摸的点群集的所有xy坐标?如何区分用户使用拇指绘图以及何时使用手指绘图?我想根据用户触摸屏幕的方式反映画笔差异,并且还想跟踪随时间触摸的所有像素的xy坐标.非常感谢您的帮助.
我正在尝试为我的视图实现UIPanGestureRecognizer.如何添加多点触控?下面是我视图中的代码(UIView的子类).我希望能够同时知道所有触摸的位置和速度.当前代码仅打印一次触摸的位置和速度.更改属性minimumNumberOfTouches和maximumNumberOfTouches不起作用.非常感谢您的帮助.
UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
panGestureRecognizer.cancelsTouchesInView = NO;
[self addGestureRecognizer:panGestureRecognizer];
- (void)handlePanGesture:(UIPanGestureRecognizer *)panGestureRecognizer
{
CGPoint location = [panGestureRecognizer locationInView:panGestureRecognizer.view];
CGPoint velocity = [panGestureRecognizer velocityInView:panGestureRecognizer.view];
NSLog(@"Location: %@", NSStringFromCGPoint(location));
NSLog(@"Velocity: %@", NSStringFromCGPoint(velocity));
}
Run Code Online (Sandbox Code Playgroud)