You can try this code below. It will play sound if cursor is under a layer and stop if it leave it. Note: each layer has the userData field, you can use it to store sound URL or for another logics. In this example I just echo this value into the browser log.
const plugin = this;
const $ = jQuery;
let audio = null;
plugin.$container.on('mouseover mouseout', '.vision-layer', (e) => {
const $layer = $(e.currentTarget);
const layerId = $layer.attr('data-layer-id');
const layer = plugin.getLayer(layerId);
console.log(layer.cfg.userData);
if(layer) {
if(audio) {
audio.pause();
audio.currentTime = 0;
audio = null;
}
if(e.type == 'mouseover') {
audio = new Audio('https://assets.mixkit.co/active_storage/sfx/940/940-preview.mp3');
audio.play();
}
}
});