;

PDA

Click to See Complete Forum and Search --> : Problem with streaming sound on first frame


sdg_uk
03-28-2005, 04:45 PM
I've been having some trouble with starting a streaming sound by putting script on the first frame of a movie. I've tried searching the forum and Google but can't find a categoric answer so would appreciate any assistance.

In summary, I have script on frame one to start a streaming mp3. It works the first time I load the page, but not on subsequent visits.

The details of my query are below...

To test what is going on I've created a very simple movie with just two frames, each of duration zero tweens (view example here (http://www.stuartandnicola.com/exp/assets/applets/StreamAudio.html))

On frame 1 I have the following code to start my sound and loop it. The code was obtained from this board...

mysound = new Sound();
mysound.loadSound("somemusic.mp3", true);

mysound.onSoundComplete = function() {
mysound.start(0,999);
};
I have added a stop action on frame 1 and a text object that says "First Frame".

On frame two I have no code and a text object that says "Shouldn't be here!". This frame has a stop action.

When I first load the page then I get "First Frame" and the sound stream. If I then refresh the page, or navigate elsewhere and then come back, then I see "Shouldn't be here!" and get no sound. Therefore I have skipped over frame one, the streaming sound and the stop action.

I picked the issue up as the animation on my home page was not playing sound if you navigated around the site and then returned to the home page. The reason was the same as here - the stream was started on frame 1.

I can cure the issue by putting the sound script on frame 2, and leaving frame 1 blank (and removing the stop action!)

My question is:

Is frame one 'unreliable'? Is there a risk all actions get skipped?

The Macromedia website says that frame 1 is a GOOD place to put function definitions, but in the example here my frame one doesn't always occur so would that mean if I defined functions and variables on it then they may get missed?

I've noticed in KM that if you add a stop action to frame 1 it warns you that this is unreliable. Is this true of ALL script on frame 1?

I've posted the example swf file on a test area of my website (view example here (http://www.stuartandnicola.com/exp/assets/applets/StreamAudio.html)) if you want to try it out. I must admit I've not tried using other browsers to view the page yet.

Thanks.

docree
03-28-2005, 07:02 PM
Yes, that is true...

The first frame is unreliable in KoolMoves flash.
It seems [to me at least] that the first frame in KM is like frame 0 in MX.
See, if memory serves me right, computers start
count at 0 and it causes some confusion in programing
and multimedia creation.

Even macromedia had problems with flash early on. [My Fuzzy Memory] :rolleyes:
And I know for certain, Real Player had similar problems too.
____________________
The Work around...

Add a copy of your first frame to the begining
with no script or actions.
Then, set the new frame's tweens to 0.

That should work.
Doc'Ree

necromanthus
03-29-2005, 08:32 AM
Originally posted by sdg_uk
My question is:

Is frame one 'unreliable'? Is there a risk all actions get skipped?

The Macromedia website says that frame 1 is a GOOD place to put function definitions, but in the example here my frame one doesn't always occur so would that mean if I defined functions and variables on it then they may get missed?


No risk at all !
I always use this keyframe for certain functions and I had no problems at all.
The "first keyframe issue" was solved a long time ago (I can't remember the flash player version).
Now talking about the first keyframe and KoolMoves :
In certain situations,some objects (shapes,images,sounds) are exported in the first frame, and this is VERY bad !
In the "Export Settings / Loading Considerations" you must set the "Image/Sound placement" to "just before they're needed".
Otherwise ... troubles !
;)

sdg_uk
03-29-2005, 06:01 PM
Thanks for the comments. I decided to try some more experiments and have come to the following conclusions...


Putting a stop action on frame one (either using the KM command, or using script) is unreliable. The stop occurs the first time the movie plays, but not on subsequent runs

Using the loadSound method isn't reliable on the first frame. Again, it works the first time round, but not on subsequent plays.

Other script on frame 1 DOES seem to work. I made a very, very simple test movie that set a variable in frame 1 and displayed it using dynamic text in frame 2. The correct text appeared each time.

It seems to be JUST loadSound that is the problem. The movie works fine if I leave the rest of the sound code on frame 1, with or without stop action. That means the rest of the frame 1 script is running ok. For example, the function to loop the sound must be being created.

I need to get out more! I have made 12 movies to test this out...

So, I think from this I'm either going to always put blank frame at the start, just to be safe, or to make sure I only load my streaming sounds in a frame other than frame 1.

necromanthus - I tried your suggestion about export settings but that didn't seem to help.

Curiously, I tried adjusting my IE cache setting to always check for a newer page on each load and that actually makes the problem go away. As soon as I turn on the cache setting back on to provide some caching then frame 1 gets skipped.

