summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorjada <jada@28c7f869-5b4e-e670-f602-82bfaf57f300>2006-03-06 19:55:06 +0000
committerjada <jada@28c7f869-5b4e-e670-f602-82bfaf57f300>2006-03-06 19:55:06 +0000
commit729daffb47398c1d4920417ba44937fe39d18330 (patch)
tree752a721493ab4d41fcd8bad581ac79781c4c01a4 /src
parent6a7e3fcea04c104dbfe285843644ab65f6ec9923 (diff)
Partial fix to sound
Diffstat (limited to 'src')
-rw-r--r--src/classes/org/jdesktop/j3d/examples/sound/AudioBehaviorMoveOne.java12
-rw-r--r--src/classes/org/jdesktop/j3d/examples/sound/MoveAppBoundingLeaf.java74
2 files changed, 33 insertions, 53 deletions
diff --git a/src/classes/org/jdesktop/j3d/examples/sound/AudioBehaviorMoveOne.java b/src/classes/org/jdesktop/j3d/examples/sound/AudioBehaviorMoveOne.java
index e5fc463..e169768 100644
--- a/src/classes/org/jdesktop/j3d/examples/sound/AudioBehaviorMoveOne.java
+++ b/src/classes/org/jdesktop/j3d/examples/sound/AudioBehaviorMoveOne.java
@@ -44,6 +44,7 @@
package org.jdesktop.j3d.examples.sound;
+import java.net.URL;
import javax.media.j3d.*;
import javax.vecmath.*;
import java.util.Enumeration;
@@ -59,13 +60,15 @@ public class AudioBehaviorMoveOne extends Behavior {
// long lastTime = -1;
boolean first_loop = true;
String fileName;
+ URL url = null;
// Override Behavior's initialize method to setup wakeup criteria
public void initialize() {
MediaContainer sample = new MediaContainer();
sample.setCapability(MediaContainer.ALLOW_URL_WRITE);
sample.setCapability(MediaContainer.ALLOW_URL_READ);
- sample.setURLString(fileName);
+ //sample.setURLString(fileName);
+ sample.setURLObject(url);
psound.setSoundData(sample);
// exaggerate the sound position now that viewPlatform
// tranform is taken into account
@@ -99,8 +102,13 @@ public class AudioBehaviorMoveOne extends Behavior {
//
// Constructor for rotation behavior. Parameter: front and back Sound nodes
//
+ public AudioBehaviorMoveOne(PointSound psound, URL url) {
+ this.psound = psound;
+ this.url = url;
+ }
+
public AudioBehaviorMoveOne(PointSound psound, String filename) {
this.psound = psound;
this.fileName = filename;
- }
+ }
}
diff --git a/src/classes/org/jdesktop/j3d/examples/sound/MoveAppBoundingLeaf.java b/src/classes/org/jdesktop/j3d/examples/sound/MoveAppBoundingLeaf.java
index 7de3b46..d0d429e 100644
--- a/src/classes/org/jdesktop/j3d/examples/sound/MoveAppBoundingLeaf.java
+++ b/src/classes/org/jdesktop/j3d/examples/sound/MoveAppBoundingLeaf.java
@@ -79,24 +79,20 @@ package org.jdesktop.j3d.examples.sound;
import java.applet.Applet;
import java.net.URL;
import java.awt.*;
-import java.awt.event.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.geometry.Sphere;
import com.sun.j3d.utils.universe.*;
import java.io.File;
+import java.net.MalformedURLException;
import javax.media.j3d.*;
import javax.vecmath.*;
+import org.jdesktop.j3d.examples.Resources;
public class MoveAppBoundingLeaf extends Applet {
// File name of sound sample
- private static int filenamesGiven = 0;
- private static URL[] url = new URL[1];
- private static String[] filename = new String[1];
- private static String path = null;
- private static boolean filenamesSet = false;
-
+ private static URL url = null;
private SimpleUniverse u = null;
public BranchGroup createSceneGraph() {
@@ -293,8 +289,7 @@ public class MoveAppBoundingLeaf extends Applet {
//
// Create a new Behavior object that will play the sound
//
- AudioBehaviorMoveOne player = new AudioBehaviorMoveOne(sound,
- filename[0]);
+ AudioBehaviorMoveOne player = new AudioBehaviorMoveOne(sound, url);
player.setSchedulingBounds(soundBounds);
objTrans.addChild(player);
@@ -305,24 +300,6 @@ public class MoveAppBoundingLeaf extends Applet {
}
public void init() {
- if (!filenamesSet) {
- // path is null if started from applet
- if (path == null) {
- path = getCodeBase().toString();
- }
-
- /*
- * append given file name to given URL path
- */
- if (filenamesGiven > 0) {
- filename[0] = new String(path + "/" + filename[0]);
- }
- else {
- // fill in default file names if all three not given
- filename[0] = new String(path + "/techno_machine.au");
- }
- filenamesSet = true;
- }
setLayout(new BorderLayout());
GraphicsConfiguration config =
@@ -332,16 +309,6 @@ public class MoveAppBoundingLeaf extends Applet {
add("Center", c);
/*
- * Change filenames into URLs
- */
- String substr = filename[0].substring(0,4);
- try {
- url[0] = new URL(filename[0]);
- }
- catch (Exception e) {
- return;
- }
- /*
* Create a simple scene and attach it to the virtual universe
*/
u = new SimpleUniverse(c);
@@ -364,26 +331,31 @@ public class MoveAppBoundingLeaf extends Applet {
// as well as an applet
//
public static void main(String[] args) {
+
if (args.length > 0) {
- if ( (args[0].startsWith("file"+File.pathSeparator)) ||
- (args[0].startsWith("http"+File.pathSeparator)) ) {
- path = args[0];
- }
- else {
- path = "file:" + args[0];
+ try {
+ if ( (args[0].startsWith("file"+File.pathSeparator)) ||
+ (args[0].startsWith("http"+File.pathSeparator)) ) {
+ url = new URL(args[0]);
+ } else if (args[0].charAt(0) != '/') {
+ url = new URL("file:./" + args[0]);
+ } else {
+ url = new URL("file:" + args[0]);
+ }
+ } catch (MalformedURLException e) {
+ System.err.println(e);
+ System.exit(1);
}
}
- else {
- path = "file:.";
- }
- if (args.length > 1) {
- filename[0] = args[1];
- if (filename[0] != null) {
- filenamesGiven++ ;
+ if (url == null) {
+ url = Resources.getResource("resources/audio/techno_machine.au");
+ if (url == null) {
+ System.err.println("resources/audio/techno_machine.au not found");
+ System.exit(1);
}
}
-
+
new MainFrame(new MoveAppBoundingLeaf(), 256, 256);
}
}