通过 JavaScript 监听/捕获 HTTP 请求事件
我有一个 Flash MP3 播放器,我计划在我的网站上使用它,我尝试做的事情(因为 Flash 元素本身没有内置回调)是侦听它可能发出的任何 HTTP 请求。目前,我可以在 Chrome 时间轴中看到 HTTP 请求表单,它准确地告诉我在播放列表中运行时所请求的每个文件的名称和位置 — 它显示为“发送请求”。我尝试这样做的目的是可能获取文件名,通过 PHP 扫描它,并通过 jQuery 将其 ID3 图像返回到浏览器。这可能吗?
从 Chrome 时间线检索: 发送请求 - 详细信息 自拍时间0ms 聚合时间 0ms0ms0ms 持续时间 303 毫秒(1.49 秒时) 资源轨道-02.mp3 请求方式 GET 已用堆大小 23.87MB / 41.62MB
I have an Flash MP3 Player that I am planning to use on my site, and what I am attempting to do (since the Flash element itself doesn't have a built in callback) is to listen for any HTTP Request it may make. Currently I can see the HTTP request form within my Chrome Timeline, and it tells me exactly the name and location of each files being requested as it is running through the playlist —- it shows up as "Send Request". The purpose for me attempting to do this is to possibly grab the file name, scan it via PHP, and return its ID3 image to the browser via jQuery. Is this possible?
Retrieved from Chrome Timeline:
Send Request - Details
Self Time 0ms
Aggregated Time 0ms0ms0ms
Duration 303ms (at 1.49s)
Resource Track-02.mp3
Request Method GET
Used Heap Size 23.87MB of 41.62MB
浏览器不提供用于侦听任何 HTTP 请求的 API。
您可以尝试通过脚本提供 mp3 文件。然后,该脚本可以将加载的文件的详细信息存储在某处。然后让 JS 代码查询另一个脚本,该脚本返回存储的详细信息。
Browsers do not provide an API for listening for any HTTP request.
Something you could try is serving the mp3 files via a script. This script could then store the loaded file's details somewhere. Then have your JS code query another script which returns the stored details.