STRecordingEventData
Carries recording-specific event information.
Overview
Recording progress, duration, and optional stop information. A stop reason is meaningful when the event indicates a recording stop or completion, rather than on every recording event. This is the associated payload of STMediaEventData.recording; inspect the enclosing STMediaEvent to identify the component and event type.
Its optional fields can report playback/recording position, source-audio duration, recorded duration, the STMediaStopRecordReason, and stop detail.
Fields are optional because different recording events carry different subsets of recording information.
public struct STRecordingEventData: Sendable {
public let positionMilliseconds: Int?
public let audioDurationMilliseconds: Int?
public let recordedDurationMilliseconds: Int?
public let stopReason: STMediaStopRecordReason?
public let stopDetail: String?
public init(
positionMilliseconds: Int? = nil,
audioDurationMilliseconds: Int? = nil,
recordedDurationMilliseconds: Int? = nil,
stopReason: STMediaStopRecordReason? = nil,
stopDetail: String? = nil
)
}
Purpose and usage
Carries recording-specific event information. Inspect this value when processing the relevant asynchronous event.
Event payload mapping
STMediaEventData.recording carries this structure. Match the associated enum case when handling STMediaEvent.data. The event type and function identify the occurrence; the payload provides its event-specific details.
switch event.data {
case .recording(let recording):
if let duration = recording.recordedDurationMilliseconds {
print("Recorded milliseconds: \(duration)")
}
default:
break
}