提交 fe1e4fa1 编写于 作者: A aquilescanta 提交者: Oliver Woodman

Fix preparation of media sources with empty timeline

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=182533415
上级 cf27bc84
......@@ -1399,7 +1399,7 @@ public final class ExoPlayerTest extends TestCase {
assertEquals(2, target3.windowIndex);
}
public void testSetAndSwitchSurfaceTest() throws Exception {
public void testSetAndSwitchSurface() throws Exception {
final List<Integer> rendererMessages = new ArrayList<>();
Renderer videoRenderer =
new FakeRenderer(Builder.VIDEO_FORMAT) {
......@@ -1409,25 +1409,8 @@ public final class ExoPlayerTest extends TestCase {
rendererMessages.add(what);
}
};
final Surface surface1 = DummySurface.newInstanceV17(/* context= */ null, /* secure= */ false);
final Surface surface2 = DummySurface.newInstanceV17(/* context= */ null, /* secure= */ false);
ActionSchedule actionSchedule =
new ActionSchedule.Builder("setAndSwitchSurfaceTest")
.executeRunnable(
new PlayerRunnable() {
@Override
public void run(SimpleExoPlayer player) {
player.setVideoSurface(surface1);
}
})
.executeRunnable(
new PlayerRunnable() {
@Override
public void run(SimpleExoPlayer player) {
player.setVideoSurface(surface2);
}
})
.build();
addSurfaceSwitch(new ActionSchedule.Builder("testSetAndSwitchSurface")).build();
new ExoPlayerTestRunner.Builder()
.setRenderers(videoRenderer)
.setActionSchedule(actionSchedule)
......@@ -1438,6 +1421,44 @@ public final class ExoPlayerTest extends TestCase {
assertEquals(2, Collections.frequency(rendererMessages, C.MSG_SET_SURFACE));
}
public void testSwitchSurfaceOnEndedState() throws Exception {
ActionSchedule.Builder scheduleBuilder =
new ActionSchedule.Builder("testSwitchSurfaceOnEndedState")
.waitForPlaybackState(Player.STATE_ENDED);
ActionSchedule waitForEndedAndSwitchSchedule = addSurfaceSwitch(scheduleBuilder).build();
new ExoPlayerTestRunner.Builder()
.setTimeline(Timeline.EMPTY)
.setActionSchedule(waitForEndedAndSwitchSchedule)
.build()
.start()
.blockUntilActionScheduleFinished(TIMEOUT_MS)
.blockUntilEnded(TIMEOUT_MS);
}
// Internal methods.
private static ActionSchedule.Builder addSurfaceSwitch(ActionSchedule.Builder builder) {
final Surface surface1 = DummySurface.newInstanceV17(/* context= */ null, /* secure= */ false);
final Surface surface2 = DummySurface.newInstanceV17(/* context= */ null, /* secure= */ false);
return builder
.executeRunnable(
new PlayerRunnable() {
@Override
public void run(SimpleExoPlayer player) {
player.setVideoSurface(surface1);
}
})
.executeRunnable(
new PlayerRunnable() {
@Override
public void run(SimpleExoPlayer player) {
player.setVideoSurface(surface2);
}
});
}
// Internal classes.
private static final class PositionGrabbingMessageTarget extends PlayerTarget {
public int windowIndex;
......
......@@ -881,8 +881,11 @@ import java.util.Collections;
private void sendCustomMessageToTarget(PlayerMessage message) {
if (message.getHandler().getLooper() == handler.getLooper()) {
deliverCustomMessage(message);
// The message may have caused something to change that now requires us to do work.
handler.sendEmptyMessage(MSG_DO_SOME_WORK);
if (playbackInfo.playbackState == Player.STATE_READY
|| playbackInfo.playbackState == Player.STATE_BUFFERING) {
// The message may have caused something to change that now requires us to do work.
handler.sendEmptyMessage(MSG_DO_SOME_WORK);
}
} else {
handler.obtainMessage(MSG_SEND_MESSAGE_TO_TARGET, message).sendToTarget();
}
......@@ -1413,7 +1416,7 @@ import java.util.Collections;
MediaPeriodHolder loadingPeriodHolder = queue.getLoadingPeriod();
if (loadingPeriodHolder == null || loadingPeriodHolder.isFullyBuffered()) {
setIsLoading(false);
} else if (loadingPeriodHolder != null && !playbackInfo.isLoading) {
} else if (!playbackInfo.isLoading) {
maybeContinueLoading();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册