RSDActiveUIStepObject
open class RSDActiveUIStepObject : RSDUIStepObject, RSDActiveUIStep
RSDActiveUIStepObject extends the RSDUIStepObject to include a duration and commands. This is used for the
case where an RSDUIStep has an action such as start walking
or stop walking
; the step may also implement
the RSDActiveUIStep protocol to allow for spoken instruction.
-
The duration of time to run the step. If
0, then this value is ignored.Declaration
Swift
open var duration: TimeInterval -
The set of commands to apply to this active step. These indicate actions to fire at the beginning and end of the step such as playing a sound as well as whether or not to automatically start and finish the step.
Seealso
RSDActiveUIStepCommand.stringMappingfor a list of the coding strings included in this framework.Declaration
Swift
open var commands: RSDActiveUIStepCommand -
Whether or not the step uses audio, such as the speech synthesizer, that should play whether or not the user has the mute switch turned on. Default =
false.Declaration
Swift
open var requiresBackgroundAudio: Bool -
Should the task end early if the task is interrupted by a phone call? Default =
false.Declaration
Swift
open var shouldEndOnInterrupt: Bool
-
A mapping of the localized text that represents an instructional voice prompt to the time marker for speaking the instruction.
The mapping is
Codableusing eitherTimeIntervalvalues as the keys or by using theSpokenInstructionKeysas special keys into the mapping dictionary.example:
// Example JSON dictionary that includes a spoken instruction map. let json = """ { "identifier": "foo", "type": "active", "title": "Hello World!", "text": "Some text.", "duration": 30, "requiresBackgroundAudio": true, "commands": ["playSoundOnStart", "vibrateOnFinish"], "spokenInstructions" : { "start": "Start moving", "10": "Keep going", "halfway": "Halfway there", "countdown": "5", "end": "Stop moving"} } """.data(using: .utf8)! // our data in native (JSON) format // The decoded mapping. self.spokenInstructions = [ 0.0 : "Start moving", 10.0 : "Keep going", 15.0 : "Halfway there", 25.0 : "five", 26.0 : "four", 27.0 : "three", 28.0 : "two", 29.0 : "one", Double.infinity : "Stop moving"]
Declaration
Swift
open var spokenInstructions: [TimeInterval : String]? -
The
SpokenInstructionKeysare specialized markers for the timing of when to speak the spoken instruction. These include keys that can be transformed into a time interval using the duration of the step to indicate thehalfwaypoint.See moreSeealso
spokenInstructionsDeclaration
Swift
public enum SpokenInstructionKeys : String, CodingKey -
Localized text that represents an instructional voice prompt. Instructional speech begins when the step passes the time indicated by the given time. If
timeIntervalis greater than or equal todurationor is equal toDouble.infinity, then the spoken instruction returned should be for when the step is finished.Declaration
Swift
open func spokenInstruction(at timeInterval: TimeInterval) -> String?Parameters
timeIntervalThe time interval at which to speak the instruction.
Return Value
The localized instruction to speak or
nilif there isn’t an instruction.
Coding (spoken instructions requires special handling and Codable auto-synthesis does not work with subclassing)
-
Default type is
.active.Declaration
Swift
open override class func defaultType() -> RSDStepType -
Override to set the properties of the subclass.
Declaration
Swift
override open func copyInto(_ copy: RSDUIStepObject) -
Override to set the properties on this instance.
example:
// Example JSON dictionary that includes a duration, commands, and spoken instruction mapping. let json = """ { "identifier": "foo", "type": "active", "title": "Hello World!", "text": "Some text.", "duration": 30, "commands": ["playSoundOnStart", "vibrateOnFinish"], "spokenInstructions" : { "start": "Start moving", "10": "Keep going", "halfway": "Halfway there", "countdown": "5", "end": "Stop moving"} } """.data(using: .utf8)! // our data in native (JSON) format
Declaration
Swift
open override func decode(from decoder: Decoder, for deviceType: RSDDeviceType?) throws
View on GitHub
RSDActiveUIStepObject Class Reference