类javafx.scene.media.AudioClip源码实例Demo

下面列出了怎么用javafx.scene.media.AudioClip的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: logbook-kai   文件: ApiReqMapStart.java
/**
 * 大破警告
 *
 * @param badlyShips 大破艦
 */
private static void displayAlert(List<Ship> badlyShips) {
    try {
        Path dir = Paths.get(AppConfig.get().getAlertSoundDir());
        Path p = Audios.randomAudioFile(dir);
        if (p != null) {
            AudioClip clip = new AudioClip(p.toUri().toString());
            clip.setVolume(AppConfig.get().getSoundLevel() / 100D);
            clip.play();
        }
    } catch (Exception e) {
        LoggerHolder.get().warn("サウンド通知に失敗しました", e);
    }
    for (Ship ship : badlyShips) {
        ImageView node = new ImageView(Ships.shipWithItemImage(ship));

        String message = Messages.getString("ship.badly", Ships.shipMst(ship) //$NON-NLS-1$
                .map(ShipMst::getName)
                .orElse(""), ship.getLv());

        Tools.Conrtols.showNotify(node, "大破警告", message, Duration.seconds(30));
    }
}
 
源代码2 项目: helloiot   文件: Beeper.java
public Beeper(ClipFactory factory, Node alert, Animation alertanimation) {

        this.alert = alert;
        this.alertanimation = alertanimation;
        // http://www.soundjay.com/tos.html
        beep = factory.createClip(getClass().getResource("/com/adr/helloiot/sounds/beep-01a.wav").toExternalForm(), AudioClip.INDEFINITE);
    }
 
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create three buttons
	Button play = new Button("Play");
	Button loop = new Button("Loop");
	Button stop = new Button("Stop");

	// Create a pane and set its properties
	HBox pane = new HBox(5);
	pane.setAlignment(Pos.CENTER);
	pane.setPadding(new Insets(10, 10, 10, 10));
	pane.getChildren().addAll(play, loop, stop);

	// Create a audio clip
	AudioClip audio = new AudioClip(
		"http://cs.armstrong.edu/liang/common/audio/anthem/anthem3.mp3");

	// Create and register handlers
	play.setOnAction(e -> {
		audio.play();
	});

	stop.setOnAction(e -> {
		audio.stop();
	});

	loop.setOnAction(e -> {
		audio.setCycleCount(AudioClip.INDEFINITE);
	});

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane);
	primaryStage.setTitle("Exercise_16_22"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
源代码4 项目: logbook-kai   文件: ApiReqMapNext.java
/**
 * 大破警告
 *
 * @param badlyShips 大破艦
 */
private static void displayAlert(List<Ship> badlyShips) {
    try {
        Path dir = Paths.get(AppConfig.get().getAlertSoundDir());
        Path p = Audios.randomAudioFile(dir);
        if (p != null) {
            AudioClip clip = new AudioClip(p.toUri().toString());
            clip.setVolume(AppConfig.get().getSoundLevel() / 100D);
            clip.play();
        }
    } catch (Exception e) {
        LoggerHolder.get().warn("サウンド通知に失敗しました", e);
    }
    for (Ship ship : badlyShips) {
        ImageView node = new ImageView(Ships.shipWithItemImage(ship));

        String message = Messages.getString("ship.badly", Ships.shipMst(ship) //$NON-NLS-1$
                .map(ShipMst::getName)
                .orElse(""), ship.getLv());

        Tools.Conrtols.showNotify(node, "大破警告", message, Duration.seconds(30));
    }
}
 
源代码5 项目: logbook-kai   文件: Audios.java
/**
 * デフォルトサウンドを再生するタスクを返します。
 * 
 * @return デフォルトサウンドを再生するタスク
 */
public static Runnable playDefaultNotifySound() {
    return () -> {
        try {
            Path p = defaultNotifySound();
            if (p != null) {
                AudioClip clip = new AudioClip(p.toUri().toString());
                clip.setVolume(AppConfig.get().getSoundLevel() / 100D);
                clip.play();
            }
        } catch (Exception e) {
            LoggerHolder.get().warn("サウンド通知に失敗しました", e);
        }
    };
}
 
源代码6 项目: logbook-kai   文件: MainController.java
/**
 * サウンド通知
 */
private void soundNotify(Path dir) {
    if (this.clip == null || !this.clip.isPlaying()) {
        try {
            Path p = Audios.randomAudioFile(dir);
            if (p != null) {
                this.clip = new AudioClip(p.toUri().toString());
                this.clip.setVolume(AppConfig.get().getSoundLevel() / 100D);
                this.clip.play();
            }
        } catch (Exception e) {
            LoggerHolder.get().warn("サウンド通知に失敗しました", e);
        }
    }
}
 
源代码7 项目: MyBox   文件: MediaTools.java
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();
}
 
源代码8 项目: helloiot   文件: StandardClip.java
StandardClip(String url, int cyclecount) {
    clip = new AudioClip(url);
    clip.setCycleCount(cyclecount);
}
 
源代码9 项目: pdfsam   文件: PlaySoundController.java
private void playSound(String soundURI) {
    if (userContext.isPlaySounds()) {
        new AudioClip(soundURI).play(1);
    }
}
 
 类所在包
 类方法
 同包方法