Not work with vite 2
erro:
onMounted is called when there is no active component instance to be associated with. Lifecycle injection APIs can only be used during execution of setup().
@hunteryun I encounter the same error using this package in a NuxtJS setup.
@Sebastix Wow, cool, A same Drupaler ! This is a special fate to meet here.
I have solved this problem, This library is just a simple package, so you can actually try to use howler.js directly, see https://github.com/goldfire/howler.js#quick-start
@hunteryun Fellow Drupaler ahoy! :-)
Your solution is also the solution I've worked out this morning, I'm using the Howler package now. This library is indeed a small wrapper. Thanks!
I'm at the same issue trying to integrate into a vue app, but I'm not as astute as you guys. If you don't mind, I get that you are cloning howler into your project, but I don't get how you then integrate that into this particular project.
Update: Okay, I think I get it. They are saying, if you have this setup and encounter this problem, just use howler directly. It is just a JS file or two, and so I'm just using it in my assets/js like any little plugin library.
<audio ref="playIt" src="@/sounds/sound.mp3" />
javascript (I'm using Vue): const it = useJsToSelectElement("playIt") const onSomeCondition = () => { it.play() }
So, just for adding sound effects to a simple app where users are interacting with the DOM, I seem to be getting the best results using vanilla functionality, and am unable to use howler or @vueuse/sound
I think the quick start docment is enough. Here is my code for your reference
import { Howl, Howler } from 'howler'
import sfx from './assets/test.mp3'
var sound = new Howl({
src: [sfx],
sprite: {
aaa: [0, 1000],
bbb: [1000, 1000],
}
});
const play = () => {
sound.play(‘aaa’);
}
I means only use howler, don't use @vueuse/sound, it not work
Hey here :)
Sorry for the late answer!
Could you let me know if v2 has fixed the issue for you?
Thanks a lot 🙏