im trying to build a simple streaming player, no playlists or anything.
the problem:
i cant set the volume for my streaming music before it plays.
the code is inside the 'Play' button
mySound.loadSound(url,true)
no matter what volume level i set on my volume knob, the stream starts playing at 100%.
now i can sort of undersand why...because my
mySound = new Sound(this);
is placed in Frame1 of the stage.
if i were to place
mySound.loadSound(url,true)
mySound.stop() //so that it doesnt start playing when the movie loads
in Frame1 of the stage as well, the volume settings work perfectly.
though, the dilemma is...i dont want the player to start streaming the huge mp3 as soon as the movie loads.
thanks for the reply.
but unfortunately that didnt make a difference.
in fact putting
mySound.setVolume(75);
within the onLoad function meant that my volume knob didnt update when i loaded movie. (at setVolume(75) my volume knob would point to about 1 o'clock)
hmm
i think the problem lies in having
mySound.loadSound("url", true);
in my Play button. i dont think any other codes within the player recognises the existence of 'mySound'.
as soon as that line loads, any volume setting via my volume knob or even
mySound.setVolume(75);
is 'forgotten'.
i was thinking of loading the stream with on(press) on my play button
and then having a volume code that would getVolume and then setVolume for a 'second' time.
ive didnt have much sucess because of my limited actionscript knowledge.
even though this method wouldnt have the best working player in the world...its the only possibility i can think of so far.
im guessing there is just no way to put loadSound in frame 1 WITHOUT the player streaming immediately upon loading?
on my other player, because it plays the background music, im allowed to have the loadSound in frame 1.
and my Play button only has something like
on(release){
_root.mySound.start(0,0);
}
and all volume settings would work perfectly.
heres the code in my volume knob just in case. obviously im not yet capable of writing all that myself.
it was actually off a volume knob tutorial.
thanks.
onClipEvent(load){
maxRotAngle = 120;
//read the initial volume & set the position of the knob this.rotbutton.
this.rotbutton._rotation = (2*_root.s.getVolume() - 100)*maxRotAngle/100;
}
/*
set the volume depending on the position of the knob
use formula to convert _rotation into volume range
*/
onClipEvent(enterFrame){
if (rotbutton.dorotate) {
_root.s.setVolume(Math.floor((100+this.rotbutton._ rotation/maxRotAngle*100)/2));
}
}
Your using 2 different sound objects. mySound on frame 1 and 's' in the volume control. And just adding the mysound object in frame 1 does not make it play. It doesn't play the sound till you load it. But why put it on root at all? Put everything inside a movie clip and oput the clip on the main timeline.
You can also download all kinds of player fla files to see how it's done, from the 'Movies" link at the top of the page.
er yer sorry
i was only posting 'mySound' for simplicity's sake.
all my objects are actually called 's'
so s.loadSound s.setVolume etcetc
just forgot to change the bit in my volume control before posting.
the reason i didnt want to put
mySound.loadSound(url, true)
in the root is because it starts streaming as soon as the swf is loaded up on a webpage.
certainly that seems to be the proper way to do it because it defines for the whole player what 'mySound' actually is.
i can stop the music playing when the swf loads.
i just add mySound.stop() to stop it playing.
problem is, it seems to continue streaming the huge music file taking up all the bandwidth necessary to load the rest of the page.
thats why i didnt want to put it in root.
i have thought about putting it inside a MC but couldnt work out how to do it....
i know how to import mp3s and stuff into the library and attach it to symbols
but not a streaming mp3 off a website.
certainly i dont want to import the whole song into my swf because that would seriously bloat everything defeating the point in streaming the song lol
ive searched up and down and it seems no other player is coded the way i am doing it.
yes i noticed theres a sound section
but im a newbie as well lol
im trying to make a streaming mp3 player that is all.
using loadSound to stream an external mp3 file.
the thing is i cannot put loadSound in root because i dont want it to start streaming soon as the swf loads.
but then if i dont put it in root, and putting it straight into my Play button instead,
then it seems that the sound object doesnt define properly leading to flash 'forgetting' my volume settings: whether on the volume knob, or mySound.setVolume(75) in root.
well i dont exactly want to do that.
but that method so far is the only way the volume settings work.
the file i have to stream is huge so i dont want it do start streaming at all unless the user clicks Play.
i use a rotating volume knob to control the volume.
the whole code is about 3 posts up.
and my sound object is actually 's'.
not 'mySound'.
i just thought that would be easier to read.
i have exactly the same bit of volume control code actually...
just except the volume readout.
attached is what i have at the moment.
sorry the codes are kind of everywhere...
if you try swapping the s.loadSound line from Play button to root, with a stop()
the volume settings will work perfectly
even though the song doesnt play because of the stop()
it will STILL start streaming.
you will see this if you have a bandwidth meter or something.
streaming the sound allows the user to play the sound as it downloads, otherwise the user has to wait until the entire sound downloads before it can be played. It's better if it streams. You can also do this on the timeline.
PHP Code:
s = new Sound();
s.stop();
and on the play button
PHP Code:
on(release){
_root.s.loadSound("url",true);
}
though i don't recommend it.
Last edited by EQFlash; 04-09-2006 at 09:23 PM.
If you don't think you're going to like the answer, then don't ask the question.
yesyes and that is exactly what im trying to do.
to stream a huge external mp3 file.
just that...i really dont want it to start downloading until user clicks Play.
my player seems to work perfectly too now.
hoever ive been trying to understand what 'sovolume' is.
from what i see...
'sovolume' is the variable for that textbox
the volume knob updates box with a volume output level
and then when the play button is pressed, flash takes that readout and applies it to the sound object 's'
is that right?
at one point i did try and work out something like
s.setVolume=s.getVolume
in my Play button but i gave up not knowing enough actionscript.
but i never thought using a text box between them would work.