0

我正在使用 Matt Gallagher 的 AudioStreamer 从 url 流式传输 mp3 文件。我需要知道流持续时间,但我找不到怎么做?!

我尝试使用 AudioStreamer 对象的持续时间属性,但它返回 0 可能是因为流来自 url。

请帮忙!

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

        [audioStreamer start];

开始流后我想得到它的持续时间?

4

2 回答 2

1

我使用 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-05T17:01:07.403 回答
0
AVAudioPlayer * sound = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:nil];
sound.delegate = self;
sound.volume = 1;
NSLog([NSString stringWithFormat:@"%f", sound.duration]);

试试这个....

于 2013-04-05T09:33:26.887 回答