【问题标题】:control the camera flash iPhone控制相机闪光灯 iPhone
【发布时间】:2012-03-26 14:12:12
【问题描述】:

我想知道是否可以设置一个应用程序,以按摩尔斯电码或 SOS 信号或类似的顺序打开和关闭相机的闪光灯。我做了一些研究,但我没有找到任何结论性的东西。

有什么想法吗? :)

【问题讨论】:

  • 鉴于 App Store 中有应用程序可以做到这一点,是的,这完全有可能。
  • 谢谢让我知道这是可能的 :)

标签: iphone camera


【解决方案1】:

以下是打开手电筒的方法:

AVCaptureSession *session = [[AVCaptureSession alloc] init];

AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error: nil];
[session addInput:input];

AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init];
[session addOutput:output];

[session beginConfiguration];
[device lockForConfiguration:nil];

[device setTorchMode:AVCaptureTorchModeOn];

[device unlockForConfiguration];
[session commitConfiguration];

[session startRunning];

然后再次将其关闭:

[session stopRunning];

您需要使用NSTimer 之类的方法按照您想要的时间打开和关闭手电筒。

【讨论】:

    猜你喜欢
    • 2011-10-23
    • 2011-05-16
    • 1970-01-01
    • 2011-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多