Skip to content

Commit 8911fde

Browse files
😉 Flashlight: Add blink
1 parent 1e0ab88 commit 8911fde

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Sources/Control/Flashlight.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ extension Control.Flashlight {
4646
}
4747
}
4848

49+
public static func blink(count: Int = 1, interval: TimeInterval = 0.1) {
50+
Task {
51+
for _ in 0..<count {
52+
toggle()
53+
try? await Task.sleep(nanoseconds: UInt64(1e+9 * interval))
54+
toggle()
55+
}
56+
}
57+
}
58+
4959
private static var deviceWithFlashlight: AVCaptureDevice? {
5060
guard
5161
let device = AVCaptureDevice.default(for: .video),

0 commit comments

Comments
 (0)