我正在使用Matt Gallagher的AudioStreamer从url中流式传输mp3文件。我需要知道流的持续时间,但我找不到方式?!
我尝试使用AudioStreamer对象的duration属性,但它返回0,可能是因为流来自url。
请帮帮我!
audioStreamer = [[AudioStreamer alloc] initWithURL:[NSURL URLWithString:@"http://ia701509.us.archive.org/25/items/TvQuran.com__Maher/001.mp3"]];
[audioStreamer start];在启动流之后,我想获得它的持续时间?
发布于 2013-04-06 01:01:07
我发现了一个使用ID3标签和AVAsset的很好的解决方案
NSURL *url = [NSURL URLWithString:@"your url here"];
AVAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
NSLog(@"> Duration = %.2f seconds", CMTimeGetSeconds(asset.duration));发布于 2013-04-05 17:33:27
AVAudioPlayer * sound = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:nil];
sound.delegate = self;
sound.volume = 1;
NSLog([NSString stringWithFormat:@"%f", sound.duration]);试试这个..。
https://stackoverflow.com/questions/15829700
复制相似问题