3

i've one ios application that plays music by streaming and using the mattgallagher AudioStreamer library it doesn't show the real playtime and never stop play at 0 secs...

Does anyone know why this happens??

Thanks a lot!

Jovem
  • 185
  • 2
  • 9

2 Answers2

5

I experienced something similar. Have a look at the progress method in AudioStreamer.m

- (double)progress
{
    @synchronized(self)
    {
        if (sampleRate > 0) && ![self isFinishing])
        {
            if (state != AS_PLAYING && state != AS_PAUSED && state != AS_BUFFERING)
            {
                return lastProgress;
            }
    ...
        }
    }

    return lastProgress;
}

Now, the reason for the progress not being displayed correctly lies within the two if-statements. When your AudioStreamer is nearly finished (probably when all data is loaded), it's isFinishing becomes true, which makes it return the cached value for progress. Also, the streamer state becomes AS_STOPPING, which makes the second if-statement return the lastProgress. What you really want is to update the progress right until the streamer stops.

My following modification to the code does this and it seems to work fine. HOWEVER, given the general quality of the AudioStreamer and the fact that it's developed by Matt Gallagher, those if statements might be as they are for a reason. So far, I did not experience any crashes or alike with my modified code but you should thoroughly test it in your app. Note, that, once the streamer is done, I don't query the progress anymore. If you do, test if it works :)

- (double)progress
{
    @synchronized(self)
    {
        if (sampleRate > 0))
        {
            if (state != AS_PLAYING && state != AS_PAUSED && state != AS_BUFFERING && state != AS_STOPPING)
            {
                return lastProgress;
            }
    ...
        }
    }

    return lastProgress;
}
Philipp Schlösser
  • 5,179
  • 2
  • 38
  • 52
  • hi, thank you... i'm testing this solution and it works well than after... but if i seek the music to another time the problem happens again.. – Jovem Oct 31 '11 at 11:37
  • Oh, so you have a slider to change the position in the song? Well, yeah, I don't have that in my app :/ – Philipp Schlösser Oct 31 '11 at 11:43
  • This solution is better, but as soon as the state turns to `AS_STOPPING` the progress stops updating. I'd love to see an answer that fixed this issue. – bendytree Aug 14 '12 at 01:36
0

The issue has been addressed:

https://github.com/mattgallagher/AudioStreamer/issues/39

Say2Manuj
  • 709
  • 10
  • 20