- Home /
Question by
chinaxfgu1 · Feb 16, 2012 at 05:33 AM ·
audiosoundexceptionstop
java.lang.IllegalStateException: stop() called on uninitialized AudioTrack.
Hi, My app reported the following exception: java.lang.IllegalStateException: stop() called on uninitialized AudioTrack. at android.media.AudioTrack.stop(AudioTrack.java:780) at org.fmod.FMODAudioDevice.run(Unknown Source)
does anyone know, what might be the cause of the exception: My code to play and stop sound is as below:
public static function PlayAudioClip (audioClip : AudioClip, position : Vector3)
{
var gameObject = new GameObject ("OneShotAudio");
gameObject.transform.position = position;
gameObject.tag = "SoundGameObject";
var source : AudioSource = gameObject.AddComponent (AudioSource);
source.clip = audioClip;
source.Play ();
Destroy (gameObject, audioClip.length);
return source;
}
public static function PlaySound(audioClip:AudioClip)
{
if(audioClip==sBonusTimeBGM)
{
PlayAudioClip(audioClip, sPlaySoundPosition);
}
if(GameStat.sSoundEnabled==0)
{
return;
}
if(!sHasWindowFocus)
{
return;
}
PlayAudioClip(audioClip, sPlaySoundPosition);
mSilentTime = 0;
}
function EnableSound()
{
GameStat.sSoundEnabled = 1;
}
function StopAllSound()
{
try{
var allPrefab : GameObject[] = GameObject.FindGameObjectsWithTag("SoundGameObject");
for (var aPrefab : GameObject in allPrefab) {
Destroy(aPrefab);
}
}catch(e){
Debug.Log("StopAllSound(), exception captured");
}
}
Comment
Answer by ghazza · Jun 02, 2013 at 11:11 PM
hi, try to put this
in your manifest file,let me know if that helped
Your answer
Follow this Question
Related Questions
How to stop Audio not all?? 0 Answers
How to Stop all audio 10 Answers
Sound stops when object is destroyed 6 Answers
How do I play a sound when pressing the W key, and when I stop pressing the W key, the sound stops? 2 Answers
Calculating rhythm of any music? 3 Answers