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

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

问题描述

我正在开发一个 iphone5 应用程序,我需要一些关于振动电机的建议.我盯着这些东西,但找不到如何从代码中手动旋转我的 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天全站免登陆