1
1
/*
2
- * Copyright (c) 2009-2012 jMonkeyEngine
2
+ * Copyright (c) 2009-2012, 2016 jMonkeyEngine
3
3
* All rights reserved.
4
4
*
5
5
* Redistribution and use in source and binary forms, with or without
33
33
34
34
import com .jme3 .asset .AssetManager ;
35
35
import com .jme3 .asset .AssetNotFoundException ;
36
+ import com .jme3 .audio .AudioData .DataType ;
36
37
import com .jme3 .export .InputCapsule ;
37
38
import com .jme3 .export .JmeExporter ;
38
39
import com .jme3 .export .JmeImporter ;
@@ -127,6 +128,17 @@ public AudioNode() {
127
128
public AudioNode (AudioData audioData , AudioKey audioKey ) {
128
129
setAudioData (audioData , audioKey );
129
130
}
131
+
132
+ /**
133
+ * Creates a new <code>AudioNode</code> with the given audio file.
134
+ * @param assetManager The asset manager to use to load the audio file
135
+ * @param name The filename of the audio file
136
+ * @param type The type. If <code>{@link com.jme3.audio.AudioData.DataType}.Stream</code>, the audio will be streamed gradually from disk,
137
+ * otherwise it will be buffered (<code>{@link com.jme3.audio.AudioData.DataType}.Buffer</code>)
138
+ */
139
+ public AudioNode (AssetManager assetManager , String name , DataType type ) {
140
+ this (assetManager , name , type == DataType .Stream , true );
141
+ }
130
142
131
143
/**
132
144
* Creates a new <code>AudioNode</code> with the given audio file.
@@ -139,6 +151,8 @@ public AudioNode(AudioData audioData, AudioKey audioKey) {
139
151
* the stream cache is used. When enabled, the audio stream will
140
152
* be read entirely but not decoded, allowing features such as
141
153
* seeking, looping and determining duration.
154
+ *
155
+ * @deprecated Use {@link AudioNode#AudioNode(com.jme3.asset.AssetManager, java.lang.String, com.jme3.audio.AudioData.DataType)} instead
142
156
*/
143
157
public AudioNode (AssetManager assetManager , String name , boolean stream , boolean streamCache ) {
144
158
this .audioKey = new AudioKey (name , stream , streamCache );
@@ -152,9 +166,11 @@ public AudioNode(AssetManager assetManager, String name, boolean stream, boolean
152
166
* @param name The filename of the audio file
153
167
* @param stream If true, the audio will be streamed gradually from disk,
154
168
* otherwise, it will be buffered.
169
+ *
170
+ * @deprecated Use {@link AudioNode#AudioNode(com.jme3.asset.AssetManager, java.lang.String, com.jme3.audio.AudioData.DataType)} instead
155
171
*/
156
172
public AudioNode (AssetManager assetManager , String name , boolean stream ) {
157
- this (assetManager , name , stream , false );
173
+ this (assetManager , name , stream , true ); // Always streamCached
158
174
}
159
175
160
176
/**
@@ -167,17 +183,18 @@ public AudioNode(AssetManager assetManager, String name, boolean stream) {
167
183
* @deprecated AudioRenderer parameter is ignored.
168
184
*/
169
185
public AudioNode (AudioRenderer audioRenderer , AssetManager assetManager , String name ) {
170
- this (assetManager , name , false );
186
+ this (assetManager , name , DataType . Buffer );
171
187
}
172
188
173
189
/**
174
190
* Creates a new <code>AudioNode</code> with the given audio file.
175
191
*
176
192
* @param assetManager The asset manager to use to load the audio file
177
193
* @param name The filename of the audio file
194
+ * @deprecated Use {@link AudioNode#AudioNode(com.jme3.asset.AssetManager, java.lang.String, com.jme3.audio.AudioData.DataType) } instead
178
195
*/
179
196
public AudioNode (AssetManager assetManager , String name ) {
180
- this (assetManager , name , false );
197
+ this (assetManager , name , DataType . Buffer );
181
198
}
182
199
183
200
protected AudioRenderer getRenderer () {
@@ -310,6 +327,19 @@ public final void setStatus(AudioSource.Status status) {
310
327
this .status = status ;
311
328
}
312
329
330
+ /**
331
+ * Get the Type of the underlying AudioData to see if it's streamed or buffered.
332
+ * This is a shortcut to getAudioData().getType()
333
+ * <b>Warning</b>: Can return null!
334
+ * @return The {@link com.jme3.audio.AudioData.DataType} of the audio node.
335
+ */
336
+ public DataType getType () {
337
+ if (data == null )
338
+ return null ;
339
+ else
340
+ return data .getDataType ();
341
+ }
342
+
313
343
/**
314
344
* @return True if the audio will keep looping after it is done playing,
315
345
* otherwise, false.
0 commit comments