wailsapp / wails

Create beautiful applications using Go
https://wails.io
MIT License
25.18k stars 1.21k forks source link

Audio files are not included in assets when running wail build #3343

Closed glvarnell closed 13 hours ago

glvarnell commented 7 months ago

Description

If I create a simple vanilla javascript wails app that just uses fireworks.js everything works including sound when I run wails dev. When I build the application it doesn't look like the mp3 files are included in the assets and I do not get any sound.

To Reproduce

Create a vanilla javascript wails app wails init -n fireworks -t vanilla -ide vscode

I have tried installing fireworks.js from npm as well as just using the CDN in index.html Download and place explosion0.mp3, explosion1.mp3 and explosion2.mp3 in the assets folder. Update the javascript config json to use the audio files. a small snippet from the config json: sound: { enabled: true, files: [ './src/assets/explosion0.mp3', './src/assets/explosion1.mp3', './src/assets/explosion2.mp3' ], volume: { min: 4, max:100 } }

run wails dev The audio plays

run wails build no audio and no mp3 files are placed in dist/assets

Expected behaviour

I expect the assets to be bundled and work from the binary build the same as in the dev build.

Screenshots

No response

Attempted Fixes

No response

System Details

# Wails
Version         | v2.8.0
Package Manager | apt   

# System
┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
| OS           | Ubuntu                                                                            |
| Version      | 23.10                                                                             |
| ID           | ubuntu                                                                            |
| Go Version   | go1.22.0                                                                          |
| Platform     | linux                                                                             |
| Architecture | amd64                                                                             |
| CPU          | AMD Ryzen 7 7735HS with Radeon Graphics                                           |
| GPU 1        | Rembrandt [Radeon 680M] (Advanced Micro Devices, Inc. [AMD/ATI]) - Driver: amdgpu |
| GPU 2        | AD107M [GeForce RTX 4060 Max-Q / Mobile] (NVIDIA Corporation) - Driver: nvidia    |
| Memory       | 15GB                                                                              |
└──────────────────────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌──────────────────────────────────────────────────────────────────────────┐
| Dependency | Package Name          | Status    | Version                 |
| *docker    | docker.io             | Installed | 24.0.5                  |
| gcc        | build-essential       | Installed | 12.10ubuntu1            |
| libgtk-3   | libgtk-3-dev          | Installed | 3.24.38-5ubuntu1        |
| libwebkit  | libwebkit2gtk-4.0-dev | Installed | 2.42.5-0ubuntu0.23.10.2 |
| npm        | npm                   | Installed | 10.2.4                  |
| *nsis      | nsis                  | Installed | v3.09-1                 |
| pkg-config | pkg-config            | Installed | 1.8.1                   |
└──────────────────────── * - Optional Dependency ─────────────────────────┘

# Diagnosis
 SUCCESS  Your system is ready for Wails development!

Additional context

Other than this minor issue I am loving wails. Thank you for all the hard work on this wonderful project!

fyonecon commented 7 months ago

可以将mp3打包在assets里面,并且播放功能正常。 建议你排查: 1️⃣浏览器的console看是否mp3的路径读取错误(你也可以在vscode/jb golang的控制台里面看到静态文件引用情况); 2️⃣检查你的js插件所预定义的mp3格式是否正确。

alexis-piquet commented 3 months ago

Hey, have you tried to add it in you frontend/package.json file?

"build": "tsc && vite build && cp -r assets/* dist/assets/",
SimiJS commented 1 day ago

You should import the audio and use it like this.

import audioSrc from '#/assets/audio/yourSoundfile'
useAudio(audioSrc)

Not Like This

useAudio('#/assets/audio/yourSoundfile')
leaanthony commented 13 hours ago

Closing this as it's a local issue 👍