Something like this I want to add current timestamp when recording is done in the video and save into camera roll.
**Note **: I have successfully added current location and timestamp in AVVideoPreviewLayer but it is static after exporting video is show static time does not show running timestamp
Try creating a layer of previewLayer: UIView with the components you want to have on camera.
Add this layer to currently running session of AVCaptureVideoPreviewLayer.
This link might help you to achieve your problem
Adding objects over camera view in app (Swift 3) not under camera view?
I tried something out. I guess you want to get latitude, longitude and the timestamp.
You find an example for latitude and longitude below.
import UIKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
var locationManager: CLLocationManager!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func showLocation(_ sender: Any) {
locationManager = CLLocationManager()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestAlwaysAuthorization()
if(CLLocationManager.locationServicesEnabled()){
locationManager.startUpdatingLocation()
}
locationManager.stopUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let userLocation:CLLocation = locations[0] as CLLocation
print("user latitude = \(userLocation.coordinate.latitude)")
print("user longitude = \(userLocation.coordinate.longitude)")
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error)
{
print("Error \(error)")
}
}
To get the current time you can use something like this:
let date = NSDate()
print(date)
The result for both in console should look something like this:
2017-12-17 21:45:39 +0000
user latitude = 37.3322499
user longitude = -122.056264
(The time looks like this in my example because im from EU but you can convert it to what you want)
You can add this to a separate view and bring it to front with
view.bringSubview(toFront: YourView)
I hope this is helpful!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With