AudioTrack : prevented audio track to be looped even if the channel loopMode is dontLoop

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9866 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 12 years ago
parent 53afc0f02e
commit a61bdf1d47
  1. 41
      engine/src/core/com/jme3/animation/AudioTrack.java

@ -44,8 +44,8 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
/** /**
* AudioTrack is a track to add to an existing animation, to paly a sound during an animations * AudioTrack is a track to add to an existing animation, to paly a sound during
* for example : gun shot, foot step, shout, etc... * an animations for example : gun shot, foot step, shout, etc...
* *
* usage is * usage is
* <pre> * <pre>
@ -54,7 +54,8 @@ import java.util.logging.Logger;
* control.getAnim("TheAnim").addTrack(track); * control.getAnim("TheAnim").addTrack(track);
* </pre> * </pre>
* *
* This is mostly intended for short sounds, playInstance will be called on the AudioNode at time 0 + startOffset. * This is mostly intended for short sounds, playInstance will be called on the
* AudioNode at time 0 + startOffset.
* *
* *
* @author Nehon * @author Nehon
@ -76,7 +77,6 @@ public class AudioTrack implements ClonableTrack {
} }
public void onAnimChange(AnimControl control, AnimChannel channel, String animName) { public void onAnimChange(AnimControl control, AnimChannel channel, String animName) {
stop();
} }
} }
@ -88,8 +88,10 @@ public class AudioTrack implements ClonableTrack {
/** /**
* Creates an AudioTrack * Creates an AudioTrack
*
* @param audio the AudioNode * @param audio the AudioNode
* @param length the length of the track (usually the length of the animation you want to add the track to) * @param length the length of the track (usually the length of the
* animation you want to add the track to)
*/ */
public AudioTrack(AudioNode audio, float length) { public AudioTrack(AudioNode audio, float length) {
this.audio = audio; this.audio = audio;
@ -99,9 +101,12 @@ public class AudioTrack implements ClonableTrack {
/** /**
* Creates an AudioTrack * Creates an AudioTrack
*
* @param audio the AudioNode * @param audio the AudioNode
* @param length the length of the track (usually the length of the animation you want to add the track to) * @param length the length of the track (usually the length of the
* @param startOffset the time in second when the sound will be played after the animation starts (default is 0) * animation you want to add the track to)
* @param startOffset the time in second when the sound will be played after
* the animation starts (default is 0)
*/ */
public AudioTrack(AudioNode audio, float length, float startOffset) { public AudioTrack(AudioNode audio, float length, float startOffset) {
this(audio, length); this(audio, length);
@ -110,10 +115,15 @@ public class AudioTrack implements ClonableTrack {
/** /**
* Internal use only * Internal use only
* @see Track#setTime(float, float, com.jme3.animation.AnimControl, com.jme3.animation.AnimChannel, com.jme3.util.TempVars) *
* @see Track#setTime(float, float, com.jme3.animation.AnimControl,
* com.jme3.animation.AnimChannel, com.jme3.util.TempVars)
*/ */
public void setTime(float time, float weight, AnimControl control, AnimChannel channel, TempVars vars) { public void setTime(float time, float weight, AnimControl control, AnimChannel channel, TempVars vars) {
if (time == length) {
return;
}
if (!initialized) { if (!initialized) {
control.addListener(new OnEndListener()); control.addListener(new OnEndListener());
initialized = true; initialized = true;
@ -132,6 +142,7 @@ public class AudioTrack implements ClonableTrack {
/** /**
* Retruns the length of the track * Retruns the length of the track
*
* @return length of the track * @return length of the track
*/ */
public float getLength() { public float getLength() {
@ -140,6 +151,7 @@ public class AudioTrack implements ClonableTrack {
/** /**
* Clone this track * Clone this track
*
* @return * @return
*/ */
@Override @Override
@ -148,8 +160,11 @@ public class AudioTrack implements ClonableTrack {
} }
/** /**
* This method clone the Track and search for the cloned counterpart of the original audio node in the given cloned spatial. * This method clone the Track and search for the cloned counterpart of the
* The spatial is assumed to be the Spatial holding the AnimControl controling the animation using this Track. * original audio node in the given cloned spatial. The spatial is assumed
* to be the Spatial holding the AnimControl controling the animation using
* this Track.
*
* @param spatial the Spatial holding the AnimControl * @param spatial the Spatial holding the AnimControl
* @return the cloned Track with proper reference * @return the cloned Track with proper reference
*/ */
@ -173,6 +188,7 @@ public class AudioTrack implements ClonableTrack {
/** /**
* recursive function responsible for finding the newly cloned AudioNode * recursive function responsible for finding the newly cloned AudioNode
*
* @param spat * @param spat
* @return * @return
*/ */
@ -220,7 +236,6 @@ public class AudioTrack implements ClonableTrack {
} }
} }
/** /**
* *
* @return the audio node used by this track * @return the audio node used by this track
@ -231,6 +246,7 @@ public class AudioTrack implements ClonableTrack {
/** /**
* sets the audio node to be used for this track * sets the audio node to be used for this track
*
* @param audio * @param audio
*/ */
public void setAudio(AudioNode audio) { public void setAudio(AudioNode audio) {
@ -252,6 +268,7 @@ public class AudioTrack implements ClonableTrack {
/** /**
* set the start offset of the track * set the start offset of the track
*
* @param startOffset * @param startOffset
*/ */
public void setStartOffset(float startOffset) { public void setStartOffset(float startOffset) {
@ -260,6 +277,7 @@ public class AudioTrack implements ClonableTrack {
/** /**
* Internal use only serialization * Internal use only serialization
*
* @param ex exporter * @param ex exporter
* @throws IOException exception * @throws IOException exception
*/ */
@ -272,6 +290,7 @@ public class AudioTrack implements ClonableTrack {
/** /**
* Internal use only serialization * Internal use only serialization
*
* @param im importer * @param im importer
* @throws IOException Exception * @throws IOException Exception
*/ */

Loading…
Cancel
Save