Skip to content
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

Conversation

srartese
Copy link
Contributor

@srartese srartese commented Oct 4, 2023

Checklist

  1. If you've added code that should be tested, add tests
  2. If you've changed APIs, update (or create!) the documentation
  3. Ensure the tests pass
  4. Make sure that your code lints and that you've followed our coding style
  5. Write a title and, if necessary, a description of your work suitable for publishing in our release notes
  6. Mention any related issues in this repository (as #ISSUE) and in other repositories (as kobotoolbox/other#ISSUE)
  7. Open an issue in the docs if there are UI/UX changes

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

jsapp/js/components/submissions/submissionUtils.ts Outdated Show resolved Hide resolved
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`;
Copy link
Member

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:

  1. Use a simple form with audio question
    simple-audio-form.xlsx
  2. Add submission using flac file (e.g. https://github.com/ietf-wg-cellar/flac-test-files/blob/main/subset/01%20-%20blocksize%204096.flac)
  3. 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.

Copy link
Member

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?

Copy link
Contributor Author

@srartese srartese Oct 16, 2023

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

@magicznyleszek magicznyleszek merged commit 16ed541 into beta Nov 14, 2023
1 of 4 checks passed
@magicznyleszek magicznyleszek deleted the 4597-data-tab-view-using-the-wrong-endpoint-for-audio-attachments branch November 14, 2023 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants