From fb19d0cc5a1191c005eccc36e5c075da5c4384b6 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 28 Jan 2015 09:16:40 -0800 Subject: Fix for licecycle setting setup to true while mediaPlayer is preparing still --- .../daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index e93fb88d..3a9c697f 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -43,6 +43,8 @@ import github.daneren2005.dsub.util.Constants; import github.daneren2005.dsub.util.FileUtil; import github.daneren2005.dsub.util.Util; +import static github.daneren2005.dsub.domain.PlayerState.PREPARING; + /** * @author Sindre Mehus */ @@ -107,6 +109,12 @@ public class DownloadServiceLifecycleSupport { try { lock.lock(); deserializeDownloadQueueNow(); + + // Wait until PREPARING is done to mark lifecycle as ready to receive events + while(downloadService.getPlayerState() == PREPARING) { + Util.sleepQuietly(50L); + } + setup.set(true); } finally { lock.unlock(); -- cgit v1.2.3