If already seeking, wait for current seek to complete

This commit is contained in:
Martin Fietz 2015-10-17 18:20:20 +02:00
parent 860741a7bb
commit e4bb88f1f2

View File

@ -500,12 +500,19 @@ public class PlaybackServiceMediaPlayer implements SharedPreferences.OnSharedPre
statusBeforeSeeking = playerStatus; statusBeforeSeeking = playerStatus;
setPlayerStatus(PlayerStatus.SEEKING, media); setPlayerStatus(PlayerStatus.SEEKING, media);
} }
if(seekLatch != null && seekLatch.getCount() > 0) {
try {
seekLatch.await(3, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Log.e(TAG, Log.getStackTraceString(e));
}
}
seekLatch = new CountDownLatch(1); seekLatch = new CountDownLatch(1);
mediaPlayer.seekTo(t); mediaPlayer.seekTo(t);
try { try {
seekLatch.await(10, TimeUnit.SECONDS); seekLatch.await(3, TimeUnit.SECONDS);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); Log.e(TAG, Log.getStackTraceString(e));
} }
} else if (playerStatus == PlayerStatus.INITIALIZED) { } else if (playerStatus == PlayerStatus.INITIALIZED) {
media.setPosition(t); media.setPosition(t);