Waiting for location in audio recordings
This commit is contained in:
parent
23cf2018ff
commit
e7e2cb311f
@ -1721,7 +1721,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 172;
|
CURRENT_PROJECT_VERSION = 173;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
||||||
@ -1750,7 +1750,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 172;
|
CURRENT_PROJECT_VERSION = 173;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
||||||
|
|||||||
@ -56,7 +56,7 @@ final class RecordsViewModel: ACHudContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func stopRecording() async {
|
func stopRecording() async {
|
||||||
await wrapWithToast { [weak self] in
|
await wrapWithToast(showProgress: false) { [weak self] in
|
||||||
guard let self else { return }
|
guard let self else { return }
|
||||||
let record = try await recordService.stopRecording()
|
let record = try await recordService.stopRecording()
|
||||||
try await storageService.add(record: record)
|
try await storageService.add(record: record)
|
||||||
|
|||||||
@ -18,10 +18,9 @@ public actor VehicleRecordService {
|
|||||||
|
|
||||||
var url: URL?
|
var url: URL?
|
||||||
var date = Date()
|
var date = Date()
|
||||||
var location: VehicleEventDto?
|
|
||||||
|
|
||||||
@AutoCancellable
|
@AutoCancellable
|
||||||
var locationTask: Task<Void,Error>?
|
var locationTask: Task<VehicleEventDto?,Error>?
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
recordService: AudioRecordServiceProtocol,
|
recordService: AudioRecordServiceProtocol,
|
||||||
@ -103,8 +102,18 @@ extension VehicleRecordService: VehicleRecordServiceProtocol {
|
|||||||
self.url = url
|
self.url = url
|
||||||
|
|
||||||
try await recordService.startRecording(to: url)
|
try await recordService.startRecording(to: url)
|
||||||
locationTask = Task {
|
|
||||||
location = try await locationService.getRecentLocation()
|
if locationTask == nil || locationTask?.isCancelled == true {
|
||||||
|
locationTask = Task {
|
||||||
|
do {
|
||||||
|
let location = try await locationService.getRecentLocation()
|
||||||
|
locationTask = nil
|
||||||
|
return location
|
||||||
|
} catch {
|
||||||
|
locationTask = nil
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,11 +123,7 @@ extension VehicleRecordService: VehicleRecordServiceProtocol {
|
|||||||
throw VehicleRecordError.emptyUrl
|
throw VehicleRecordError.emptyUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
locationTask?.cancel()
|
|
||||||
locationTask = nil
|
|
||||||
self.url = nil
|
self.url = nil
|
||||||
let location = self.location
|
|
||||||
self.location = nil
|
|
||||||
|
|
||||||
await recordService.stopRecording()
|
await recordService.stopRecording()
|
||||||
|
|
||||||
@ -126,6 +131,11 @@ extension VehicleRecordService: VehicleRecordServiceProtocol {
|
|||||||
async let durationTask = recordService.getDuration(from: url)
|
async let durationTask = recordService.getDuration(from: url)
|
||||||
|
|
||||||
let (text, duration) = await (recognitionTask, try? durationTask)
|
let (text, duration) = await (recognitionTask, try? durationTask)
|
||||||
|
var location = try? await locationTask?.value
|
||||||
|
|
||||||
|
// One location can be shared between multile records
|
||||||
|
// So, manually give each copy it's unique id
|
||||||
|
location?.id = UUID().uuidString
|
||||||
|
|
||||||
let record = AudioRecordDto(
|
let record = AudioRecordDto(
|
||||||
path: url.lastPathComponent,
|
path: url.lastPathComponent,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user