From 4501cdd14af6617090f72f09e042a9fb6dbb3727 Mon Sep 17 00:00:00 2001 From: Adam Baker Date: Wed, 20 Jun 2018 18:09:30 +0100 Subject: [PATCH] Add a delay after starting a new track when we won't move onto the next track. Fixes #1 --- .../mediarouter/MediaRouterPlayService.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java b/src/main/java/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java index ef45db5..70e4666 100644 --- a/src/main/java/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java +++ b/src/main/java/com/github/nutomic/controldlna/mediarouter/MediaRouterPlayService.java @@ -105,6 +105,8 @@ public class MediaRouterPlayService extends Service { private boolean mPollingStatus = false; + private int mStartingTrack = 0; + private boolean mBound; /** @@ -270,6 +272,7 @@ public class MediaRouterPlayService extends Service { return; mCurrentTrack = trackNumber; + mStartingTrack = 3; Item track = mPlaylist.get(trackNumber); DIDLParser parser = new DIDLParser(); DIDLContent didl = new DIDLContent(); @@ -483,10 +486,13 @@ public class MediaRouterPlayService extends Service { stopForeground(true); } - if (status.getPlaybackState() == MediaItemStatus.PLAYBACK_STATE_FINISHED || - status.getPlaybackState() == MediaItemStatus.PLAYBACK_STATE_CANCELED) { + if ((status.getPlaybackState() == MediaItemStatus.PLAYBACK_STATE_FINISHED || + status.getPlaybackState() == MediaItemStatus.PLAYBACK_STATE_CANCELED) && + (mStartingTrack == 0)) { playNext(); } + if (mStartingTrack > 0) + mStartingTrack--; } }); }