diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-01-28 09:16:40 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-01-28 09:16:40 -0800 |
commit | fb19d0cc5a1191c005eccc36e5c075da5c4384b6 (patch) | |
tree | 04335bc036de90320d57c561bcf5f27683200530 | |
parent | 797d0fd2816a73a36c8e5851191a3b8530a866ac (diff) | |
download | dsub-fb19d0cc5a1191c005eccc36e5c075da5c4384b6.tar.gz dsub-fb19d0cc5a1191c005eccc36e5c075da5c4384b6.tar.bz2 dsub-fb19d0cc5a1191c005eccc36e5c075da5c4384b6.zip |
Fix for licecycle setting setup to true while mediaPlayer is preparing still
-rw-r--r-- | src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java | 8 |
1 files changed, 8 insertions, 0 deletions
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(); |