mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
iPad: disable video preview on main screen when 'Enable video' setting is off
This commit is contained in:
parent
35f865151b
commit
3c3bdfe1a8
2 changed files with 37 additions and 17 deletions
|
|
@ -39,19 +39,11 @@
|
|||
}
|
||||
*/
|
||||
|
||||
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
-(void) initVideoPreview {
|
||||
session = [[AVCaptureSession alloc] init];
|
||||
|
||||
|
||||
|
||||
currentCamera = 0;
|
||||
|
||||
|
||||
|
||||
AVCaptureVideoPreviewLayer* previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:session];
|
||||
|
||||
previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
|
||||
|
|
@ -62,7 +54,19 @@
|
|||
[session setSessionPreset:AVCaptureSessionPresetHigh];
|
||||
[session commitConfiguration];
|
||||
|
||||
[self useCameraAtIndex:0 startSession:NO];
|
||||
[self useCameraAtIndex:0 startSession:NO];
|
||||
}
|
||||
|
||||
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
bool enableVideo = [[NSUserDefaults standardUserDefaults] boolForKey:@"enable_video_preference"];
|
||||
|
||||
if (enableVideo) {
|
||||
[self initVideoPreview ];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) switchCameraPressed {
|
||||
|
|
@ -94,18 +98,31 @@
|
|||
|
||||
|
||||
-(void) showPreview:(BOOL) show {
|
||||
if (show && !session.running) {
|
||||
[window addSubview:self.view];
|
||||
[window sendSubviewToBack:self.view];
|
||||
[session startRunning];
|
||||
} else if (!show && session.running) {
|
||||
bool enableVideo = [[NSUserDefaults standardUserDefaults] boolForKey:@"enable_video_preference"];
|
||||
|
||||
if (enableVideo) {
|
||||
if (session == nil) {
|
||||
[self initVideoPreview];
|
||||
}
|
||||
|
||||
if (show && !session.running) {
|
||||
[window addSubview:self.view];
|
||||
[window sendSubviewToBack:self.view];
|
||||
[session startRunning];
|
||||
} else if (!show && session.running) {
|
||||
[self.view removeFromSuperview];
|
||||
[session stopRunning];
|
||||
}
|
||||
} else {
|
||||
if (session != nil)
|
||||
[session stopRunning];
|
||||
[self.view removeFromSuperview];
|
||||
[session stopRunning];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) viewDidAppear:(BOOL)animated {
|
||||
[phoneMainView.switchCamera addTarget:self action:@selector(switchCameraPressed) forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
}
|
||||
|
||||
-(void) viewDidDisappear:(BOOL)animated {
|
||||
|
|
|
|||
|
|
@ -44,10 +44,11 @@
|
|||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrameSize">{768, 1024}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:196</string>
|
||||
<object class="NSColor" key="IBUIBackgroundColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MQA</bytes>
|
||||
<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
|
||||
</object>
|
||||
<bool key="IBUIOpaque">NO</bool>
|
||||
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
|
||||
|
|
@ -142,6 +143,7 @@
|
|||
<int key="NSvFlags">266</int>
|
||||
<string key="NSFrame">{{0, 975}, {768, 49}}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<object class="NSColor" key="IBUIBackgroundColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MCAwAA</bytes>
|
||||
|
|
@ -156,6 +158,7 @@
|
|||
<int key="NSvFlags">274</int>
|
||||
<string key="NSFrame">{{0, 20}, {768, 1004}}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:212</string>
|
||||
<object class="NSColor" key="IBUIBackgroundColor">
|
||||
<int key="NSColorSpace">1</int>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue