Copy link to clipboard
Copied
Hello,
I need to load external SWF file, which contains simple image sequence + audio. I've used the MovieClipLoader class for this and also a preloader, where I'm checking if I can run the SWF safely, without the need to interrupt playback later and continue with loading. It's working similar to YouTube video, where the video is buffered.
The issue is that when I load the SWF and run it, the audio start to play later. I tested more cases and the reason is that even if I load enough from the SWF, I can be sure I can start playback, because it not enough loaded from the audio, so the it starts to play a bit later. When I load more, the audio starts to play immediately.
So the question is, is there a way how can I check if audio is loaded and ready to play?
Thanks,
Michal
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Michal
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Michal
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
check the number of frames loaded.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now