DefaultAvPlayer implements AvPlayer { @Override public void load(@NonNull String path, @NonNull final Callback callback, @NonNull final ErrorCallback errorCallback) { init(); if (!state.isLoading(path) && !state.isLoaded(path)) { state.setLoading(path); player.load(path, new Callback() { @Override public void onSuccess() { state.setLoaded(); if (state.isPlaying()) { player.play(new StopCallbackWrapper(callback), new StopErrorCallbackWrapper(errorCallback)); } else { callback.onSuccess(); } } }, new ErrorCallback() { @Override public void onError() { state.setInit(); errorCallback.onError(); } }); } } DefaultAvPlayer(@NonNull AvPlayerImplementation player); @Override void deinit(); @Override void init(); @Override void load(@NonNull String path,
                     @NonNull final Callback callback,
                     @NonNull final ErrorCallback errorCallback); @Override void stop(); @Override void play(@NonNull Callback callback, @NonNull ErrorCallback errorCallback); @Override void play(@NonNull String path,
                     @NonNull Callback callback,
                     @NonNull ErrorCallback errorCallback); @Override void pause();  }
@Test public void testLoadLoad() { load(PATH_A); verifyLoad(1, PATH_A); verifyCallback(1); verifyErrorCallback(0); }
@Test public void testLoadReloadSync() { load(PATH_A); load(PATH_B); verifyLoad(1, PATH_B); verifyCallback(2); verifyErrorCallback(0); }
@Test public void testLoadReloadAsync() { implementation.setAsyncLoadFailure(true); load(PATH_A); implementation.setAsyncLoadFailure(false); load(PATH_B); verifyLoad(1, PATH_B); verifyCallback(1); verifyErrorCallback(0); }
@Test public void testLoadFail() { implementation.setSyncLoadFailure(true); load(PATH_A); verifyLoad(1, PATH_A); verifyCallback(0); verifyErrorCallback(1); }