Reputation: 121
how can i develop or is there any way to achieve the flashlight flash on the beat of the music?
i have search over google for the functionality but won't found anything that will draw me the exact way so i would like to have some expert advice that if anyone had done that before or have an idea how to do it?
looking for something like this video
i know how to turn on and off the flash light here is the code but don't know how to handle that on beat of music
-(void) turnTorchOn: (bool) on
{
Class captureDeviceClass = NSClassFromString(@"AVCaptureDevice");
if (captureDeviceClass != nil) {
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if ([device hasTorch] && [device hasFlash]){
[device lockForConfiguration:nil];
if (on) {
[device setTorchMode:AVCaptureTorchModeOn];
[device setFlashMode:AVCaptureFlashModeOn];
torchIsOn = YES;
} else {
[device setTorchMode:AVCaptureTorchModeOff];
[device setFlashMode:AVCaptureFlashModeOff];
torchIsOn = NO;
}
[device unlockForConfiguration];
}
}
}
please help thanks in advance :)
Upvotes: 2
Views: 1571
Reputation: 760
Having no knowledge whatsoever regarding Audio-technology I have stumbled upon a tutorial that should help you out pretty easily. The tutorial is for a music visualizer however the foundation is alike.
http://www.raywenderlich.com/36475/how-to-make-a-music-visualizer-in-ios
Upvotes: 1