3 Replies Latest reply on Sep 28, 2006 12:29 PM by Newsgroup_User

    Audio streaming issue - sound.duration

    Level 7
      Using Flash 8, AS2.0, streaming sounds via loadSound(url, true)

      When using the method Sound.duration, this returns whatever value Flash
      thinks is the length of the song. This is based on how much data Flash has
      loaded about the song.

      The duration is never really correct until the file has completely loaded,
      so I can't display a proper progress indicator if the file is still loading
      and playing at the same time.

      Anyone have a work-around?

      The file needs to stream because it's large and I don't want users to wait.
      (podcasts)

      Thanks,

      Chris Hayes


        • 1. Re: Audio streaming issue - sound.duration
          Level 7
          Christopher,

          > Using Flash 8, AS2.0, streaming sounds via loadSound(url, true)

          Gotcha.

          > When using the method Sound.duration, this returns whatever
          > value Flash thinks is the length of the song. This is based on how
          > much data Flash has loaded about the song.

          I doublechecked that, and you're right.

          > The duration is never really correct until the file has completely
          > loaded, so I can't display a proper progress indicator if the file
          > is still loading and playing at the same time.

          That makes sense. Now that I think about it, I think I've seen this
          occasionally on sites with audio. I think what I've seen is that progress
          indicators kinda "hang in there" until the full data have loaded.

          > Anyone have a work-around?

          Well, I suppose you could hard-code the known audio's length. Outside
          of that, seems like a fact of life. You could repeatedly check the duration
          until it stops changing and is above zero. Does that make sense?


          David Stiller
          Adobe Community Expert
          Dev blog, http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: Audio streaming issue - sound.duration
            Level 7
            Hi David,

            I haven't checked this board for a while, so I didn't notice you had posted
            something.

            What you suggested is actually exactly what we did and it works great -
            GMTA.

            Alternatively, you could embed ID3 tags with the time and convert that into
            milliseconds and set the progress from there. As long as you're using ID3 v2
            tags, Flash will read them BEFORE the song completely loads.


            Thanks,
            Chris


            • 3. Re: Audio streaming issue - sound.duration
              Level 7
              Chris,

              > What you suggested is actually exactly what we did
              > and it works great - GMTA.

              Cool.

              > Alternatively, you could embed ID3 tags with the
              > time and convert that into milliseconds and set the
              > progress from there. As long as you're using ID3 v2
              > tags, Flash will read them BEFORE the song
              > completely loads.

              Ah! Even cooler! Good thinking. :)


              David Stiller
              Adobe Community Expert
              Dev blog, http://www.quip.net/blog/
              "Luck is the residue of good design."