Does the same behaviour occur in other browsers I wonder???

About the test movie
I made a simple two frame movie. The first frame sets a variable, the second frame has a dynamic text box that the variable is displayed in. The movie stops at frame 2. That way I can test if the variable assignment occurred. The code to load the streaming sound was moved from frame 1 to frame 2, and I then added stop actions to frame 1 using both the KM stop movie command and the stop() command.

necromanthus
03-30-2005, 02:37 AM
Originally posted by sdg_uk
necromanthus - I tried your suggestion about export settings but that didn't seem to help.
That's because, as I said before, in certain conditions some objects are exported in the first frame (no matter what are the export settings !!!).
This is an old KM bug and you can't do anything about that.
Another source of troubles may be the KM internal preloader (also don't forget: 2 keyframes are added).
As general rule: the first keyframe is useful for scripts (not for objects).
Now talking about your sound object: KM doesn't have a symbol-library, so you can't have "real" objects into your KM project.
Three important properties are available for a real object:
- can be Attached
- can be exported for ActionScript
- can be exported in the first frame
Unfortunately none of them is available for KM.
For now ...

Bob Hartzell
03-30-2005, 08:43 AM
Do your test files include a preloader? If so, turn that off because it may be confusing the results. Also turn off movie looping.

sdg_uk
03-30-2005, 06:53 PM
No - I didn't use a pre-loader for my mini movie. This was mainly because I was having problems with movies that were mostly script based and so very small and didn't need a pre-loader.

I tried my simple test movie with looping set to off but I still get the same results as above.

However, I have found one interesting result...

My other PC has a copy of Mozilla Firefox on it, so I revisited my original test movie (and all its variants) with Firefox and they work just fine - exactly as expected, every time. If you refresh, or navigate away and then come back, then you get precisely the action you expect.

i.e. the stop action on frame 1 works every time, the loadSound works every time. So frame one is reliable with FF!

Earlier on in my tests I'd already found that setting my IE cache to check for newer versions of a page on every visit made the movies work right, so is it something to do with the way the cache works in IE?!?!?

I think I'll just get in the habit of putting a blank frame on frame 1 or using the preloader (if the movie is big enough) so that IT adds a couple of frames for me :) then I don't have a problem :)

Bob Hartzell
03-31-2005, 08:08 AM
I applaud your scientific mind and relentlish experiments!

sdg_uk
03-31-2005, 08:32 AM
Lol - I'm a capricorn. If you believe in such stuff then that means I am stubborn, tenacious and methodical (my wife would agree with all of those so maybe there's something to it...)

From a practical point of view, I was wanting to make sure that my animations work properly for so my viewers get the effect I was intending. Hopefully this thread will help others achieve that too :)

necromanthus
03-31-2005, 09:20 AM
Originally posted by sdg_uk
So frame one is reliable with FF!

Earlier on in my tests I'd already found that setting my IE cache to check for newer versions of a page on every visit made the movies work right, so is it something to do with the way the cache works in IE?!?!?
Frame ONE is reliable for IE6 too.
For FireFox the "Check for newer versions of stored pages" is set to "Every visit to the page" by default.
For IE6 the default setting is "Automatically" (and this is source of troubles in many other situations,not only this one).
And this is because you can't stream anything from cache.
But this is another story ...
Anyway,a better method is to import that sound (in the first frame !),to set the number of loops and to validate "Stream" for it.

p.s.
Capricorn ??? Hmmm ... nasty creatures.
:smoov:

sdg_uk
03-31-2005, 03:27 PM
I'm not sure I understand your last comment

Anyway,a better method is to import that sound (in the first frame !),to set the number of loops and to validate "Stream" for it.
At the moment I load my sound using the following script:

mysound = new Sound();
mysound.loadSound("somemusic.mp3", true);Do you mean import as in import to the KM movie itself? and then set it to stream from in there?
________

PS: Capricorns are lovely (well, my other half must think so!) Apparently we are responsible and conscientious. Mind you, the same website that says that also says we can be domineering, bossy and unforgiving. I'd like to think I don't exhibit too much of those last three!
________

PPS: Someone else posted in to this board about how helpful and friendly everyone is - I second that :)

necromanthus
03-31-2005, 05:20 PM
Originally posted by sdg_uk
Do you mean import as in import to the KM movie itself? and then set it to stream from in there?
Yeap.
Take advantage of this great Flash feature: the SWF file ("everything in one file"),not available for HTML,PHP,CGI,ASP and so on.
It means the fastest download,no delays and no troubles.
Your method is useful only in case of music PlayLists (not this case I suppose)

p.s.
january 4th
ha ha ha