Hi. I'm playing around with javafx and I have modified the code of the MediaPleyer demo trying to reproduce a wav file. It doesn't work.
/*
* 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
}
}
The wav file is not reproduced without giving any exception. If I change the repeatCount property to
repeatCount: javafx.scene.media.MediaPlayer.REPEAT_FOREVER
eventually gives a heap space exception:
Exception in thread "PlayerLoop" java.lang.OutOfMemoryError: Java heap space
There is any problem in the code above? There is a way to reproduce wav files? I think this is essential for javafx since wavs are a very spread audio format.
Thanks.