Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
c8a3100b
Commit
c8a3100b
authored
Dec 15, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated CaptureSession internals for setting modes, with example UI update
parent
12d8b112
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
36 deletions
+29
-36
Examples/Programmatic/CaptureView/CaptureView/Assets.xcassets/ic_switch_camera_white.imageset/Contents.json
+0
-24
Examples/Programmatic/CaptureView/CaptureView/Assets.xcassets/ic_switch_camera_white.imageset/ic_switch_camera_white.png
+0
-0
Examples/Programmatic/CaptureView/CaptureView/Assets.xcassets/ic_switch_camera_white.imageset/ic_switch_camera_white@2x.png
+0
-0
Examples/Programmatic/CaptureView/CaptureView/Assets.xcassets/ic_switch_camera_white.imageset/ic_switch_camera_white@3x.png
+0
-0
Examples/Programmatic/CaptureView/CaptureView/ViewController.swift
+19
-9
Sources/CaptureSession.swift
+10
-3
No files found.
Examples/Programmatic/CaptureView/CaptureView/Assets.xcassets/ic_switch_camera_white.imageset/Contents.json
deleted
100644 → 0
View file @
12d8b112
{
"images"
:
[
{
"idiom"
:
"universal"
,
"filename"
:
"ic_switch_camera_white.png"
,
"scale"
:
"1x"
},
{
"idiom"
:
"universal"
,
"filename"
:
"ic_switch_camera_white@2x.png"
,
"scale"
:
"2x"
},
{
"idiom"
:
"universal"
,
"filename"
:
"ic_switch_camera_white@3x.png"
,
"scale"
:
"3x"
}
],
"info"
:
{
"version"
:
1
,
"author"
:
"xcode"
}
}
\ No newline at end of file
Examples/Programmatic/CaptureView/CaptureView/Assets.xcassets/ic_switch_camera_white.imageset/ic_switch_camera_white.png
deleted
100644 → 0
View file @
12d8b112
169 Bytes
Examples/Programmatic/CaptureView/CaptureView/Assets.xcassets/ic_switch_camera_white.imageset/ic_switch_camera_white@2x.png
deleted
100644 → 0
View file @
12d8b112
259 Bytes
Examples/Programmatic/CaptureView/CaptureView/Assets.xcassets/ic_switch_camera_white.imageset/ic_switch_camera_white@3x.png
deleted
100644 → 0
View file @
12d8b112
379 Bytes
Examples/Programmatic/CaptureView/CaptureView/ViewController.swift
View file @
c8a3100b
...
@@ -127,7 +127,7 @@ class ViewController: UIViewController, CapturePreviewViewDelegate, CaptureSessi
...
@@ -127,7 +127,7 @@ class ViewController: UIViewController, CapturePreviewViewDelegate, CaptureSessi
:name: prepareSwitchCameraButton
:name: prepareSwitchCameraButton
*/
*/
private
func
prepareSwitchCameraButton
()
{
private
func
prepareSwitchCameraButton
()
{
let
img
:
UIImage
?
=
UIImage
(
named
:
"ic_
switch_camera
_white"
)
let
img
:
UIImage
?
=
UIImage
(
named
:
"ic_
camera_front
_white"
)
switchCameraButton
.
pulseColor
=
MaterialColor
.
white
switchCameraButton
.
pulseColor
=
MaterialColor
.
white
switchCameraButton
.
pulseFill
=
true
switchCameraButton
.
pulseFill
=
true
switchCameraButton
.
setImage
(
img
,
forState
:
.
Normal
)
switchCameraButton
.
setImage
(
img
,
forState
:
.
Normal
)
...
@@ -139,6 +139,8 @@ class ViewController: UIViewController, CapturePreviewViewDelegate, CaptureSessi
...
@@ -139,6 +139,8 @@ class ViewController: UIViewController, CapturePreviewViewDelegate, CaptureSessi
:name: prepareFlashButton
:name: prepareFlashButton
*/
*/
private
func
prepareFlashButton
()
{
private
func
prepareFlashButton
()
{
captureView
.
captureSession
.
flashMode
=
.
Auto
let
img
:
UIImage
?
=
UIImage
(
named
:
"ic_flash_auto_white"
)
let
img
:
UIImage
?
=
UIImage
(
named
:
"ic_flash_auto_white"
)
flashButton
.
pulseColor
=
MaterialColor
.
white
flashButton
.
pulseColor
=
MaterialColor
.
white
flashButton
.
pulseFill
=
true
flashButton
.
pulseFill
=
true
...
@@ -176,7 +178,18 @@ class ViewController: UIViewController, CapturePreviewViewDelegate, CaptureSessi
...
@@ -176,7 +178,18 @@ class ViewController: UIViewController, CapturePreviewViewDelegate, CaptureSessi
:name: handleSwitchCameraButton
:name: handleSwitchCameraButton
*/
*/
internal
func
handleSwitchCameraButton
(
button
:
UIButton
)
{
internal
func
handleSwitchCameraButton
(
button
:
UIButton
)
{
captureView
.
captureSession
.
switchCameras
()
var
img
:
UIImage
?
if
.
Back
==
captureView
.
captureSession
.
cameraPosition
{
img
=
UIImage
(
named
:
"ic_camera_rear_white"
)
captureView
.
captureSession
.
switchCameras
()
}
else
if
.
Front
==
captureView
.
captureSession
.
cameraPosition
{
img
=
UIImage
(
named
:
"ic_camera_front_white"
)
captureView
.
captureSession
.
switchCameras
()
}
switchCameraButton
.
setImage
(
img
,
forState
:
.
Normal
)
switchCameraButton
.
setImage
(
img
,
forState
:
.
Highlighted
)
}
}
/**
/**
...
@@ -189,19 +202,16 @@ class ViewController: UIViewController, CapturePreviewViewDelegate, CaptureSessi
...
@@ -189,19 +202,16 @@ class ViewController: UIViewController, CapturePreviewViewDelegate, CaptureSessi
case
.
Off
:
case
.
Off
:
img
=
UIImage
(
named
:
"ic_flash_on_white"
)
img
=
UIImage
(
named
:
"ic_flash_on_white"
)
captureView
.
captureSession
.
flashMode
=
.
On
captureView
.
captureSession
.
flashMode
=
.
On
print
(
"On"
)
case
.
On
:
case
.
On
:
img
=
UIImage
(
named
:
"ic_flash_auto_white"
)
img
=
UIImage
(
named
:
"ic_flash_auto_white"
)
captureView
.
captureSession
.
flashMode
=
.
Off
captureView
.
captureSession
.
flashMode
=
.
Auto
print
(
"Auto"
)
case
.
Auto
:
case
.
Auto
:
img
=
UIImage
(
named
:
"ic_flash_off_white"
)
img
=
UIImage
(
named
:
"ic_flash_off_white"
)
captureView
.
captureSession
.
flashMode
=
.
On
captureView
.
captureSession
.
flashMode
=
.
Off
print
(
"Off"
)
}
}
captureView
.
flashButton
?
.
setImage
(
img
,
forState
:
.
Normal
)
flashButton
.
setImage
(
img
,
forState
:
.
Normal
)
captureView
.
flashButton
?
.
setImage
(
img
,
forState
:
.
Highlighted
)
flashButton
.
setImage
(
img
,
forState
:
.
Highlighted
)
}
}
/**
/**
...
...
Sources/CaptureSession.swift
View file @
c8a3100b
...
@@ -194,6 +194,13 @@ public class CaptureSession : NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -194,6 +194,13 @@ public class CaptureSession : NSObject, AVCaptureFileOutputRecordingDelegate {
}
}
/**
/**
:name: cameraPosition
*/
public
var
cameraPosition
:
AVCaptureDevicePosition
{
return
activeCamera
!.
position
}
/**
:name: focusMode
:name: focusMode
*/
*/
public
var
focusMode
:
AVCaptureFocusMode
{
public
var
focusMode
:
AVCaptureFocusMode
{
...
@@ -206,7 +213,7 @@ public class CaptureSession : NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -206,7 +213,7 @@ public class CaptureSession : NSObject, AVCaptureFileOutputRecordingDelegate {
do
{
do
{
let
device
:
AVCaptureDevice
=
activeCamera
!
let
device
:
AVCaptureDevice
=
activeCamera
!
try
device
.
lockForConfiguration
()
try
device
.
lockForConfiguration
()
device
.
focusMode
=
focusMod
e
device
.
focusMode
=
valu
e
device
.
unlockForConfiguration
()
device
.
unlockForConfiguration
()
}
catch
let
e
as
NSError
{
}
catch
let
e
as
NSError
{
error
=
e
error
=
e
...
@@ -233,7 +240,7 @@ public class CaptureSession : NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -233,7 +240,7 @@ public class CaptureSession : NSObject, AVCaptureFileOutputRecordingDelegate {
do
{
do
{
let
device
:
AVCaptureDevice
=
activeCamera
!
let
device
:
AVCaptureDevice
=
activeCamera
!
try
device
.
lockForConfiguration
()
try
device
.
lockForConfiguration
()
device
.
flashMode
=
flashMod
e
device
.
flashMode
=
valu
e
device
.
unlockForConfiguration
()
device
.
unlockForConfiguration
()
}
catch
let
e
as
NSError
{
}
catch
let
e
as
NSError
{
error
=
e
error
=
e
...
@@ -260,7 +267,7 @@ public class CaptureSession : NSObject, AVCaptureFileOutputRecordingDelegate {
...
@@ -260,7 +267,7 @@ public class CaptureSession : NSObject, AVCaptureFileOutputRecordingDelegate {
do
{
do
{
let
device
:
AVCaptureDevice
=
activeCamera
!
let
device
:
AVCaptureDevice
=
activeCamera
!
try
device
.
lockForConfiguration
()
try
device
.
lockForConfiguration
()
device
.
torchMode
=
torchMod
e
device
.
torchMode
=
valu
e
device
.
unlockForConfiguration
()
device
.
unlockForConfiguration
()
}
catch
let
e
as
NSError
{
}
catch
let
e
as
NSError
{
error
=
e
error
=
e
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment