diff options
author | ByteHamster <info@bytehamster.com> | 2021-03-05 17:44:33 +0100 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2021-03-05 17:44:33 +0100 |
commit | bc073ff38fc9f21998811504d0c0cd15ffb39c5e (patch) | |
tree | 7cfb40248cc20eb0a0bd55d0b704052448337128 /core/src/play | |
parent | dd0502c0d65ef51347a8dedabd6edf2b9318848c (diff) | |
download | AntennaPod-bc073ff38fc9f21998811504d0c0cd15ffb39c5e.zip |
Removed metadata loader from model
Diffstat (limited to 'core/src/play')
-rw-r--r-- | core/src/play/java/de/danoeh/antennapod/core/cast/CastUtils.java | 29 | ||||
-rw-r--r-- | core/src/play/java/de/danoeh/antennapod/core/service/playback/RemotePSMP.java | 19 |
2 files changed, 17 insertions, 31 deletions
diff --git a/core/src/play/java/de/danoeh/antennapod/core/cast/CastUtils.java b/core/src/play/java/de/danoeh/antennapod/core/cast/CastUtils.java index 3884041b6..86c85de6b 100644 --- a/core/src/play/java/de/danoeh/antennapod/core/cast/CastUtils.java +++ b/core/src/play/java/de/danoeh/antennapod/core/cast/CastUtils.java @@ -10,7 +10,6 @@ import com.google.android.gms.cast.MediaInfo; import com.google.android.gms.cast.MediaMetadata; import com.google.android.gms.common.images.WebImage; -import de.danoeh.antennapod.core.util.playback.PlayableException; import de.danoeh.antennapod.core.util.playback.RemoteMedia; import java.util.Calendar; import java.util.List; @@ -78,23 +77,18 @@ public class CastUtils { /** * Converts {@link FeedMedia} objects into a format suitable for sending to a Cast Device. * Before using this method, one should make sure {@link #isCastable(Playable)} returns - * {@code true}. - * - * Unless media.{@link FeedMedia#loadMetadata() loadMetadata()} has already been called, - * this method should not run on the main thread. + * {@code true}. This method should not run on the main thread. * * @param media The {@link FeedMedia} object to be converted. * @return {@link MediaInfo} object in a format proper for casting. */ public static MediaInfo convertFromFeedMedia(FeedMedia media){ - if(media == null) { + if (media == null) { return null; } MediaMetadata metadata = new MediaMetadata(MediaMetadata.MEDIA_TYPE_GENERIC); - try{ - media.loadMetadata(); - } catch (PlayableException e) { - Log.e(TAG, "Unable to load FeedMedia metadata", e); + if (media.getItem() == null) { + media.setItem(DBReader.getFeedItem(media.getItemId())); } FeedItem feedItem = media.getItem(); if (feedItem != null) { @@ -188,16 +182,11 @@ public class CastUtils { if (mediaId > 0) { FeedMedia fMedia = DBReader.getFeedMedia(mediaId); if (fMedia != null) { - try { - fMedia.loadMetadata(); - if (matches(media, fMedia)) { - result = fMedia; - Log.d(TAG, "FeedMedia object obtained matches the MediaInfo provided. id=" + mediaId); - } else { - Log.d(TAG, "FeedMedia object obtained does NOT match the MediaInfo provided. id=" + mediaId); - } - } catch (PlayableException e) { - Log.e(TAG, "Unable to load FeedMedia metadata to compare with MediaInfo", e); + if (matches(media, fMedia)) { + result = fMedia; + Log.d(TAG, "FeedMedia object obtained matches the MediaInfo provided. id=" + mediaId); + } else { + Log.d(TAG, "FeedMedia object obtained does NOT match the MediaInfo provided. id=" + mediaId); } } else { Log.d(TAG, "Unable to find in database a FeedMedia with id=" + mediaId); diff --git a/core/src/play/java/de/danoeh/antennapod/core/service/playback/RemotePSMP.java b/core/src/play/java/de/danoeh/antennapod/core/service/playback/RemotePSMP.java index e61896965..fe39ca0b1 100644 --- a/core/src/play/java/de/danoeh/antennapod/core/service/playback/RemotePSMP.java +++ b/core/src/play/java/de/danoeh/antennapod/core/service/playback/RemotePSMP.java @@ -28,7 +28,7 @@ import de.danoeh.antennapod.core.cast.CastConsumer; import de.danoeh.antennapod.core.cast.CastManager; import de.danoeh.antennapod.core.cast.CastUtils; import de.danoeh.antennapod.core.cast.DefaultCastConsumer; -import de.danoeh.antennapod.core.util.playback.PlayableException; +import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.util.playback.RemoteMedia; import de.danoeh.antennapod.core.feed.FeedMedia; import de.danoeh.antennapod.core.feed.MediaType; @@ -354,16 +354,13 @@ public class RemotePSMP extends PlaybackServiceMediaPlayer { this.mediaType = media.getMediaType(); this.startWhenPrepared.set(startWhenPrepared); setPlayerStatus(PlayerStatus.INITIALIZING, media); - try { - media.loadMetadata(); - callback.onMediaChanged(true); - setPlayerStatus(PlayerStatus.INITIALIZED, media); - if (prepareImmediately) { - prepare(); - } - } catch (PlayableException e) { - Log.e(TAG, "Error while loading media metadata", e); - setPlayerStatus(PlayerStatus.STOPPED, null); + if (media instanceof FeedMedia && ((FeedMedia) media).getItem() == null) { + ((FeedMedia) media).setItem(DBReader.getFeedItem(((FeedMedia) media).getItemId())); + } + callback.onMediaChanged(true); + setPlayerStatus(PlayerStatus.INITIALIZED, media); + if (prepareImmediately) { + prepare(); } } |