如何在录制iphone5 IOS时使用振动? [英] how to use Vibration while recording iphone5 IOS?

查看:141
本文介绍了如何在录制iphone5 IOS时使用振动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发iphone5应用程序,我需要一些关于振动电机的建议。
i护目镜,但无法找到我如何从代码手动旋转我的iPhone。请指导我...或提供任何链接或想法..

I am working on a iphone5 app and i need some advice on the vibration motor. i goggled the things but cant find how can i manually rotate my iPhone from the code.please guide me... or give any link or ideas..

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

What i want to do is vibrate the phone while recordign the video .

但我的问题是当我开始振动时它无法重新录制视频..我发现它会当音频正在捕捉运行时不起作用..所以我尝试在录音时静音但是它仍然不能正常工作

but my problem is when i start the vibration it cant recrod the video.. i found that it will not work when audio is capturing running.. so i tried with mute the sound while recording but its not working still

以下是我的代码..

//
//  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

我是振动我的手机,但它的工作振动或视频录制...如果视频将录制没有声音,那么即使它对我来说是好的..

i am vibrating my phone with this but its working vibrating or video recording...if video will record with no sound then even its ok for me..

while(TRUE){

        AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

    }

谢谢

推荐答案

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

I'm guessing the recording APIs might internally disable vibration (and other system sounds too) because vibration during recording would seriously degrade the video and audio quality of the recording.

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

Of course I'm only guessing. That seems like the sort of thing Apple might do, and I think in most cases that's what you would want (e.g., you wouldn't want a recording to be ruined by an incoming text message or phone call). I'm curious why you want to vibrate the device during recording - is it for a special effect?

这篇关于如何在录制iphone5 IOS时使用振动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