Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Streaming mp3 Problem...that dog won't hunt! 2

Status
Not open for further replies.

calmar

Technical User
Feb 15, 2001
32
US
Hi!
Can anyone please throw me a rope?
I've banged my head on this for a week and can't
get it to fly right...checked the posts & didn't find
one that addressed it.

Problem:

I have a client who currently has a Flash intro with
an mp3 embedded in the html doc. It plays, but the mp3
cuts off before it's done (on his machine).

I took the mp3 and embedded it in the movie & synched it
to stream. It played fine on my 3 computers (online), from
at least 2 other offsite computers.

However, my client says he can't hear any sound on his home or office computers.

Next I tried starting the mp3 on frame 5
( thing.
(actually, I just checked it and I don't hear sound
either, although it worked fine initially)

((BTW, I cleared the browser cache before testing it...
maybe I'm still getting the cached version??))

I've tried publishing it for different versions of
the plugin (4,5,6)....still no dice.

My latest try was to use the Load Streaming MP3 Behavior
but it's slow to load even on my local test, and I don't
get any sound now even when I control/test from Flash ?!)

Any advice would be welcome!!
Thanks,
Cal [smile]
 
Seems to work fine for me! PIV - ME - IE5.5 - Flash 7 - Cable connection.
 
oldnewbie,

thanks for checking, ...the client is using a pc IE6, DSL.

Is there supposed to be an advantage to using the
behavior vs embedding the mp3 from the library?
(besides making the swf size smaller).

It (the behavior) doesn't work at all for me, unless I was supposed to do something else besides putting it on a keyframe on it's own layer...it added the frames for the rest of the movie, and I published it in the same directory as the mp3.

It may be just a problem with his machine, but he says his
friends have tested it and have the same problem.

((I'm including the behavior code in case you wanted to see))

Thanks,
Cal

//Load Streaming mp3 behavior
if(_global.Behaviors == null)_global.Behaviors = {};
if(_global.Behaviors.Sound == null)_global.Behaviors.Sound = {};
if(typeof this.createEmptyMovieClip == 'undefined'){
this._parent.createEmptyMovieClip('BS_ClaireMP3',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) );
_global.Behaviors.Sound.ClaireMP3 = new Sound(this._parent.BS_ClaireMP3);
} else {
this.createEmptyMovieClip('_ClaireMP3_',new Date().getTime()-(Math.floor((new Date().getTime()) /10000)*10000) );
_global.Behaviors.Sound.ClaireMP3 = new Sound(this.BS_ClaireMP3);
}
_global.Behaviors.Sound.ClaireMP3.loadSound("Claire13AIF.mp3",true);


 
Sorry, but this behavior thingy is news to me! First time I've seen this. Is this done in MX2004, and with AS2.0?

I'm used to either attaching sounds from the Library as "event" soundObjects, or dynamically loading them from the server as "streaming" soundObjects. Mind you you can also dynamically load "event" soundObjects also.

The main difference between attached sounds from the Library, and dynamically loading them, other than the .swf's size, is mainly that when dynamically loading "streaming" sounds, the sound will start on it's own when enough has buffered, usually around 5 seconds. Works fine on a fast connection, but usually, miserably fails on a slow connection (unless you used a very low bit rate...), at least on the initial download.
Dynamically loading "event" sounds on the other hand, have to be started and can only be started when they're fully loaded, as attached sounds from the Library have to be fully loaded, before you can start them up.

If you use a "streaming" dynamically loaded sound, you can't really sync it up with the start of your movie, unless you delay the playing of the movie until the sound starts playing.
If you use a dynamically loaded "event" sound or an attached sound from the Library, then you must make sure that all elements are preloaded before starting the movie.

Think I might just be adding to your confusion on this, so I'll wait for your further reflections on all of this...

You could also have a look at this great soundObject tutorial...


Htt
 
Yeah, I intially imported the mp3 to the library & attached an instance to frame 1 of it's layer, &
synched it as "streaming". That worked fine for me, but he
couldn't hear the music on his machine.

In Sham's book (FOE) on MX2004, he suggested starting the
mp3 at frame 5, with a "kicker" mp3 on frame 4 (sound at
lowest level)....I haven't tried the kicker yet.

Another book at B&N suggested using the Load Streaming MP3 behavior in MX2004...I didn't even know it was there!

Window > Development Panels > Behaviors > Add > Sound
> Load Streaming MP3

Maybe it has to be configured ..?

Here's the info I found in the Flash Help in Flash
(it's over my head):

Preloading MP3 and FLV files
To preload MP3 and FLV files, you can use the setInterval() function to create a "polling" mechanism that checks the bytes loaded for a Sound or NetStream object at predetermined intervals. To track the download progress of MP3 files, use the Sound.getBytesLoaded() and Sound.getBytesTotal() methods; to track the download progress of FLV files, use the NetStream.bytesLoaded and NetStream.bytesTotal properties.

The following code uses setInterval() to check the bytes loaded for a Sound or NetStream object at predetermined intervals.

// Create a new Sound object to play the sound.
var songTrack = new Sound();
// Create the polling function that tracks download progress.
// This is the function that is "polled." It checks
// the download progress of the Sound object passed as a reference.
checkProgress = function (soundObj) {
var bytesLoaded = soundObj.getBytesLoaded();
var bytesTotal = soundObj.getBytesTotal();
var percentLoaded = Math.floor(bytesLoaded/bytesTotal * 100);
trace("%" + percentLoaded + " loaded.");
}
// When the file has finished loading, clear the interval polling.
songTrack.onLoad = function () {
clearInterval(poll);
}
// Load streaming MP3 file and start calling checkProgress()
songTrack.loadSound("beethoven.mp3", true);
var poll = setInterval(checkProgress, 1000, songTrack);

You can use this same kind of polling technique to preload external FLV files. To get the total bytes and current number of bytes loaded for an FLV file, use the NetStream.bytesLoaded and NetStream.bytesTotal properties.

Another way to preload FLV files is to use the NetStream.setBufferTime() method. This method takes a single parameter that indicates the number of seconds of the FLV stream to download before playback begins.

For more information, see MovieClip.getBytesLoaded(), MovieClip.getBytesTotal(), NetStream.bytesLoaded, NetStream.bytesTotal, NetStream.setBufferTime(), setInterval(), Sound.getBytesLoaded(), and Sound.getBytesTotal().


Cal
 
No, sorry but I'm on MX only still! And don't plan to upgrade, so I'll have to hand down this one to someone else!
 
I can hear the sound also.

As an alternative to loading in a streaming mp3 file with the buffering and playback problems Old has already touched on I usually stream large sound files as .swf - create a new movie empty except for the sound placed on the timeline, add in as many frames as necessary to hold the complete waveform and put a stop() on the last frame so that it doesn't loop.

You can then load this swf into _level1 (or whatever) of your main movie via loadMovie - since swfs stream by default and the mp3 compression within Flash is much better than most commercial mp3 programs I find this provides smaller filesizes and better playback performance than using a Sound object in this circumstance although I find loadSound still works great with short sound effects etc.
 
Wangbar,
I put the mp3 in it's own
swf, created an (invisible) mc on frame 5 of a new
layer of the movie I want to load the mp3 into.

I put this code on the frame that contains the
mc that will hold the swf

loadMovie("Claire.swf","_root.claireMC");

The main movie plays but no sound(?) Did I put
the code in the wrong place?
Thanks,
Cal
 
Are you using a soundObject in that external .swf, or have you laid the sound on the timeline?
 
Hi Old,
I put an instance of the mp3 on the
timeline of claire.swf

Cal
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top