capacitor-community / native-audio

MIT License
109 stars 66 forks source link

Loop function does not play the audio, only sets loop variable #87

Open parolaraul opened 1 year ago

parolaraul commented 1 year ago

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:


/**

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:

Expected behavior: The audio file will be reproduced in loop mode.

Actual behavior: Nothing happens after loop is invoked.

orhan-swe commented 10 months ago

Yeah, it was a bit confusing for me too. A good solution would be for loop function to check if the audio file is already being played and if not start playing it.

rondybrandao commented 9 months ago

Have you found a solution for this bug?, I need this method. Apparently it works well on an HTML page, but on Android nothing happens, nor does it show an error.

orhan-swe commented 9 months ago

@rondybrandao First you call preload(), then you call play(), now music should start playing, and then you call loop(), so now it will also loop.