Below is an alternative XForms concept that uses events and actions. This would require introducing either a new action for recording audio (e.g. odk:startaudio
) or, as I've shown below, a combination of a generic background recording action (e.g. odk:startrecording
) and an attribute to indicate the type of recording (e.g. odk:type="audio"
).
<model>
<instance>
<my_recording/>
...
</instance>
<bind nodeset="/data/my_recording" type="binary"/>
<odk:startrecording event="xforms-ready" ref="/data/my_recording" odk:type="audio" odk:quality="low"/>
...
</model>
Adding recording for a range would require introducing an event for a question being reached and a stoprecording
action (the recording implicitly stops on form exit in the example above). (Side note, I don't know if it would really make sense to allow partial recording within a field-list
or an Enketo form not in pages
mode but it would be possible by doing something like using the value of the immediately preceding question changing as triggering this new event.)
<model>
<instance>
<my_recording/>
...
</instance>
<bind nodeset="/data/my_recording" type="binary"/>
...
</model>
<body>
<input ref="/data/q1">
<startrecording ref="/data/my_recording" event="odk-question-reached" odk:type="audio" odk:quality="low"/>
</input>
...
<input ref="/data/thanks">
<stoprecording ref="/data/my_recording" event="odk-question-reached"/>
</input>
</body>
The purist side of me really likes this. It's extremely flexible and powerful and it's consistent with concepts we've already introduced. The pragmatist side of me concerned. I think that in XLSForm we'd only expose triggering on the odk-question-reached
event and we could do a fair amount of validation at that level. But to really follow the specs clients would need to be able to handle actions being triggered by all the events we support, mismatched start/stop actions, etc. That may be handled by our existing generic support for events and actions but I have a feeling that there will be issues. For example, xforms-value-changed
events can be triggered in really quick succession and that might cause instability for media recording. If we're unlikely to expose that functionality in XLSForms anyway, I'd rather avoid it.
One of the big points @Xiphware brought up during the TAB call is that there might be other kinds of background recording and that we'd want to introduce an approach that can be extended to e.g. video, locations, humidity, etc. I don't think that there's a big advantage of one approach vs. the other for this.
- In the original attributes approach I outlined, we'd have to introduce a new attribute name for each type of data to record. Alternately, the attribute name could be something like
odk:auto-populate
with values likeaudio
,location
,video
(which I think I prefer). - In the event/action approach defined above we'd need to introduce either new actions or new types for each new type of data to record.
I think of the attributes approach as a flattened version of the actions/events one that implicitly always uses a "question reached" event to trigger recording start and stop. It's less powerful but I think that's an asset because we get more control over what can be expressed by a form. It's also generally simpler to only have to deal with the bind
rather than having information about the recording in action
s as well.