diff options
author | Christian Schneppe <christian.schneppe@pix-art.de> | 2020-02-03 21:46:26 +0100 |
---|---|---|
committer | Christian Schneppe <christian.schneppe@pix-art.de> | 2020-02-03 21:46:26 +0100 |
commit | 3c3c645c68552c1c074650ce370a720e67c9ecf0 (patch) | |
tree | 1f43732d74dd9ee80cbfcf9e0515d9793f7e1bd3 /src | |
parent | 29bc3e9c7b172d61b3075da993e3ea48e3f0a1a3 (diff) |
update MetaDataExtractor
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/pixart/messenger/persistance/FileBackend.java | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java index 8293b9b98..08dc746c1 100644 --- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java @@ -1183,17 +1183,30 @@ public class FileBackend { } private String getAudioTitleArtist(File file) { + String artist; + String title; + StringBuilder builder = new StringBuilder(); try { MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever(); mediaMetadataRetriever.setDataSource(file.toString()); - StringBuilder builder = new StringBuilder(); - String artist = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST); - String title = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE); + artist = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST); + if (artist == null) { + 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) { builder.append(artist); + separator = true; } if (title != null && title.length() > 0) { - builder.append(" - "); + if (separator) { + builder.append(" - "); + } builder.append(title); } try { |