capacitor-community / capacitor-community/native-audio

Vite build & asset paths, how the hell?

Open
#93 3 comments 7 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
154
Forks
78
PR merge metrics
No merged PRs in 30d

Description

I'm clearly missing something with this. I have an app built with vite, direct from Capacitor's quickstart. I've added my audio to `source/assets/sounds`, as seen here:
![image](https://github.com/capacitor-community/native-audio/assets/55938439/969fa90d-b579-43b5-ba6a-8cdd29e3a454)

and so, they build like this in the Android folder:
![image](https://github.com/capacitor-community/native-audio/assets/55938439/0f902d78-b032-4c8f-b396-009837e90a6f)

I've tried preloading the audio in a ton of different ways, looking through different issues, trying different repos such as CapGo, and nothing has worked.

I've tried all of these:
```
assetPath: "public/assets/sounds/bang.1edeb9ba.wav",
assetPath: "public/assets/sounds/bang.wav",
assetPath: "assets/sounds/bang.wav",
assetPath: "sounds/bang.wav",
assetPath: "sounds/bang.1edeb9ba.wav",
assetPath: "assets/sounds/bang.1edeb9ba.wav",
```

Nothing is working? It just throws an error with the path of the file.
The docs are super vague, and the "native-audio-example" seems to only be useful to those who know that exact framework.

Contributor guide

Open the contributing guide

Research direction

Start with the Vite asset output under source/assets/sounds and the generated Android folder, then compare those paths with native-audio-example. Reproduce the preload failure in the Capacitor quickstart using bang.wav and record which assetPath is requested and where the file is generated. Done means identifying a working path or documenting the mismatch clearly.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, vite
Domain
audio-video-rtc, mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.