Work around Android 5 returning 'null' duration for opus files (#7440)

This commit is contained in:
ByteHamster 2024-10-03 21:14:44 +02:00 committed by GitHub
parent 993a1eb171
commit 4990d95f33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 1 deletions

View File

@ -194,6 +194,7 @@ public class LocalFeedUpdater {
try { try {
loadMetadata(item, file, context); loadMetadata(item, file, context);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
item.setDescriptionIfLonger(e.getMessage()); item.setDescriptionIfLonger(e.getMessage());
} }
return item; return item;
@ -222,7 +223,9 @@ public class LocalFeedUpdater {
} }
String durationStr = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION); String durationStr = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
item.getMedia().setDuration((int) Long.parseLong(durationStr)); if (durationStr != null && !durationStr.equals("null")) {
item.getMedia().setDuration((int) Long.parseLong(durationStr));
}
item.getMedia().setHasEmbeddedPicture(mediaMetadataRetriever.getEmbeddedPicture() != null); item.getMedia().setHasEmbeddedPicture(mediaMetadataRetriever.getEmbeddedPicture() != null);