我需要在React Native中访问流的ICY元数据(即歌曲标题,歌手)。使用axios.head
返回icy-metaint: "16000"
,这意味着数据存在。如何获取流的元数据?
我是否使用类似WebSockets
的方式来检索元数据?
以下代码:
function icyMetadata() {
const options = {
method: 'GET',
mode: 'cors',
headers: {
"Icy-MetaData": "1",
"Access-Control-Expose-Headers": "Access-Token, Uid"
}
}
axios.head('http://ais-sa1.streamon.fm/7261_64k.mp3', options)
.then(res => console.log(res.headers))
.catch(err => console.log(err))
}
返回:
access-control-allow-credentials: "true"
access-control-allow-headers: "ETag, If-None-Match"
access-control-allow-origin: "*"
access-control-expose-headers: "ETag, If-None-Match"
cache-control: "no-cache"
connection: "close"
content-type: "audio/mpeg"
expires: "Mon, 26 Jul 1997 05:00:00 GMT"
icy-br: "48"
icy-description: "Unspecified description"
icy-genre: "various"
icy-metaint: "16000"
icy-name: "105.9 Shine FM"
icy-pub: "1"
icy-url: ""
instance-id: "04bcede1dad351aa4d82e0e201345cb5"
p3p: "CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI""
pragma: "no-cache"
server: "AIS Streaming Server 8.1.3-rc3"
set-cookie: ["AISSessionId=5c47fb3377970f3d_1568458_tQIwO3gZ_MjE…x-Age=6000; Expires=Sun, 10 Feb 2019 10:44:29 GMT"]
x-loudness: "-11.134537"