From e39079311f57ce17c5b53f7c5ffbf5abad9dd244 Mon Sep 17 00:00:00 2001 From: Andras Samu Date: Wed, 16 Oct 2024 15:17:00 +0200 Subject: [PATCH] fix recording filename, settings parameter set correctly --- Sources/HKStream/HKStreamRecorder.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sources/HKStream/HKStreamRecorder.swift b/Sources/HKStream/HKStreamRecorder.swift index 1d3078306..c5938bb83 100644 --- a/Sources/HKStream/HKStreamRecorder.swift +++ b/Sources/HKStream/HKStreamRecorder.swift @@ -109,13 +109,19 @@ public actor HKStreamRecorder { } /// Starts recording. - public func startRecording(_ filaName: String? = nil, settings: [AVMediaType: [String: any Sendable]] = HKStreamRecorder.defaultSettings) async throws { + public func startRecording(_ fileName: String? = nil, settings: [AVMediaType: [String: any Sendable]] = HKStreamRecorder.defaultSettings) async throws { guard !isRecording else { throw Error.invalidState } + + self.fileName = fileName ?? UUID().uuidString + self.settings = settings + + guard let fileName = self.fileName else { throw Error.invalidState } + videoPresentationTime = .zero audioPresentationTime = .zero - let fileName = fileName ?? UUID().uuidString + let url = moviesDirectory.appendingPathComponent(fileName).appendingPathExtension("mp4") writer = try AVAssetWriter(outputURL: url, fileType: .mp4) isRecording = true