summaryrefslogtreecommitdiff
path: root/model/src/main/java
diff options
context:
space:
mode:
authorByteHamster <info@bytehamster.com>2023-11-05 08:27:34 +0100
committerByteHamster <info@bytehamster.com>2023-11-05 08:27:34 +0100
commitf7a13065a9c92ba26d3686aeb18269f2313bd0b6 (patch)
treef7f7a49aa65acc295cc99dc0e3e870a1f5f4130f /model/src/main/java
parent2c3fb5610a98d80db25b85fdf0607bfc2b6216fc (diff)
parent8d4270ab87d82dadccab177f6710637b28750c7a (diff)
downloadAntennaPod-f7a13065a9c92ba26d3686aeb18269f2313bd0b6.zip
Merge branch 'master' into develop
Diffstat (limited to 'model/src/main/java')
-rw-r--r--model/src/main/java/de/danoeh/antennapod/model/MediaMetadataRetrieverCompat.java18
-rw-r--r--model/src/main/java/de/danoeh/antennapod/model/feed/FeedMedia.java7
2 files changed, 21 insertions, 4 deletions
diff --git a/model/src/main/java/de/danoeh/antennapod/model/MediaMetadataRetrieverCompat.java b/model/src/main/java/de/danoeh/antennapod/model/MediaMetadataRetrieverCompat.java
new file mode 100644
index 000000000..f3173946d
--- /dev/null
+++ b/model/src/main/java/de/danoeh/antennapod/model/MediaMetadataRetrieverCompat.java
@@ -0,0 +1,18 @@
+package de.danoeh.antennapod.model;
+
+import android.media.MediaMetadataRetriever;
+
+import java.io.IOException;
+
+/**
+ * On SDK<29, this class does not have a close method yet, so the app crashes when using try-with-resources.
+ */
+public class MediaMetadataRetrieverCompat extends MediaMetadataRetriever {
+ public void close() {
+ try {
+ release();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedMedia.java b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedMedia.java
index 9e8583075..991b5f3db 100644
--- a/model/src/main/java/de/danoeh/antennapod/model/feed/FeedMedia.java
+++ b/model/src/main/java/de/danoeh/antennapod/model/feed/FeedMedia.java
@@ -2,13 +2,13 @@ package de.danoeh.antennapod.model.feed;
import android.content.Context;
import android.content.SharedPreferences.Editor;
-import android.media.MediaMetadataRetriever;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.Nullable;
import android.support.v4.media.MediaBrowserCompat;
import android.support.v4.media.MediaDescriptionCompat;
+import de.danoeh.antennapod.model.MediaMetadataRetrieverCompat;
import de.danoeh.antennapod.model.playback.MediaType;
import de.danoeh.antennapod.model.playback.Playable;
import de.danoeh.antennapod.model.playback.RemoteMedia;
@@ -458,11 +458,10 @@ public class FeedMedia extends FeedFile implements Playable {
hasEmbeddedPicture = Boolean.FALSE;
return;
}
- MediaMetadataRetriever mmr = new MediaMetadataRetriever();
- try {
+ try (MediaMetadataRetrieverCompat mmr = new MediaMetadataRetrieverCompat()) {
mmr.setDataSource(getLocalMediaUrl());
byte[] image = mmr.getEmbeddedPicture();
- if(image != null) {
+ if (image != null) {
hasEmbeddedPicture = Boolean.TRUE;
} else {
hasEmbeddedPicture = Boolean.FALSE;