mirror of
https://github.com/samsonjs/media.git
synced 2026-04-15 12:55:46 +00:00
Fix preparation of media sources with empty timeline
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=182533415
This commit is contained in:
parent
cf27bc84e6
commit
fe1e4fa1f2
2 changed files with 46 additions and 22 deletions
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue