[录制iphone5 IOS时如何使用振动?

问题描述 投票:4回答:2

我正在开发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);

    }

谢谢

我正在开发iphone5应用,我需要有关振动马达的一些建议。我扫了一眼东西,但找不到从代码中手动旋转iPhone的方法。请引导我...或提供任何链接...

iphone objective-c ios7 rotation vibration
2个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.