Search code examples
iphoneiosobjective-cdurationaudiostreamer

Get duration of Matt Gallagher's AudioStreamer from http url?


I'm using Matt Gallagher's AudioStreamer to stream mp3 files from url. I need to know stream duration but I can't find how?!

I tried to use the duration property of the AudioStreamer object, but it returns 0 perhaps because the stream is from an url.

Help please!

audioStreamer = [[AudioStreamer alloc] initWithURL:[NSURL URLWithString:@"http://ia701509.us.archive.org/25/items/TvQuran.com__Maher/001.mp3"]]; 

        [audioStreamer start];

after starting the stream i want to get its duration?


Solution

  • I found a great solution using ID3 tags and AVAsset

     NSURL *url = [NSURL  URLWithString:@"your url here"]; 
            AVAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
            NSLog(@"> Duration = %.2f seconds", CMTimeGetSeconds(asset.duration));