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?
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));
AVAudioPlayer * sound = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:nil];
sound.delegate = self;
sound.volume = 1;
NSLog([NSString stringWithFormat:@"%f", sound.duration]);
try this....
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.