// We have to construct the MediaPlayer on the main thread (or at least on a thread with an
// associated looper) otherwise we don't get sent the messages when callbacks should be
// invoked. I've raised a bug for this: http://b/4602011.
Callable<MediaPlayer> callable = new Callable<MediaPlayer>() {
@Override
public MediaPlayer call() throws Exception {
return new MediaPlayer();
}
};
FutureTask<MediaPlayer> future = new FutureTask<MediaPlayer>(callable);
getInstrumentation().runOnMainSync(future);
return DynamicProxy.dynamicProxy(MediaPlayerProxy.class, future.get(1, TimeUnit.SECONDS));