rFlex / SCRecorder

iOS camera engine with Vine-like tap to record, animatable filters, slow motion, segments editing
Apache License 2.0
3.06k stars 583 forks source link

How to black out SCRecorder's SCImageView/previewLayer when app is backgrounded? #328

Open gadu opened 8 years ago

gadu commented 8 years ago

I'm using a custom SCFilterImageView on my SCRecorder.

When my app is backgrounded (and I also want this when viewWillDisappear is called) I call [self.recorder stopRunning]; to stop the camera. The issue is whatever frame was currently displaying when i called that, will stay on the previewLayer for the recorder until [self.recorder startRunning] starts supplying new sample buffers.

I hold a reference to the SCFilterImageView i use in my camera controller and I've been trying to clear it out by calling self.filterImageView.CIImage = nil; right before my call to [self.recorder stopRunning];

I assumed this would work because the GLKView's delegate method (glkView: drawInRect:) makes a call to render the current CIImage onto the GLKView

I also tried exposing the GLKView, so that I could call [self.filterImageView.GLKView deleteDrawable] and messing around with the glClear() function, but I don't really have experience with OpenGL ES 2.0 so I don't know if I should be messing with that (it also doesn't work).

Any help?

gadu commented 8 years ago

A few more details. If I run

self.filterImageView.CIImage = nil;
[self.recorder stopRunning];
self.filterImageView.CIImage = nil;

I can get it to successfully black out the previewLayer about 20% of the time. I'm guessing in the time it takes to stop running (or even if there are some buffers in the pipeline) the image gets replaced, so I'm not sure if this is reliable way to do it.

aprato commented 8 years ago

self.filterImageView.hidden = YES; ?