代码之家  ›  专栏  ›  技术社区  ›  ginger

如何发出iPhone默认快门声音[重复]

  •  -1
  • ginger  · 技术社区  · 8 年前

    这是一个规范,我点击拍摄按钮,并保存必要的帧作为一个静止图像的相机辊。

    (我不保存电影。)

    关于iPhone的快门声,我问你一个问题。

    我应该做什么样的编码才能发出iPhone默认的快门声音?

    首先,我使用AVCaptureVideoDataOutput创建了一个没有快门声音的相机应用程序。

    接下来,我想使用AVCaptureVideoDataOutput创建一个具有快门声音的相机。

    有没有办法强制发出iPhone默认的快门声音?

    补充

    代码8.3.3

    我想实现AVCaptureVideoDataOutput,因为我想在未来实现电影拍摄和静态拍摄。

    1 回复  |  直到 8 年前
        1
  •  0
  •   Pedro Pinho    8 年前

    使用此选项:

    AudioServicesPlaySystemSound(1108);
    

    Sounds

    对于自定义声音:

    AVAudioPlayer *audioPlayer;
    NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"Name of your audio file" 
                                                          ofType:@"type of your audio file example: mp3"];
    NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
    audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
    audioPlayer.numberOfLoops = -1;
    [audioPlayer play];
    

    <AVFoundation/AVFoundation.h>