• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

Sound Streaming question

I'm using flash to stream some MP3s and I have a few problems:

1. I need to be able to pause/resume the streaming, I tried stopping and then starting again in a specific offset. It doesn't start at all. If I load the sound again after it was played, I can play it again but no matter what offset I as k to start it at, it starts in the beginning.

2. A similiar problem, I need to be able to jump inside the soundclip to a different position.

3. If I load a clip to an existing soundclip, the duration property updates, but the position property continues from where it was and is not set to the real position in the track.
How do I reset it? - what I did was to save the position on the track change, but I would prefare something more elegant...

Yours,
<><
Dancer
0
Dancer
Asked:
Dancer
  • 5
  • 4
1 Solution
 
ocgstylesCommented:
0
 
DancerAuthor Commented:
Thanks, this says that all should work fine except the stop() and then start() because of a bug in flash, but how about loading again and then starting at an offset, this doesn't work either!

How about the duration problem and playing from an offset?

<><
Dancer
0
 
ocgstylesCommented:
I would think that what you said last would work too...let me experiment a little bit.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
ocgstylesCommented:
here is code that i did.  one mistake i was making was that, the position property is in milliseconds.  you may be making the same mistake.  the offset time is in seconds.  i had two buttons on the stage, one calls the playAmber function and the other calls the pauseAmber function.  if this isn't close, post the code you are using so i can get a better idea.

//frame 1
paused_loc = 0;
playing = false;

function createAmber(loc){
     amber = new Sound();
     amber.attachSound("amber3");
     dur.text = amber.duration;
}

function playAmber(){
     createAmber();
     amber.start(paused_loc,999);
     trace("started at " + paused_loc);
     gotoAndPlay(5);
     playing = true;
}

function pauseAmber(){
     paused_loc = amber.position/1000;
     amber.stop();
     trace("paused at " + paused_loc);
     playing = false;
}
createAmber();
stop();

//play button
on(press){
  playAmber();
}

//pause button
on(press){
  pauseAmber();
}

-ocgstyles
0
 
DancerAuthor Commented:
Hi, I did just that, and didn't forget to divide by 1000 (I also tried rounding it with int())

The difference between us is that I stream the sound, and you attach a loaded sound... I think that is where the problem is.
I have an array of URLs of mp3s (TrackURL[]) and an array of matching titles (TrackName[])
I commented out irrelevant stuff...

function PlayItem (item,StartTime)
{
//     this.nCurItem = item;
     this.bPlaying = true;
     this.CurSound.loadSound(TrackURL[item], true);
//     if (_root.MuteSign._visible == false)
//          this.CurSound.setVolume(this.nVolume);
//     else
//          this.CurSound.setVolume(0);
     this.CurSound.start(StartTime,1);
//     _root.CurTrackName = TrackName[item]
}

I use the same button for play and pause and have a toggle bPause on the actions MovieClip. PauseSymbol displays above the playbutton when pause is on.
This is the PlayButton's onPress:

on(press)
{
     if (_root.actions.bPause == true)
     {
          _root.PauseSymbol._visible = false;
          _root.actions.bPause = false;
          _root.actions.PlayItem(_root.actions.nCurItem,int(_root.actions.CurSoundOffset/1000));
     }
     else
     {
          _root.PauseSymbol._visible = true;
          _root.actions.bPause = true;
          _root.actions.CurSoundOffset = _root.actions.CurSound.position;
          _root.actions.CurSound.stop();
     }
}
0
 
ocgstylesCommented:
I wanted to take another look at this, just haven't had the time yet.....

-ocgstyles
0
 
DancerAuthor Commented:
sure, when you have the time...
0
 
rexmorCommented:
Im my previous project I used streaming sound. what I did was... I only Select Sync:Stream. in the Sound Panel.

Not so sure with this idea.


rex



0
 
DancerAuthor Commented:
I guess that with loadsound it doesn't know how to jump forward... even if it is already fully loaded, probably a "known feature" kind of bug...

thanks anyway for the help.

<><
Dancer
0
 
DancerAuthor Commented:
I'd be happpy to hear if you know anything new about the subject :-)

Yours,
<><
Dancer
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now