Re: AudioQueue newbie : Handling Forward , Rewind , etc..,
Re: AudioQueue newbie : Handling Forward , Rewind , etc..,
- Subject: Re: AudioQueue newbie : Handling Forward , Rewind , etc..,
- From: Devon Tucker <email@hidden>
- Date: Tue, 29 Jul 2008 16:52:33 -0230
Raj,
I'm currently grappling with the exact same issues. I think I know how
to solve these problems conceptually but I'm not sure about the
implementation. Keep in mind that I know very little about digital
audio so I hope someone will correct me if I'm wrong (Which I very
well could be).
For forward and rewind, seeking, you need to determine the packet
index given the time in seconds you wish to seek to. For example given
that you want to seek to time "pos" you would calculate the necessary
packet index like this:
packetIndex = (pos * sampleRate) / framesPerPacket
Implementation-wise, I guess, depends on how you want to do it. You
could stop playback, clear your buffers, start buffering from then new
packet index and start playback again. You could also simply reset
your packetIndex to the desired index and keep playing normally.
As for tracking the position through the song, this can be
accomplished much the same way. Given the currently playing packet we
can determine the position by:
position = (packetIndex * framesPerPacket) / sampleRate
In order to keep track of the position in the audio file, with respect
to implementation, we need to keep track of our current packet index.
This packet index could be different from the packet index needed for
your buffer callback however, due to buffer priming. I recommend
keeping a separate packet index for playback, which starts at zero
when playback starts and gets incremented by the number of packets
read in your buffer callback.
Hope this helps,
Devon
On 28-Jul-08, at 5:56 AM, Rajeswar Rao wrote:
Hi ,
Im trying to paly audio file, using AudioQueue ,
I could Play , Pause using AudioQueueStart and AudioQueuePause ;
Now im trying to implement 'Forward/Rewind' functionality also the
duration played so far .....
How can I achieve this ? Do I have to handle these things in
"Callback function" ? if so , how ?
any suggestions are appreciated.
Thanks in Adavance
~Raj
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
Cheers,
Devon
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden