I encounter difficulties in recovering informations (ID3 tag) from an MP3 stream. I want this informations for display the albumArt and the title of the current song on the homepage of the radiomed's website.
我在从MP3流中恢复信息(ID3标签)时遇到了困难。我希望这些信息能够在radiomed网站的主页上显示albumArt和当前歌曲的标题。
Update
With PHP , I worked with ID3 library for PHP, but this library was not up to date since 2004 and with Javascript , I worked with TagLib, MusicMetadata and id3js . The results were errors messages (js) and string (0) with a var_dump($getID3)
// this return the object obtain with the catched info from the stream .
使用PHP,我使用ID3库来处理PHP,但是这个库自2004年以来不是最新的,使用Javascript,我使用了TagLib,MusicMetadata和id3js。结果是错误消息(js)和带有var_dump($ getID3)的字符串(0)//这将返回使用来自流的catched信息获取的对象。
The result should be, title and artist of the current on air song.
结果应该是当前空中歌曲的标题和艺术家。
I tried with php & js but I failed.
我试过php和js但是我失败了。
2 个解决方案
#1
This example can help you https://gist.github.com/fracasula/5781710
这个例子可以帮助你https://gist.github.com/fracasula/5781710
But it won t read the stream conitnuously, it will just fetch first buffer and try it. It may or may not returns the current track name, it depends.
但它不会连续读取流,它只会获取第一个缓冲区并尝试它。它可能会也可能不会返回当前曲目名称,具体取决于。
It needs to be improved, i guess, to read stream in continue and detect each buffer for track data. Thus you could show it wherever needed.
我想,需要改进继续读取流并检测每个缓冲区的轨道数据。因此,您可以在需要的地方展示它。
#2
You could try to use PECL extension if you want to fetch id3 directly from mp3
如果要直接从mp3获取id3,可以尝试使用PECL扩展
pecl install id3-0.2
And than use a id3_get_tag function:
而不是使用id3_get_tag函数:
<?php
$tag = id3_get_tag( "path/to/example.mp3" );
print_r($tag);
?>
But instead doing this, i would search documentation of your streaming software, probably there is some api to fetch stream data (json, xml, plain text)
但是这样做,我会搜索你的流媒体软件的文档,可能有一些api来获取流数据(json,xml,纯文本)
#1
This example can help you https://gist.github.com/fracasula/5781710
这个例子可以帮助你https://gist.github.com/fracasula/5781710
But it won t read the stream conitnuously, it will just fetch first buffer and try it. It may or may not returns the current track name, it depends.
但它不会连续读取流,它只会获取第一个缓冲区并尝试它。它可能会也可能不会返回当前曲目名称,具体取决于。
It needs to be improved, i guess, to read stream in continue and detect each buffer for track data. Thus you could show it wherever needed.
我想,需要改进继续读取流并检测每个缓冲区的轨道数据。因此,您可以在需要的地方展示它。
#2
You could try to use PECL extension if you want to fetch id3 directly from mp3
如果要直接从mp3获取id3,可以尝试使用PECL扩展
pecl install id3-0.2
And than use a id3_get_tag function:
而不是使用id3_get_tag函数:
<?php
$tag = id3_get_tag( "path/to/example.mp3" );
print_r($tag);
?>
But instead doing this, i would search documentation of your streaming software, probably there is some api to fetch stream data (json, xml, plain text)
但是这样做,我会搜索你的流媒体软件的文档,可能有一些api来获取流数据(json,xml,纯文本)