01: /*
02: * JOALTestResources.java
03: *
04: * Created on 18 July 2006, 22:23
05: *
06: * To change this template, choose Tools | Template Manager
07: * and open the template in the editor.
08: */
09:
10: package org.jdesktop.j3d.apps.sound;
11:
12: import java.io.BufferedInputStream;
13: import java.io.File;
14: import java.io.FileInputStream;
15: import java.io.FileNotFoundException;
16: import java.io.InputStream;
17: import java.net.URL;
18: import javax.media.j3d.MediaContainer;
19:
20: /**
21: *
22: * @author dave
23: */
24: public class JOALTestResources {
25:
26: /** Creates a new instance of JOALTestResources */
27: public JOALTestResources() {
28: }
29:
30: public static URL getTestMediaURL(String filename) {
31: //System.out.println("JOALTestResources - getTestMediaURL - " + url);
32: URL url = JOALTestResources.class.getResource(filename);
33: return url;
34: }
35:
36: public static MediaContainer getMediaContainerFromClasspath(
37: String urlString) {
38: URL url = getTestMediaURL(urlString);
39: System.out
40: .println("JOALTestResources - getMediaContainerFromClasspath - "
41: + url);
42: MediaContainer mc = new MediaContainer(url);
43: return mc;
44: }
45:
46: public static MediaContainer getTestMediaContainer(String path,
47: boolean isClasspath) {
48: MediaContainer mc = null;
49: if (isClasspath) {
50: mc = getMediaContainerFromClasspath(path);
51: } else if (isClasspath) {
52: mc = getMediaContainerFromFile(path);
53: }
54: return mc;
55: }
56:
57: public static MediaContainer getMediaContainerFromFile(
58: String filename) {
59: try {
60: File file = new File(filename);
61: InputStream is = new BufferedInputStream(
62: new FileInputStream(file));
63: System.out.println(is);
64: MediaContainer mc = new MediaContainer(is);
65: System.out.println(mc);
66: return mc;
67: } catch (FileNotFoundException ex) {
68: ex.printStackTrace();
69: }
70: return null;
71: }
72: }
|