gpt4 book ai didi

iphone - 使用 AudioStreamer 获取 MP3 ID3 元数据和歌曲持续时间

转载 作者:行者123 更新时间:2023-12-03 21:00:02 30 4
gpt4 key购买 nike

我正在使用Matt Gallagher's AudioStreamer通过 HTTP 播放 MP3。我需要知道歌曲的时长和 ID3 标签。

是否可以在 AudioStreamer 中实现此功能,以及如何实现?

最佳答案

来自他的Docs :

Limited scope

One point should be clarified before I continue: this class is intended for streaming audio. By streaming, I don't simply mean "an audio file transferred over HTTP". Instead, I mean a continuous HTTP source without an end that continues indefinitely (like a radio station, not a single song).

这似乎意味着获取持续时间可能很困难。

以下是获取 ID3v2 标签的方法:

Get metadata

The easiest source of metadata comes from the HTTP headers. Inside the handleReadFromStream:eventType: method, use CFReadStreamCopyProperty to copy the kCFStreamPropertyHTTPResponseHeader property from the CFReadStreamRef, then you can use CFHTTPMessageCopyAllHeaderFields to copy the header fields out of the response. For many streaming audio servers, the stream name is one of these fields.

The considerably harder source of metadata are the ID3 tags. ID3v1 is always at the end of the file (so is useless when streaming). ID3v2 is located at the start so may be more accessible.

I've never read the ID3 tags but I suspect that if you cache the first few hundred kilobytes of the file somewhere as it loads, open that cache with AudioFileOpenWithCallbacks and then read the kAudioFilePropertyID3Tag with AudioFileGetProperty you may be able to read the ID3 data (if it exists). Like I said though: I've never actually done this so I don't know for certain that it would work.

关于iphone - 使用 AudioStreamer 获取 MP3 ID3 元数据和歌曲持续时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1550621/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com