RoundOutTooSoon
RoundOutTooSoon

Reputation: 9891

Using audioqueue to stream audio. How to get the length of the audio file before playback ends?

Already finished implementing the player. I want to implement the progress bar. But I wonder if that's possible to do since we are streaming the music. Unless we are provided the length of the song before hand.

Please, I need your advice on this.

Upvotes: 0

Views: 1509

Answers (2)

RoundOutTooSoon
RoundOutTooSoon

Reputation: 9891

Actually, I found a way to do that and I succeeded. That you calculate the number of frames per packet of the song, and the average packet's size (in bytes). Use NSHTTPConnection to get the file size and use this formular:

totalFrames = (fileSize * framesPerPacket / average packet size)

when you have total frames, just divide it by the bitrate, then u get urself the total time!!

Upvotes: 1

fbrereto
fbrereto

Reputation: 35925

Unless you are given the size (or time length) of the audio file beforehand, there's no way you can set the range of your progress bar (you'll have no max).

Upvotes: 3

Related Questions