FileDocCategorySizeDatePackage
AwaitableCompletionListener.javaAPI DocAndroid 5.1 API2191Thu Mar 12 22:22:48 GMT 2015com.android.ex.variablespeed

AwaitableCompletionListener

public class AwaitableCompletionListener extends Object implements MediaPlayer.OnCompletionListener
Implementation of {@link MediaPlayer.OnErrorListener} that we can wait for in tests.

Fields Summary
private final BlockingQueue
mQueue
Constructors Summary
Methods Summary
public voidassertNoMoreCallbacks()

        if (mQueue.peek() != null) {
            throw new IllegalStateException("there was an unexpected callback on the queue");
        }
    
public voidawaitOneCallback(long timeout, java.util.concurrent.TimeUnit unit)

        if (mQueue.poll(timeout, unit) == null) {
            throw new TimeoutException();
        }
    
public voidonCompletion(android.media.MediaPlayer mp)


    
        
        try {
            mQueue.put(new Object());
        } catch (InterruptedException e) {
            // This should not happen in practice, the queue is unbounded so this method will not
            // block.
            // If this thread is using interrupt to shut down, preserve interrupt status and return.
            Thread.currentThread().interrupt();
        }