本文整理汇总了Java中javafx.scene.media.AudioClip.play方法的典型用法代码示例。如果您正苦于以下问题:Java AudioClip.play方法的具体用法?Java AudioClip.play怎么用?Java AudioClip.play使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.media.AudioClip
的用法示例。
在下文中一共展示了AudioClip.play方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: displayAlert
import javafx.scene.media.AudioClip; //导入方法依赖的package包/类
/**
* 大破警告
*
* @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: towerBlast
import javafx.scene.media.AudioClip; //导入方法依赖的package包/类
public void towerBlast(boolean sound,int cycle){
final IntegerProperty frameCounter = new SimpleIntegerProperty(0);
anim = new Timeline(
new KeyFrame(FRAME_TIME, event -> {
frameCounter.set((frameCounter.get() + 1) % numCells);
setViewport(cellClips[frameCounter.get()]);
})
);
anim.setCycleCount(cycle);
anim.setOnFinished(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent t) {
stack.getChildren().remove(current);
}
});
anim.play();
if(sound){
AudioClip blast =new AudioClip (Url.BLAST_SOUND_EFFECT);
blast.play();
blast.setCycleCount(1);
}
}
示例3: showRotate
import javafx.scene.media.AudioClip; //导入方法依赖的package包/类
private void showRotate() {
URL doorBellWav = getClass().getResource("door-bell.wav");
AudioClip doorBellSound = new AudioClip(doorBellWav.toString());
doorBellSound.play();
if (timeline != null) {
timeline.stop();
}
Settings.instance().incrementCurrentUser();
timeMinutes.set("Rotate");
paneColor.set("-fx-background-color:#FF0000");
showMainWindow();
nag = new Timeline();
nag.setCycleCount(Timeline.INDEFINITE);
nag.getKeyFrames().add(new KeyFrame(Duration.seconds(15), new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
if (timeMinutes.getValue().equals("Rotate")) {
showMainWindow();
doorBellSound.play();
} else {
nag.stop();
}
}
}));
nag.playFromStart();
}
示例4: start
import javafx.scene.media.AudioClip; //导入方法依赖的package包/类
@Override
public void start(Stage palco) throws Exception {
AudioClip clip = new AudioClip(AUDIO_URL);// 1
clip.play(); // 2
StackPane raiz = new StackPane();
raiz.getChildren().add(new Text("Tocando Música ")); // 3
Scene cena = new Scene(raiz, 600, 100);
palco.setTitle("Tocando Audio em JavaFX");
palco.setScene(cena);
palco.show();
}
示例5: playAudioClip
import javafx.scene.media.AudioClip; //导入方法依赖的package包/类
public void playAudioClip(String audioClipName, double volume) {
// Play Audio
ResourceManager<AudioClip> audioResourceManager = getAudioResourceManager();
AudioClip audioClip = audioResourceManager.get(audioClipName);
if (audioClip != null) {
audioClip.play(volume);
}
}
示例6: call
import javafx.scene.media.AudioClip; //导入方法依赖的package包/类
@Override
protected Object call() throws Exception {
// audio file NEEDS to be .wav
AudioClip audio = new AudioClip(getClass().getResource("In_Seoul_Retro_80.wav").toExternalForm());
audio.setVolume(0.3f);
audio.setCycleCount(INDEFINITE);
audio.play();
return null;
}