简体   繁体   中英

How to seek the streaming audio in iPhone?

I need to develop an audio streaming application ,which has the capability to play,pause and seek(fast forward). I have implemented the all operations except seek..I am using Matt's audio streaming sample code . Can anybody explain in detail about how to implement audio seek operation. I got an idea about seek operation. ie. using AudioQueueGetCurrentTime() method. But I cannot get the entire concept to implement it. So can you help me with a sample code?

Thanks in advance, Syam

dude i am working on the exact same thing. i looked forever!!!

i tried

SInt64 byteOffset;
            UInt32 ioFlags;
            NSLog(@"seek to packet %i", mainMP3delegate.seek_Packet);
            OSStatus err = AudioFileStreamSeek(inAudioFileStream, mainMP3delegate.seek_Packet, &byteOffset, &ioFlags);
            if (err) { PRINTERROR("seek error");  myData->failed = true;}

and i tried to change the start time to where i wanted

AudioTimeStamp ts; ts.mFlags = kAudioTimeStampSampleTimeValid; ts.mSampleTime = 111110; NSLog(@"sample time %f", ts.mSampleTime); ts.mSampleTime = mainMP3delegate.MP3_Timestamp; NSLog(@"sample time %f", ts.mSampleTime);

         err = AudioQueueStart(myData->audioQueue, &ts.mSampleTime);
         if (err) { PRINTERROR("AudioQueueStart"); myData->failed = true; return err; }     
         myData->started = true;

but neither worked

i know its something simple, i just don't know about, so I put up a bid on elance to get someone to solve it for money even!!! http://www.elance.com/jobs/16779786/iphone_application_audio_streaming_seek_scrub&&catId=11033&backurl=aHR0cDovL3d3dy5lbGFuY2UuY29tL3BocC9zZWFyY2gvbWFpbi9lb2xzZWFyY2gucGhwP21hdGNoVHlwZT1wcm9qZWN0I21hdGNoS2V5d29yZHM9aXBob25lJTIwc3RyZWFtJTIwc2VlayZzb3J0Qnk9JnNvcnRPcmRlcj0mcGFnZT0xJmNhdEZpbHRlcj0xMDAmc3ViY2F0RmlsdGVyPSZ0aW1lbGVmdEZpbHRlcj0mdGltZWxpc3RlZEZpbHRlcj0mYnVkZ2V0RmlsdGVyPS0xJmZlYXR1cmVkcHJvamVjdEZpbHRlcj1mYWxzZSZlc2Nyb3dwcm9qZWN0RmlsdGVyPWZhbHNlJmIyYnByb2plY3RGaWx0ZXI9ZmFsc2UmaG91cmx5cHJvamVjdEZpbHRlcj10cnVlJmZpeGVkcHJvamVjdEZpbHRlcj10cnVlJnN0YXR1c0ZpbHRlcj0xMDAzNyZhbWV4cHJvamVjdEZpbHRlcj0%3D&job_tier=11188

But, no luck. I ended up (for now) downloading the mp3 and seeking through the buffer like shown here, but it is not a good solution.

http://lists.apple.com/archives/coreaudio-api/2009/Jan//msg00143.html

man! if you figure this out or someone does, i would go crazy. i also put up a bid on rentacoder that someone is working on,

I was using the Matt's audio streaming sample code too, but I wasn't able to achieve a good seek with his code.

Now I'm using the MPMoviePlayerController that do the audio streaming and its seek function works great. The only problem is that the total time is calculated progressively, only when the download is in the end you can know the total time.

MPMoviePlayerController Class Reference

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM