javafx.scene.media.AudioClip.play()

Here are the examples of the java api javafx.scene.media.AudioClip.play() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

8 Examples 7

19 Source : Ball.java
with MIT License
from Team-60

public void jump() {
    // TEMPORARY, TODO: MUSIC DISABLE
    audioClip.play();
    velocity = jumpSpeed;
}

19 Source : TocandoAudio.java
with GNU General Public License v3.0
from jesuino

@Override
public void start(Stage palco) throws Exception {
    // 1
    AudioClip clip = new AudioClip(AUDIO_URL);
    // 2
    clip.play();
    StackPane raiz = new StackPane();
    // 3
    raiz.getChildren().add(new Text("Tocando Música "));
    Scene cena = new Scene(raiz, 600, 100);
    palco.setreplacedle("Tocando Audio em JavaFX");
    palco.setScene(cena);
    palco.show();
}

19 Source : ClockWithAudio.java
with GNU General Public License v3.0
from AlohaWorld

/**
 * Announce the current time at every minute
 */
public void announceTime(int hour, int minute) {
    // Announce hour
    hourAudio[hour % 12].play();
    // Time delay to allow hourAudio play to finish
    try {
        Thread.sleep(1500);
    } catch (InterruptedException ex) {
    }
    // Announce minute
    minuteAudio[minute].play();
    // Time delay to allow minuteAudio play to finish
    try {
        Thread.sleep(1500);
    } catch (InterruptedException ex) {
    }
    // Announce am or pm
    if (hour < 12)
        amAudio.play();
    else
        pmAudio.play();
}

19 Source : ClockWithThread.java
with GNU General Public License v3.0
from AlohaWorld

/**
 * Tell the time with given hour and minute
 */
private void announceTime(int hour, int minute) {
    // Announce hour, 12-hour format
    hourAudio[hour % 12].play();
    try {
        Thread.sleep(1500);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    // Announce minute
    minAudio[minute].play();
    try {
        Thread.sleep(800);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    // Announce am/pm according to the hour
    if (hour < 12) {
        amAudio.play();
    } else {
        pmAudio.play();
    }
}

19 Source : ClockWithAudio1.java
with GNU General Public License v3.0
from AlohaWorld

/**
 * Tell the time with given hour and minute
 * @throws InterruptedException
 */
private void announceTime(int hour, int minute) {
    // Announce hour, 12-hour format
    hourAudio[hour].play();
    try {
        Thread.sleep(1500);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    // Announce minute
    minAudio[minute].play();
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    // Announce am/pm according to the hour
    if (hour >= 12)
        pmAudio.play();
    else
        amAudio.play();
}

18 Source : AudioClipDemo.java
with The Unlicense
from sgrinev

@Override
public void start(Stage primaryStage) {
    AudioClip clickSound = new AudioClip("https://github.com/sgrinev/mastering-javafx-9-10-book/raw/master/resources/mouse-click.wav");
    Button btn = new Button("Play");
    btn.setOnAction((e) -> {
        clickSound.play();
    });
    StackPane root = new StackPane();
    root.getChildren().add(btn);
    Scene scene = new Scene(root, 300, 250);
    primaryStage.setreplacedle("Hello World!");
    primaryStage.setScene(scene);
    primaryStage.show();
}

17 Source : GameViewHelper.java
with Apache License 2.0
from AnywhereSoftware

/**
 * Plays a previously loaded audio file. Volume should be between 0 to 1.
 */
public void PlayAudioClip(int Id, double Volume) {
    AudioClip ac = sounds.get(Id);
    ac.play(Volume);
}

16 Source : MediaTools.java
with Apache License 2.0
from Mararsh

public static void audio(File file, double volumn, int cycle) {
    AudioClip clip = new AudioClip(file.toURI().toString());
    clip.setVolume(volumn);
    clip.setCycleCount(cycle);
    clip.play();
}