use of com.google.android.exoplayer2.offline.DownloadHelper.Callback in project ExoPlayer by google.
the class FakeClockTest method createHandler_sendMessageAtFrontOfQueue_sendsMessageFirst.
@Test
public void createHandler_sendMessageAtFrontOfQueue_sendsMessageFirst() {
HandlerThread handlerThread = new HandlerThread("FakeClockTest");
handlerThread.start();
FakeClock fakeClock = new FakeClock(/* initialTimeMs= */
0);
TestCallback callback = new TestCallback();
HandlerWrapper handler = fakeClock.createHandler(handlerThread.getLooper(), callback);
handler.obtainMessage(/* what= */
1).sendToTarget();
handler.sendMessageAtFrontOfQueue(handler.obtainMessage(/* what= */
2));
handler.sendMessageAtFrontOfQueue(handler.obtainMessage(/* what= */
3));
handler.obtainMessage(/* what= */
4).sendToTarget();
ShadowLooper.idleMainLooper();
shadowOf(handler.getLooper()).idle();
assertThat(callback.messages).containsExactly(new MessageData(/* what= */
3, /* arg1= */
0, /* arg2= */
0, /* obj=*/
null), new MessageData(/* what= */
2, /* arg1= */
0, /* arg2= */
0, /* obj=*/
null), new MessageData(/* what= */
1, /* arg1= */
0, /* arg2= */
0, /* obj=*/
null), new MessageData(/* what= */
4, /* arg1= */
0, /* arg2= */
0, /* obj=*/
null)).inOrder();
}
use of com.google.android.exoplayer2.offline.DownloadHelper.Callback in project ExoPlayer by google.
the class SingleSampleMediaPeriod method continueLoading.
@Override
public boolean continueLoading(long positionUs) {
if (loadingFinished || loader.isLoading() || loader.hasFatalError()) {
return false;
}
DataSource dataSource = dataSourceFactory.createDataSource();
if (transferListener != null) {
dataSource.addTransferListener(transferListener);
}
SourceLoadable loadable = new SourceLoadable(dataSpec, dataSource);
long elapsedRealtimeMs = loader.startLoading(loadable, /* callback= */
this, loadErrorHandlingPolicy.getMinimumLoadableRetryCount(C.DATA_TYPE_MEDIA));
eventDispatcher.loadStarted(new LoadEventInfo(loadable.loadTaskId, dataSpec, elapsedRealtimeMs), C.DATA_TYPE_MEDIA, C.TRACK_TYPE_UNKNOWN, format, C.SELECTION_REASON_UNKNOWN, /* trackSelectionData= */
null, /* mediaStartTimeUs= */
0, durationUs);
return true;
}
Aggregations