I discovered that the interface pulseaudio was deprecated: The pulseaudio interface
So i replaced it with sound-playback and now my application is able to play sounds!
Thank you again James! You have led me on the right path.
For completeness I am sharing the working yaml file:
name: fromgtog
version: '7.0.1'
summary: Clone ALL GitHub/Gitea/Local to GitHub/Gitea.
description: |
Helps to clone all repositories from GitHub on Gitea/Local and vice versa.
grade: stable
confinement: strict
base: core24
icon: snap/gui/icon.png
title: FromGtoG
website: https://andre-i.eu
issues: https://github.com/goto-eof
license: MIT
compression: xz
slots:
fromgtog-dbus:
interface: dbus
bus: session
name: it.es5.fromgtog.dbus
apps:
fromgtog:
environment:
ALSA_CONFIG_PATH: $SNAP/etc/asound.conf
LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP_DESKTOP_RUNTIME/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/libproxy:$SNAP_DESKTOP_RUNTIME/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/gio/modules
command: executor
extensions: [ gnome ]
plugs:
- network
- x11
- browser-support
- unity7
- home
- desktop
- desktop-legacy
- removable-media
- wayland
- network-bind
- audio-playback
- alsa
slots:
- fromgtog-dbus
platforms:
amd64:
build-on: [ amd64 ]
build-for: [ amd64 ]
arm64:
build-on: [ arm64 ]
build-for: [ arm64 ]
parts:
wrapper:
plugin: dump
source: snap/local
source-type: local
alsa-config:
plugin: dump
source: snap/local/asound.conf
source-type: file
organize:
asound.conf: etc/asound.conf
prime:
- etc/asound.conf
application:
plugin: maven
source: .
build-packages:
- openjdk-21-jdk
- maven
stage-packages:
- openjdk-21-jre
- glib-networking
- libgtk-3-0
- xdg-utils
- libasound2
- libasound2-plugins
- alsa-utils
after:
- alsa-config
override-prime: |
snapcraftctl prime
rm -vf usr/lib/jvm/java-*-openjdk-*64/lib/security/blacklisted.certs
While in Java I do something like that to load the clip:
private Clip loadClip(String soundFilename) {
try {
InputStream soundStream = SoundPlayer.class.getResourceAsStream(soundFilename);
URL soundURL = getClass().getClassLoader().getResource(soundFilename);
if (soundURL == null) {
logger.error("File not found: {}", soundFilename);
return null;
}
logger.info("Loading file: {}", soundFilename);
AudioInputStream audioStream = AudioSystem.getAudioInputStream(soundURL);
Clip clip = AudioSystem.getClip();
clip.open(audioStream);
audioStream.close();
return clip;
} catch (RuntimeException | UnsupportedAudioFileException | IOException |
LineUnavailableException e) {
logger.error("SoundPlayer failed to load clip", e);
}
return null;
}