[RESOLU]Lag sur premier son

allianallian Membre
juin 2009 modifié dans API UIKit #1
Bonjour,
lorsque je joue un son pour la première fois dans mon appli cela provoque assez souvent un lag de l'app genre d'une demi seconde.

Et cela pour différents types de fichiers son.

Je fais cela comme indiqué dans la doc Apple :

//initializing the sounds<br />	// Get the main bundle for the app<br />&nbsp; &nbsp; CFBundleRef mainBundle;<br />&nbsp; &nbsp; mainBundle = CFBundleGetMainBundle ();<br />&nbsp; &nbsp; <br />&nbsp; &nbsp; // Get the URL to the sound file to play<br />&nbsp; &nbsp; soundFileURLRefLoose&nbsp; =&nbsp; &nbsp; CFBundleCopyResourceURL (<br />												&nbsp;  mainBundle,<br />												&nbsp;  CFSTR (&quot;Loose&quot;),<br />												&nbsp;  CFSTR (&quot;caf&quot;),<br />												&nbsp;  NULL<br />												&nbsp;  );<br />	<br />&nbsp; &nbsp; // Create a system sound object representing the sound file<br />&nbsp; &nbsp; AudioServicesCreateSystemSoundID (<br />									&nbsp; soundFileURLRefLoose,<br />									&nbsp; &amp;soundFileLoose<br />									&nbsp; );<br />	<br />	// Get the URL to the sound file to play<br />&nbsp; &nbsp; soundFileURLRefBonus&nbsp; =&nbsp; &nbsp; CFBundleCopyResourceURL (<br />														mainBundle,<br />														CFSTR (&quot;Bonus&quot;),<br />														CFSTR (&quot;caf&quot;),<br />														NULL<br />														);<br />	<br />&nbsp; &nbsp; // Create a system sound object representing the sound file<br />&nbsp; &nbsp; AudioServicesCreateSystemSoundID (<br />									&nbsp; soundFileURLRefBonus,<br />									&nbsp; &amp;soundFileBonus<br />									&nbsp; );<br />	<br /><br />


J'initialise mes deux fichiers dans le viewDidLoad  et apres je les joue dans une méthode comme ceci :

//play the sound<br />					AudioServicesPlaySystemSound (soundFileBonus);


Quelqu'un connait il une solution ? Merci

Réponses

Connectez-vous ou Inscrivez-vous pour répondre.