capacitor-community / native-audio

MIT License
102 stars 62 forks source link

Audio is not played #74

Closed Lucas-Wanat closed 1 year ago

Lucas-Wanat commented 1 year ago

Describe the bug When preload() is executed, it returns an error:

To Reproduce Steps to reproduce the behavior:

Captura de tela 2023-01-17 092019 image

Sending plugin error:{"save":false,"callbackId":"18192255","pluginId":"NativeAudio","methodName":"preload","success":false,"error":{"message":"androidappsrcassetsaudio\beep_erro.wav"}}

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context using capacitor 3.5.1, Cordova 10.1.2 and I've tried different audio locations but it didn't work

Thanks in advance.

Ps: the community must improve.

bazuka5801 commented 1 year ago

@Lucas-Wanat In the javascript part, you can pass the assetPath as a filename instead of a fullpath. This might solve the problem.

Lucas-Wanat commented 1 year ago

@Lucas-Wanat In the javascript part, you can pass the assetPath as a filename instead of a fullpath. This might solve the problem.

@bazuka5801 I'm going to try that, I had already tried that before, and it ended up not working, should I put the file extension or just the name? I also tried that, and in my project there is no src folder in the android folder, I think the location, shown in the documentation would not be correct for me.

Lucas-Wanat commented 1 year ago

@bazuka5801 returning to report that it didn't work, I just put the name (beep_correto.wav) and it didn't work, returning the same error.

Edited:

I just saw an issue about assetPath, so I put the audio in the indicated place, and it no longer returns an error, but only a callback and without sound:

callback: 131360741, pluginId: NativeAudio, methodName: preload, methodData:{"assetId":"correct","assetPath":"beep_correct.wav","audioChannelNum":1,"isUrl":false}

Lucas-Wanat commented 1 year ago

A new error occurred, after testing what I did as said in the previous comment in the edit, it returned this error:

image

The code:

image

Edited:

Not sure what happened, but the error described in that comment only happened once and now it just returns a callback and no audio.

Edited 2:

I included the then and catch methods in the code, so the error described in part in my language (Brazilian Portuguese before ":"), describes that the audio already exists.

image