|
@@ -49,34 +49,41 @@ class NCAudioRecorderViewController: UIViewController , NCAudioRecorderDelegate
|
|
|
|
|
|
override func viewDidLoad() {
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
super.viewDidLoad()
|
|
|
|
+
|
|
|
|
+ voiceRecordHUD.update(0.0)
|
|
|
|
+ durationLabel.text = ""
|
|
|
|
+ startStopLabel.text = NSLocalizedString("_voice_memo_start_", comment: "")
|
|
|
|
+
|
|
|
|
+ setColors(userInterfaceStyle: nil)
|
|
}
|
|
}
|
|
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
super.viewWillAppear(animated)
|
|
super.viewWillAppear(animated)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
|
|
|
+ super.traitCollectionDidChange(previousTraitCollection)
|
|
|
|
|
|
- contentContainerView.backgroundColor = UIColor.lightGray
|
|
|
|
- voiceRecordHUD.update(0.0)
|
|
|
|
- voiceRecordHUD.fillColor = UIColor.green
|
|
|
|
- durationLabel.text = ""
|
|
|
|
- startStopLabel.text = NSLocalizedString("_voice_memo_start_", comment: "")
|
|
|
|
|
|
+ setColors(userInterfaceStyle: traitCollection.userInterfaceStyle)
|
|
}
|
|
}
|
|
|
|
|
|
- func createRecorder(fileName: String) {
|
|
|
|
|
|
+ // MARK: - Colors
|
|
|
|
+
|
|
|
|
+ func setColors(userInterfaceStyle: UIUserInterfaceStyle?) {
|
|
|
|
|
|
- self.fileName = fileName
|
|
|
|
- recording = NCAudioRecorder(to: fileName)
|
|
|
|
- recording.delegate = self
|
|
|
|
-
|
|
|
|
- DispatchQueue.global().async {
|
|
|
|
- // Background thread
|
|
|
|
- do {
|
|
|
|
- try self.recording.prepare()
|
|
|
|
- } catch {
|
|
|
|
- print(error)
|
|
|
|
- }
|
|
|
|
|
|
+ if userInterfaceStyle == .dark {
|
|
|
|
+ // personalized
|
|
|
|
+ } else {
|
|
|
|
+ // personalized
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ view.backgroundColor = .clear
|
|
|
|
+ contentContainerView.backgroundColor = UIColor.lightGray
|
|
|
|
+ voiceRecordHUD.fillColor = UIColor.green
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // MARK: - Action
|
|
|
|
+
|
|
@IBAction func touchViewController() {
|
|
@IBAction func touchViewController() {
|
|
|
|
|
|
if recording.state == .record {
|
|
if recording.state == .record {
|
|
@@ -111,6 +118,24 @@ class NCAudioRecorderViewController: UIViewController , NCAudioRecorderDelegate
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // MARK: - Code
|
|
|
|
+
|
|
|
|
+ func createRecorder(fileName: String) {
|
|
|
|
+
|
|
|
|
+ self.fileName = fileName
|
|
|
|
+ recording = NCAudioRecorder(to: fileName)
|
|
|
|
+ recording.delegate = self
|
|
|
|
+
|
|
|
|
+ DispatchQueue.global().async {
|
|
|
|
+ // Background thread
|
|
|
|
+ do {
|
|
|
|
+ try self.recording.prepare()
|
|
|
|
+ } catch {
|
|
|
|
+ print(error)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
func audioMeterDidUpdate(_ db: Float) {
|
|
func audioMeterDidUpdate(_ db: Float) {
|
|
|
|
|
|
//print("db level: %f", db)
|
|
//print("db level: %f", db)
|