update MetaDataExtractor
This commit is contained in:
parent
29bc3e9c7b
commit
3c3c645c68
1 changed files with 17 additions and 4 deletions
|
@ -1183,17 +1183,30 @@ public class FileBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getAudioTitleArtist(File file) {
|
private String getAudioTitleArtist(File file) {
|
||||||
|
String artist;
|
||||||
|
String title;
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
|
MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();
|
||||||
mediaMetadataRetriever.setDataSource(file.toString());
|
mediaMetadataRetriever.setDataSource(file.toString());
|
||||||
StringBuilder builder = new StringBuilder();
|
artist = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST);
|
||||||
String artist = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST);
|
if (artist == null) {
|
||||||
String title = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE);
|
artist = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUMARTIST);
|
||||||
|
}
|
||||||
|
if (artist == null) {
|
||||||
|
artist = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_COMPOSER);
|
||||||
|
}
|
||||||
|
title = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE);
|
||||||
|
mediaMetadataRetriever.release();
|
||||||
|
boolean separator = false;
|
||||||
if (artist != null && artist.length() > 0) {
|
if (artist != null && artist.length() > 0) {
|
||||||
builder.append(artist);
|
builder.append(artist);
|
||||||
|
separator = true;
|
||||||
}
|
}
|
||||||
if (title != null && title.length() > 0) {
|
if (title != null && title.length() > 0) {
|
||||||
|
if (separator) {
|
||||||
builder.append(" - ");
|
builder.append(" - ");
|
||||||
|
}
|
||||||
builder.append(title);
|
builder.append(title);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
Reference in a new issue