Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
507 views
in Technique[技术] by (71.8m points)

stream - Reading Remote MP3 File's ID3 Tags using Java

I am looking for a way to read the ID3 tags from an MP3 file on a remote server without actually downloading the file. I have seen libraries like JAudioTagger and Entagged, but both seem to require a file object and not a URL or InputStream, which I know how to get with a remote file. Is there another library that can do this? Or is there a way to get the correct object to interact with these classes using a URL?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

ID3 Tags are located in the last 128 ( 355 if using extended tag ) bytes of the file, so you are going to at least have to download part of the file. As HTTP supports range specific file access, it should be theoretically possible to do this (though I do not know of any libraries that would do it for you).

Essentially what would need to happen is to do a HEAD request to get the length of the file in bytes, then perform a GET on the file with the Range length-355 to the end of the file. This would return the necessary metadata. This gives a good idea of what a ranged request looks like.

Sorry though that I do not know of any libraries that would do this automatically, but it isn't a particularly difficult task to set up the getter. From there it is possible to write the metadata to a temp file and have it parsed by your ID3 parser.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...