-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added an event that triggers when metadata is received from the track source #552
Conversation
@xgustavoh can you take a look? |
@Guichaguri , I can, I'll create a test project to be analyzing and identify if everything is working perfectly! Edit: Tomorrow I'll test more deeply, but so far it's working perfectly! |
Good night @Guichaguri, It worked perfectly within my environment, but I detected a small problem, In Edit¹: Icy headers not working. When reading the code I noticed that the headers never sends My tests:
Note: When the bitrate is smaller, it may be that when the music changes it will take a while to receive the event, but this is not an error, that is correct! Because the metadata is sent in range of X bytes. Tested configuration [
{
"id": "1111",
"url": "https://live.hunter.fm/rock320",
"title": "The Rock Channel (320Kbps - MP3)",
"artist": "Hunter.FM",
"artwork": "https://cdn.hunter.fm/image/thumb/station/default.jpg"
},
{
"id": "2222",
"url": "https://live.hunter.fm/country",
"title": "O Canal Sertanejo (192Kbps - MP3)",
"artist": "Hunter.FM",
"artwork": "https://cdn.hunter.fm/image/thumb/station/sertanejo-first/200x200ht.jpg"
},
{
"id": "3333",
"url": "https://live.hunter.fm/mpop2k",
"title": "The Pop2k Hitz Channel (64Kbps - AAC)",
"artist": "Hunter.FM",
"artwork": "https://cdn.hunter.fm/image/thumb/station/pop2k-first/200x200ht.jpg"
},
{
"id": "4444",
"url": "https://live.hunter.fm/80s32",
"title": "The 80s Channel (32Kbps - AAC)",
"artist": "Hunter.FM",
"artwork": "https://cdn.hunter.fm/image/thumb/station/80s-first/200x200ht.jpg"
}
] |
@maendamedia This implementation is only for Android (initially). Note¹: the correct event name is |
Ok, yes it was iOS indeed :) |
|
@xgustavoh As for OGG, that issue can either be caused by a bug in ExoPlayer or by the track not being properly encoded. Can you send an OGG stream URL where it doesn't work? Let me know whether 82b8cec fixes the icy headers for you. |
@Guichaguri, I took the test here, the About OGG really is a bug in ExoPlayer, because I use AIMP on my computer to test the metadata and it gets perfectly, while on the mobile does not receive. URL Stream: http://ice2.hunterfm.com:2001/ogg ------------ AIMP Vs ExoPlayer |
There is something different with the OGG stream. Basically, the player sends the For the OGG URL you've sent, these are the headers returned: { server: 'HunterCast 2.2',
date: 'Wed, 01 May 2019 20:34:58 GMT',
'content-type': 'application/ogg',
'cache-control': 'no-cache',
expires: 'Mon, 26 Jul 1997 05:00:00 GMT',
pragma: 'no-cache',
'ice-audio-info': 'ice-samplerate=44100;ice-quality=4,99;ice-channels=2',
'icy-br': 'Quality 4,99',
'icy-description': 'My station description',
'icy-genre': 'Various',
'icy-name': 'My Station name',
'icy-pub': '1',
'icy-url': 'http://www.audiorealm.com' } Here are the headers for the MP3 stream: { server: 'Icecast 2.4.2',
date: 'Wed, 01 May 2019 20:42:04 GMT',
'content-type': 'audio/mpeg',
'cache-control': 'no-cache',
expires: 'Mon, 26 Jul 1997 05:00:00 GMT',
pragma: 'no-cache',
'icy-br': '320, 320',
'ice-audio-info': 'ice-samplerate=44100;ice-bitrate=320;ice-channels=2',
'icy-genre': 'Rock',
'icy-name': 'HUNTER.FM -=[: O Canal Rock :]=-',
'icy-pub': '1',
'icy-url': 'http://hunter.fm',
'icy-metaint': '16000',
'strict-transport-security': 'max-age=31536000; includeSubDomains; preload' } |
After researching a little bit, I think OGG streams use VorbisComment instead. After analyzing the stream using the music-metadata module, I've confirmed it is indeed Vorbis metadata instead of Icy: "vorbis": [
{
"id": "ENCODER",
"value": "SAM technology"
},
{
"id": "ARTIST",
"value": "Lauv & Troye Sivan"
},
{
"id": "TITLE",
"value": "i'm so tired"
}
] Here's an ExoPlayer feature request for reading VorbisComment: google/ExoPlayer#5527 Edit: Documentation about the VorbisComment format can be found here. |
I really had not noticed that the header was different, now that you've commented, I've noticed that even the AIMP does not get
So following the logic, both |
I've merged it. We'll add support for new metadata types whenever ExoPlayer adds them. For now, this is enough for most tracks. |
Only one question pertaining to Although, considering that usually only comes 1 metadata per made, the for is not used more than once ..... There is doubt 🤔 |
I've separated them mostly for readability reasons, but the change also makes them not conflict with each other. Let's say you have a mp3 stream that has both ID3 tags and ICY metadata, the older code would only trigger the event once, being a mix of the ID3 tags and the ICY metadata. Now, it triggers the event twice: one for the ID3 tags and another one for the ICY metadata. Considering there is usually no ID3 tags in icy streams, it shouldn't be a problem at all, but it might become one as we implement new metadata formats. As for the computational usage, the difference is too small even for a benchmark to notice. |
Just as an update from this PR, ExoPlayer recently added support for both Vorbis Comments and QuickTime metadata, I've added support for both of them in v2: 4139370 |
This PR adds the
playback-metadata-received
event, which is fired whenever ID3 Tags, Icy Metadata or Icy Headers are received with the following parameters:string
id3
,icy
oricy-headers
)string
string
string
string
string
string
This PR closes #192, and supersedes #384
Implementation Details
ID3 Tags
The parameters are filled from the following ID3 tags:
TIT2
TALB
orTOAL
TOPE
TDRC
WOAS
,WORS
orWOAF
Icy Metadata
The parameters are filled from the following properties:
StreamTitle
¹StreamTitle
¹StreamUrl
¹ - The module parses the
StreamTitle
string splitting the first " - ". The first part is set as theartist
and the second part is set astitle
. When there is no occurrences, the whole string is set astitle
.Icy Headers
The parameters are filled from the following headers:
icy-name
icy-genre
icy-url