gpt4 book ai didi

iphone - iphone5 IOS录音时如何使用振动?

转载 作者:搜寻专家 更新时间:2023-10-30 19:49:09 25 4
gpt4 key购买 nike

我正在开发 iphone5 应用程序,我需要一些关于振动电机的建议。我用眼睛盯着这些东西,但找不到如何从代码中手动旋转我的 iPhone。请指导我......或提供任何链接或想法......

我想做的是在录制视频时让手机振动。

但我的问题是,当我开始振动时,它无法录制视频。我发现它在捕获正在运行的音频时不起作用。所以我尝试在录制时将声音静音,但它仍然无法正常工作

以下是我的代码..

//
// APPViewController.m
//
//
// Created by Rafael Garcia Leiva on 29/04/13.
// Copyright (c) 2013 Appcoda. All rights reserved.
//

#import "APPViewController.h"
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>

@interface APPViewController ()

@end

@implementation APPViewController

- (void)viewDidLoad {

[super viewDidLoad];



}

- (void)viewDidAppear:(BOOL)animated {

self.movieController = [[MPMoviePlayerController alloc] init];
[self.movieController setContentURL:self.movieURL];

[self.movieController.view setFrame:CGRectMake ( 0, 0, 320, 476)];

[self.view addSubview:self.movieController.view];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.movieController];

[[MPMusicPlayerController applicationMusicPlayer] setVolume:0];

[self.movieController play];

[self setupAudio];



}

- (IBAction)takeVideo:(UIButton *)sender {

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeMovie, nil];




[self presentViewController:picker animated:YES completion:NULL];
while(TRUE){

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

}



}

- (void)setupAudio {
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil];
UInt32 doSetProperty = 1;
AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(doSetProperty), &doSetProperty);
[[AVAudioSession sharedInstance] setActive: YES error: nil];
}


- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

self.movieURL = info[UIImagePickerControllerMediaURL];

[picker dismissViewControllerAnimated:YES completion:NULL];

}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {

[picker dismissViewControllerAnimated:YES completion:NULL];

}

- (void)moviePlayBackDidFinish:(NSNotification *)notification {

[[NSNotificationCenter defaultCenter]removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:nil];

[self.movieController stop];
[self.movieController.view removeFromSuperview];
self.movieController = nil;

}

@end

我正在用它振动我的手机,但它正在振动或正在录制视频...如果录制视频时没有声音,那么对我来说就没问题了..

while(TRUE){

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

}

谢谢

最佳答案

我猜测录制 API 可能会在内部禁用振动(以及其他系统声音),因为录制期间的振动会严重降低录制的视频和音频质量。

当然,我只是猜测。这似乎是 Apple 可能会做的事情,而且我认为在大多数情况下这就是您想要的(例如,您不希望录音被传入的短信或电话破坏)。我很好奇你为什么要在录音时振动设备 - 是为了特殊效果吗?

关于iphone - iphone5 IOS录音时如何使用振动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21059607/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com