javafx를 가지고 놀고 있는데 wav 파일을 재생하려고하는 MediaPleyer 데모 코드를 수정했습니다. 작동하지 않습니다.Javafx 및 wav 파일
/*
* Copyright (c) 2009, SUN Microsystems, Inc.
* All rights reserved.
*/
package javafx.tools.fxd.demos.mediaplayer;
import javafx.scene.*;
import javafx.scene.media.*;
import javafx.stage.*;
var player = javafx.scene.media.MediaPlayer {
repeatCount: 1
media: Media {
source: "{__DIR__}Door_Open.wav"
};
};
class MyMediaPlayerUI extends MediaPlayerUI {
override protected function contentLoaded() {
super.contentLoaded();
var s = player.media.source;
var i = s.lastIndexOf ("/");
if (i >= 0) {
s = s.substring (i + 1);
}
fileName.content = s;
}
}
var stage : Stage;
var ui = MyMediaPlayerUI {};
var skins = [ "{__DIR__}MediaPlayer1.fxz", "{__DIR__}MediaPlayer2.fxz" ];
var index = 0;
ButtonController {
pressed: bind ui.playPressed
hovered: bind ui.playHovered
normal: bind ui.playNormal
activeArea: bind ui.playActiveArea
action: function() {
player.play();
}
}
ButtonController {
pressed: bind ui.pausePressed
hovered: bind ui.pauseHovered
normal: bind ui.pauseNormal
activeArea: bind ui.pauseActiveArea
action: function() {
player.pause();
}
}
ButtonController {
pressed: bind ui.switchPressed
hovered: bind ui.switchHovered
normal: bind ui.switchNormal
activeArea: bind ui.switchActiveArea
action: function() {
index = (index + 1) mod skins.size();
ui.url = skins[index];
}
}
stage = Stage {
title: "Media Player"
//visible: true
resizable: false
onClose: function() { java.lang.System.exit (0); }
scene: Scene {
content: ui
}
}
wav 파일은 예외없이 복제되지 않습니다. 내가
repeatCount: javafx.scene.media.MediaPlayer.REPEAT_FOREVER
에 반복 횟수 속성이 결국 힙 공간 예외 준다 변경하는 경우 :
Exception in thread "PlayerLoop" java.lang.OutOfMemoryError: Java heap space
위의 코드에 문제가 있습니다를? wav 파일을 재현하는 방법이 있습니까? wav는 매우 널리 퍼져있는 오디오 포맷이므로 javafx에서는 이것이 필수적이라고 생각합니다.
감사합니다.
Windows에서 "chord.wav"를 시도했기 때문에 파일과 관련이 있어야합니다. – Averroes
이 경우 사운드가 최초 재생을 완료하고 다시 재생을 클릭하면이 예외가 발생합니다. 스레드 "AWT-EventQueue-1"의 예외 com.sun.media.jmc.OperationUnsupportedException : 미디어 플레이어 피어가 미디어 시간을 설정할 수 없습니다 시간 : 1.207031191 매우 실망 스럽습니다. – Averroes