Post source info refreshes.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130289294
This commit is contained in:
andrewlewis 2016-08-15 09:36:42 -07:00 committed by Oliver Woodman
parent 1a909fd163
commit 80227840f6
2 changed files with 24 additions and 25 deletions

View file

@ -79,10 +79,11 @@ import java.io.IOException;
private static final int MSG_SEEK_TO = 3;
private static final int MSG_STOP = 4;
private static final int MSG_RELEASE = 5;
private static final int MSG_PERIOD_PREPARED = 6;
private static final int MSG_SOURCE_CONTINUE_LOADING_REQUESTED = 7;
private static final int MSG_TRACK_SELECTION_INVALIDATED = 8;
private static final int MSG_CUSTOM = 9;
private static final int MSG_REFRESH_SOURCE_INFO = 6;
private static final int MSG_PERIOD_PREPARED = 7;
private static final int MSG_SOURCE_CONTINUE_LOADING_REQUESTED = 8;
private static final int MSG_TRACK_SELECTION_INVALIDATED = 9;
private static final int MSG_CUSTOM = 10;
private static final int PREPARING_SOURCE_INTERVAL_MS = 10;
private static final int RENDERING_INTERVAL_MS = 10;
@ -218,11 +219,11 @@ import java.io.IOException;
internalPlaybackThread.quit();
}
// TrackSelector.InvalidationListener implementation.
// MediaSource.Listener implementation.
@Override
public void onTrackSelectionsInvalidated() {
handler.sendEmptyMessage(MSG_TRACK_SELECTION_INVALIDATED);
public void onSourceInfoRefreshed(Timeline timeline, Object manifest) {
handler.obtainMessage(MSG_REFRESH_SOURCE_INFO, Pair.create(timeline, manifest)).sendToTarget();
}
// MediaPeriod.Callback implementation.
@ -237,6 +238,13 @@ import java.io.IOException;
handler.obtainMessage(MSG_SOURCE_CONTINUE_LOADING_REQUESTED, source).sendToTarget();
}
// TrackSelector.InvalidationListener implementation.
@Override
public void onTrackSelectionsInvalidated() {
handler.sendEmptyMessage(MSG_TRACK_SELECTION_INVALIDATED);
}
// Handler.Callback implementation.
@Override
@ -271,6 +279,10 @@ import java.io.IOException;
handlePeriodPrepared((MediaPeriod) msg.obj);
return true;
}
case MSG_REFRESH_SOURCE_INFO: {
handleSourceInfoRefreshed((Pair<Timeline, Object>) msg.obj);
return true;
}
case MSG_SOURCE_CONTINUE_LOADING_REQUESTED: {
handleContinueLoadingRequested((MediaPeriod) msg.obj);
return true;
@ -305,21 +317,6 @@ import java.io.IOException;
}
}
// MediaSource.Listener implementation.
@Override
public void onSourceInfoRefreshed(Timeline timeline, Object manifest) {
try {
eventHandler.obtainMessage(MSG_SOURCE_INFO_REFRESHED, Pair.create(timeline, manifest))
.sendToTarget();
handleTimelineRefreshed(timeline);
} catch (ExoPlaybackException | IOException e) {
Log.e(TAG, "Error handling timeline change.", e);
eventHandler.obtainMessage(MSG_ERROR, e).sendToTarget();
stopInternal();
}
}
// Private methods.
private void setState(int state) {
@ -803,9 +800,11 @@ import java.io.IOException;
}
}
public void handleTimelineRefreshed(Timeline timeline) throws ExoPlaybackException, IOException {
public void handleSourceInfoRefreshed(Pair<Timeline, Object> timelineAndManifest)
throws ExoPlaybackException, IOException {
eventHandler.obtainMessage(MSG_SOURCE_INFO_REFRESHED, timelineAndManifest).sendToTarget();
Timeline oldTimeline = this.timeline;
this.timeline = timeline;
this.timeline = timelineAndManifest.first;
// Update the loaded periods to take into account the new timeline.
if (playingPeriod != null) {

View file

@ -380,9 +380,9 @@ import java.util.Arrays;
}
tracks = new TrackGroupArray(trackArray);
prepared = true;
callback.onPrepared(this);
sourceListener.onSourceInfoRefreshed(
new SinglePeriodTimeline(0, durationUs, seekMap.isSeekable()), null);
callback.onPrepared(this);
}
private void copyLengthFromLoader(ExtractingLoadable loadable) {