New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added logic to support all audio formats in the player #4676
Added logic to support all audio formats in the player #4676
Conversation
…for-audio-attachments
const questionPath = Object.keys(submission).find(key => submission[key] === lastItem); | ||
|
||
const newAudioURL = | ||
`${ROOT_URL}/api/v2/assets/${submission._xform_id_string}/data/${attachment.instance}/attachments/?xpath=${questionPath}&format=mp3`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When questionPath
is undefined
, this will crash the app.
Steps to break it:
- Use a simple form with audio question
simple-audio-form.xlsx - Add submission using
flac
file (e.g. https://github.com/ietf-wg-cellar/flac-test-files/blob/main/subset/01%20-%20blocksize%204096.flac) - Go to Data Table and click this tiny play button. You will see
400
error on this:
GET http://kf.kobo.local/api/v2/assets/aJpiarEu6gxjLrg7wuXpDq/data/34/attachments/?xpath=undefined&format=mp3
and another error:Uncaught (in promise) DOMException: The media resource indicated by the src attribute or assigned media provider object was not suitable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, but perhaps Object.keys
above should be Object.values
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this problem is because when you upload the file it gets renamed by removing the '_' in the file. Unfortunately it's not as simple as just replacing the _
with spaces because it only does it for the original file name but numeric values are getting added to the end of the file and that is our new file name.
For example:
We upload: 01 - blocksize 4096.flac
The attachment file name is 01_-_blocksize_4096-12_47_9.flac
The question value is: 01 - blocksize 4096-12_47_9.flac
Additionally if the file name has a -
originally that does not get removed, only the spaces that were replaced with the hyphen.
We were comparing the file name to the question value in order to get the question path name but clearly that doesn't work when the name of the file is changing between the file name and the actual value of the question file.
I'm working on the solution now. Stay tuned
…d being undefiend
…for-audio-attachments
…for-audio-attachments
Checklist
Description
Added a check for the type of audio file and if the player doesn't support it then it is sent to the endpoint to format it to an mp3. This will allow types like
.AMR
and.AAC
to be uploaded via Enketo or specifically the background audio from collect to be played back in the audio player.Related issues
Fixes #4597