diff options
author | ByteHamster <info@bytehamster.com> | 2020-05-16 19:12:01 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2020-05-16 22:30:30 +0200 |
commit | ed0233f767448426d92be9948211970e860a4980 (patch) | |
tree | c66842e762118b91dad95487d173275e9269d8cf | |
parent | df1c298bf6a9fca18c3afda76293f7fce50bf351 (diff) | |
download | AntennaPod-ed0233f767448426d92be9948211970e860a4980.zip |
Set duration of playable when streaming
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java index 2570fb1c5..69253bc13 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java @@ -48,6 +48,7 @@ import java.util.concurrent.TimeUnit; import de.danoeh.antennapod.core.ClientConfig; import de.danoeh.antennapod.core.R; +import de.danoeh.antennapod.core.event.FeedItemEvent; import de.danoeh.antennapod.core.event.MessageEvent; import de.danoeh.antennapod.core.event.PlaybackPositionEvent; import de.danoeh.antennapod.core.event.ServiceEvent; @@ -847,6 +848,17 @@ public class PlaybackService extends MediaBrowserServiceCompat { return true; case MediaPlayer.MEDIA_INFO_BUFFERING_END: sendNotificationBroadcast(NOTIFICATION_TYPE_BUFFER_END, 0); + + Playable playable = getPlayable(); + if (getPlayable() instanceof FeedMedia + && playable.getDuration() <= 0 && mediaPlayer.getDuration() > 0) { + // Playable is being streamed and does not have a duration specified in the feed + playable.setDuration(mediaPlayer.getDuration()); + DBWriter.setFeedMedia((FeedMedia) playable); + updateMediaSessionMetadata(playable); + setupNotification(playable); + } + return true; default: return flavorHelper.onMediaPlayerInfo(PlaybackService.this, code, resourceId); |