how is the external swf's sound created?
is there a sound file being loaded? is there an flv being played in an flvplayback component?
The swf file is compiled in Java. It is a frame by frame animation (bunch of screenshots) + stream sound in mp3 format.
No other SWF is loaded at the time and I'm not using FLV in this case.
your sound is attached to a timeline?
if yes, then a correctly coded preloader will ensure the sound is loaded completely before the sound starts to play IF there is a stop on the external swf's first frame.
Yes, the sound is attached to the main timeline.
The preloader is working, but I don't want to load the full SWF file, but just the required part, so I've implemented predictive preloader, which works well and image data are streamed well. Just the sound isn't working as expected and I need to find the sweet spot, where enough of the sound will be loaded, so the sound will start immediately. If I can check how much of the sound is loaded and if the sound should be played, I could solve this easily. Just, it seems there is no way to check, how much of the sound is loaded and if the sound is ready to play from Flash.
the problem is caused by your preloader. it does not completely load the sound which, from your description, is a requried part.
if the sound extends along a timeline and its sync property is stream (not event), you need to load all the frames that contain the sound.
Ok, so the preloader has to load the SWF file fully in this case? I tested the SWF file with different percentage and the sound doesn't have to be loaded fully. It's a stream sound, so it is streamed and even when it's loaded partially it should be able to play. So the issue is, there seems to be no way to check, the sound is ready to play, even if it's not fully loaded. And in this case it seems, no help for me.
check the number of frames loaded.
Unfortunatelly, this is not good solution, I don't know how many frames I need to load. If I know it, I don't have to ask on this forum
Sorry, there is probably no solution and I'll have to look at mp3 spec, SWF file spec and other things again.
if you can inspect the external swf's fla enough to know the sound's sync is set to stream you should be able to look at the timeline where the sound is attached and determine the number of frames the sound occupies.
I know everything about the file, I know that the sound starts on the first frame and also I know it ends on the last frame. If the sound data are on the main timeline, the sound could be streamed and you don't have to load it fully to start playback. The question is the same, how much I need to load to start the sound.
I think it's not very clear why I need this. Imagine:
- you need to play the external SWF file
- you start to load it via the MovieClipLoader class
- onLoadInit you stop the movie and wait for the load
- check, if you can run the movie - based on bytes and/or frames you can determine, you preloaded enough, so the movie won't be stopped and you don't have to load more to continue
- but, when you run the movie, the animation starts, just the sound doesn't, because more of it needs to be loaded.
- then after short time the sound start to play and since it's streamed and on the timeline, it's sync with the animation
So, in this scenario a few seconds of the sound are skipped / missing in playback. Of course, it could happen that the sound runs fine, because the SWF content could be different. I can't say 20% of the file size is audio and the rest is the animation.
I wanted fully flash solution, but it seems I'll have to find it in combination with Java, because it seems there is no way to distinguish between audio and other data in the Flash movie in AS.
Anyway, thank you for your help.