2

I am developing a simple game for android using adobe air, but there is some delay in the sound effects when playing it on the device. I checked the sound (mp3 file) if there is any silence at the beginning but the sound file does not have any silence. So I thought I could develop an ANE to play the sounds and to avoid audio latency. Now the problem with ANE is that it throws IO error when tried to access the mp3 file. I am new to creating ANE and I cant get this working. I have the mp3 file in res/raw folder by name snd.mp3 and I have the res folder copied to Android-ARM folder and packaged the ANE along with sounds.jar and library.swf. I am using SoundPool to play the sound.

I tried to access the sound by passing the string to load function of SoundPool:

sp.load("android.resource://" +
        freContext.getActivity().getPackageName() +  
        freContext.getResourceId("raw.snd"));

However the resourceId gives a unique number which shows the sound file exists but I am unable to get the sound to play. I also tried with MediaPlayer, its the same. It throws IO error. Is there anything that I am doing wrong or missing? Any help would be appreciated. Thanks in Advance.

isnot2bad
  • 24,105
  • 2
  • 29
  • 50
animator
  • 61
  • 2

1 Answers1

0

You need an additional slash between the package name and the resource ID:

sp.load("android.resource://" +
        freContext.getActivity().getPackageName() + "/" +
        freContext.getResourceId("raw.snd"));
Dave Walker
  • 153
  • 1
  • 8