capacitor-community / capacitor-community/native-audio
Loop function does not play the audio, only sets loop variable
- Dominant language
- Java
- Stars
- 154
- Forks
- 78
- PR merge metrics
- No merged PRs in 30d
Description
# Confusing documentation / Wrong behavior
I added this library to my project and I found out that my audio file was not being played. I thought it was due to the file location and the "assetPath" variable, buy I realized it was caused by a "bug" in the .loop() method I was calling. I was expecting for the audio to reproduce with the loop call, but this was not the actual behavior. Its confusing and it does not correspond with the documentation:
---
/**
* This method will loop the audio file for playback.
* @param assetId - identifier of the asset
* @returns void
*/
NativeAudio.loop({
assetId: 'fire',
});
---
I would suggest calling the play() method in the AudioAsset.java file after setting the loop variable or fixing the documentation.
https://github.com/capacitor-community/native-audio/blob/8cfe67ba954748ae54aab8e6394757d65125b493/android/src/main/java/com/getcapacitor/community/audio/AudioAsset.java#L105
STR:
- Preload an audio file with an assetId (NativeAudio.preload())
- Call the loop function with the same assetId.
Expected behavior:
The audio file will be reproduced in loop mode.
Actual behavior:
Nothing happens after loop is invoked.
Contributor guide
Assessment
This issue has not been assessed yet.