How do you play a fucking sound?

Ive been trying for hours to play a WAV file but it always stays silent

heres my code
package soundboardfx;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.Media;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.ext.swing.SwingButton;

var player: MediaPlayer = MediaPlayer {
autoPlay: true
//repeatCount: MediaPlayer.REPEAT_FOREVER
volume: 1.0
mute: false
stopTime: 0s
media: Media {
source: “{DIR}areyouracist.wav”
}
};

Stage {
title: “meu barulhinho - MIDI file”
width: 250
height: 80
scene: Scene {
content: HBox{
spacing: 10
content: [
SwingButton {
text: “play”
action: function() {
player.play();
},
},
SwingButton {
text: “pause”
action: function() {
player.pause();
}
}]
}
}
};

try an .mp3

no didnt work

Try commenting out the ‘stopTime’ field in the media player

still doesnt work

if this line is left out the sound doesnt play:
repeatCount: MediaPlayer.REPEAT_FOREVER

but when it is included it causes a heap error and crashes the program

Try this MP3 Player demo. If it works, then download the source code and compile parts of it until you get the sound working.

it seems you have to load a sound from a remote URl instead of locally,
images can be loaded locally however which confuses the issue,
???

thanks for the help

This is how I do it:


var audiostream = AudioStream {
	url: "file:///sounds/realshady.mp3";
}

now this can be a file path or a “{DIR}” for local path etc.
supports all sounds formats from what i can see: “aif, wav, mp3, acc, … http, rtsp” etc


var soundchannel = AudioChannel {
    sound: bind lazy audiostream
    autoplay: true;
    paused: false;
}

next you make a channel and connect the sound to it.

this is cool for making audio mixers and channel groups, also connecting up audio filters (spectrum fft, lowpass filter, vst, coreaudio plugins, …etc). As you can also see i’m using the autoplay to get things rolling soon as its loaded (i know i’m slack- you can do a soundchannel.play()).

and because we’re all gamer types:


    soundchannel.location = Vec3 {x, y, z};

guess that would be cool, no?