Hi All,
On my iPhone I'm seeing (actually, hearing) a problem where the beginnings of sounds aren't being played. These are MP3 files that the app has downloaded and saved on the device. They are being loaded and played like this:
| var file:File = new File(url); | |
| var request:URLRequest = new URLRequest(file.url); | |
| var context:SoundLoaderContext = new SoundLoaderContext(500, true); | |
| var sound:Sound = new Sound(request, context); | |
| sound.addEventListener(IOErrorEvent.IO_ERROR, onSoundLoadError); | |
| sound.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSoundLoadError); | |
| var transform:SoundTransform = new SoundTransform(soundVolumeAdjustmentFactor); | |
| _soundChannel = _sound.play(0, 1, transform); | |
| _soundChannel.addEventListener(Event.SOUND_COMPLETE, onSoundComplete); |
This is happening in a Flex mobile app. I'm not seeing it on Android, on the desktop AIR simulator, or on my 5th generation iPod Touch - only on my iPhone 4.
The problem is somewhat random/erratic - as to when / which audios / degree of clipping - but is easy to reproduce in my app. I haven't tried creating a sample, bare bones app that demonstrates the problem yet - I'm hoping that one of you will have dealt with this and can provide an easy solution.
I've already put several days into trying to solve this at this point, and have done a lot of googling.
I'm seeing clipping of anything from a fraction of a second up to cases where the first 10 seconds of an audio isn't played. Typically my files range from as short as a fraction of a second to several seconds, but I'm using a longer (12 second) file for testing purposes, which is what allows me to see cases where a full 10 seconds of audio is ignored. This 10-second case only happens in the first file that's played after I start up the app.
The only thing that I've found that helps is to a) create the Sound and SoundTransform, b) play the sound in a loop at zero volume (new SoundTransform(0)), c) wait a while (1 second) using Timer, then d) play the sound again with volume turned up. This improves the situation but doesn't solve it.
- The problem becomes much more predictable - i.e. less random and erratic. It happens to the same degree to the same files in the sequence of files that I'm playing.
- The problem decreases, e.g. the maximum clipping that I'm seeing is 3-4 seconds, and it happens in a smaller percentage of the files that I play.
Once I do this, the problem seems to affect specific files more than others. In other words, it consistently impacts certain files but not others, regardless of their position in the sequence of play. The problem-prone and problem-free files look similar to me when I open them in Audacity. Mystery upon mystery.
Any ideas on what is causing this, or how to prevent it? Is this a known bug? Is there an error in my code?
Thanks,
Douglas