mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Post source info refreshes.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=130289294
This commit is contained in:
parent
1a909fd163
commit
80227840f6
2 changed files with 24 additions and 25 deletions
|
|
@ -79,10 +79,11 @@ import java.io.IOException;
|
||||||
private static final int MSG_SEEK_TO = 3;
|
private static final int MSG_SEEK_TO = 3;
|
||||||
private static final int MSG_STOP = 4;
|
private static final int MSG_STOP = 4;
|
||||||
private static final int MSG_RELEASE = 5;
|
private static final int MSG_RELEASE = 5;
|
||||||
private static final int MSG_PERIOD_PREPARED = 6;
|
private static final int MSG_REFRESH_SOURCE_INFO = 6;
|
||||||
private static final int MSG_SOURCE_CONTINUE_LOADING_REQUESTED = 7;
|
private static final int MSG_PERIOD_PREPARED = 7;
|
||||||
private static final int MSG_TRACK_SELECTION_INVALIDATED = 8;
|
private static final int MSG_SOURCE_CONTINUE_LOADING_REQUESTED = 8;
|
||||||
private static final int MSG_CUSTOM = 9;
|
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 PREPARING_SOURCE_INTERVAL_MS = 10;
|
||||||
private static final int RENDERING_INTERVAL_MS = 10;
|
private static final int RENDERING_INTERVAL_MS = 10;
|
||||||
|
|
@ -218,11 +219,11 @@ import java.io.IOException;
|
||||||
internalPlaybackThread.quit();
|
internalPlaybackThread.quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TrackSelector.InvalidationListener implementation.
|
// MediaSource.Listener implementation.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrackSelectionsInvalidated() {
|
public void onSourceInfoRefreshed(Timeline timeline, Object manifest) {
|
||||||
handler.sendEmptyMessage(MSG_TRACK_SELECTION_INVALIDATED);
|
handler.obtainMessage(MSG_REFRESH_SOURCE_INFO, Pair.create(timeline, manifest)).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
// MediaPeriod.Callback implementation.
|
// MediaPeriod.Callback implementation.
|
||||||
|
|
@ -237,6 +238,13 @@ import java.io.IOException;
|
||||||
handler.obtainMessage(MSG_SOURCE_CONTINUE_LOADING_REQUESTED, source).sendToTarget();
|
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.
|
// Handler.Callback implementation.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -271,6 +279,10 @@ import java.io.IOException;
|
||||||
handlePeriodPrepared((MediaPeriod) msg.obj);
|
handlePeriodPrepared((MediaPeriod) msg.obj);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
case MSG_REFRESH_SOURCE_INFO: {
|
||||||
|
handleSourceInfoRefreshed((Pair<Timeline, Object>) msg.obj);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
case MSG_SOURCE_CONTINUE_LOADING_REQUESTED: {
|
case MSG_SOURCE_CONTINUE_LOADING_REQUESTED: {
|
||||||
handleContinueLoadingRequested((MediaPeriod) msg.obj);
|
handleContinueLoadingRequested((MediaPeriod) msg.obj);
|
||||||
return true;
|
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 methods.
|
||||||
|
|
||||||
private void setState(int state) {
|
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;
|
Timeline oldTimeline = this.timeline;
|
||||||
this.timeline = timeline;
|
this.timeline = timelineAndManifest.first;
|
||||||
|
|
||||||
// Update the loaded periods to take into account the new timeline.
|
// Update the loaded periods to take into account the new timeline.
|
||||||
if (playingPeriod != null) {
|
if (playingPeriod != null) {
|
||||||
|
|
|
||||||
|
|
@ -380,9 +380,9 @@ import java.util.Arrays;
|
||||||
}
|
}
|
||||||
tracks = new TrackGroupArray(trackArray);
|
tracks = new TrackGroupArray(trackArray);
|
||||||
prepared = true;
|
prepared = true;
|
||||||
callback.onPrepared(this);
|
|
||||||
sourceListener.onSourceInfoRefreshed(
|
sourceListener.onSourceInfoRefreshed(
|
||||||
new SinglePeriodTimeline(0, durationUs, seekMap.isSeekable()), null);
|
new SinglePeriodTimeline(0, durationUs, seekMap.isSeekable()), null);
|
||||||
|
callback.onPrepared(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyLengthFromLoader(ExtractingLoadable loadable) {
|
private void copyLengthFromLoader(ExtractingLoadable loadable) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue