native-audio icon indicating copy to clipboard operation
native-audio copied to clipboard

Promise not resolve on NativeAudio.preload

Open jansgescheit opened this issue 2 years ago • 4 comments

Describe the bug Promise does not resolve on preloading Assets

To Reproduce

NativeAudio.preload({
                    assetId: 'sound.mp3',
                    assetPath: 'public/assets/sound.mp3',
                    audioChannelNum: 1,
                    isUrl: false,
                })
.then(() => console.log('loaded'))
.catch(e => console.error(e))

Expected behavior Promise should be resolve or fail

Smartphone (please complete the following information):

  • iOS 15

Additional context Add any other context about the problem here.

jansgescheit avatar Jul 26 '22 07:07 jansgescheit

@jansgescheit Try to update the plugin to the latest version and verify this issue, if that doesn't help, try debugging the capacitor-community/native-audio -> preload function in XCode.

bazuka5801 avatar Jul 26 '22 19:07 bazuka5801

@bazuka5801 thank you for reply

I'm using the latest version, and I've already struggled through the Xcode debugger. The call to call.resolve() is never reached, the method is exited one line before. Maybe also a quirk of the debugger in the async code.

Edit I may have found the problem, I call the preload method twice for the same asset, on the second call the Promise is no longer resolved or rejected

jansgescheit avatar Jul 27 '22 19:07 jansgescheit

Im having the exact same issue, workarounds Im exploring are combination of unloading assets and manually tracking preloading.

kubenstein avatar Aug 02 '22 14:08 kubenstein

It's strange. Sometimes it works, sometimes it doesn't, but it doesn't work at all when I have the livereload active.

jansgescheit avatar Aug 02 '22 15:08 jansgescheit