Skip to content

Can't play audio file in assets folder #8961

Discussion options

You must be logged in to vote

You're literally trying to access /~assets/sounds/swiftly-610.mp3. There's no one to parse and interpret the requested URL, as in the SFC template. So two options: use the /public folder OR:

// second option
import mp3File from 'assets/sounds/swiftly-610.mp3'
const audio = new Audio(mp3File)
audio.play()

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ghosteye1
Comment options

@rstoenescu
Comment options

Answer selected by rstoenescu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants