After the deployment to the server, no sound is played!

There is java bean

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.inject.Named;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;

public class AudioPlayer {

    AudioPlayer player = new AudioPlayer();

    private File file;
    private String path;

    public File getFile() {
        return file;

    public void setFile(File file) {
        this.file = file;

    public String getPath() {
        return path;

    public void setPath(String path) {
        this.path = path;

    public void run() {
        player.setPath("Путь до файла");
        file = new File(path);
        AudioInputStream audioIn;
        try {
            audioIn = AudioSystem.getAudioInputStream(file);
            Clip clip;
            clip = AudioSystem.getClip();
            Thread.sleep(clip.getMicrosecondLength() / 1000);

        } catch (IOException | LineUnavailableException | InterruptedException | UnsupportedAudioFileException ex) {
            Logger.getLogger(AudioPlayer.class.getName()).log(Level.SEVERE, null, ex);

There is an XHTML file that should start sound

    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html >=""
        <h:commandLink action="#{}" value="Play" />

Actually the assembly, the start of the server, deploy without errors, the paths are also correct, but the sound does not play, help!

Asked on January 19, 2020 in Programming.
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.