mirror of
https://github.com/samsonjs/media.git
synced 2026-04-01 10:35:48 +00:00
Amend seek action in ActionSchedule to optionally wait until playback resumes.
This allows more deterministic action schedules, especially for real media which may take an arbitrary amount of time to rebuffer after seeking. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=171005231
This commit is contained in:
parent
498ff14439
commit
d7b4f8a645
4 changed files with 51 additions and 5 deletions
|
|
@ -39,8 +39,8 @@ public final class CommonEncryptionDrmTest extends ActivityInstrumentationTestCa
|
|||
|
||||
// Seeks help reproduce playback issues in certain devices.
|
||||
private static final ActionSchedule ACTION_SCHEDULE_WITH_SEEKS = new ActionSchedule.Builder(TAG)
|
||||
.delay(30000).seek(300000).delay(10000).seek(270000).delay(10000).seek(200000).delay(10000)
|
||||
.seek(732000).build();
|
||||
.delay(30000).seekAndWait(300000).delay(10000).seekAndWait(270000).delay(10000)
|
||||
.seekAndWait(200000).delay(10000).seekAndWait(732000).build();
|
||||
|
||||
private DashTestRunner testRunner;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,10 +33,10 @@ public final class DashStreamingTest extends ActivityInstrumentationTestCase2<Ho
|
|||
private static final String TAG = "DashStreamingTest";
|
||||
|
||||
private static final ActionSchedule SEEKING_SCHEDULE = new ActionSchedule.Builder(TAG)
|
||||
.delay(10000).seek(15000)
|
||||
.delay(10000).seek(30000).seek(31000).seek(32000).seek(33000).seek(34000)
|
||||
.delay(10000).seekAndWait(15000)
|
||||
.delay(10000).seek(30000).seek(31000).seek(32000).seek(33000).seekAndWait(34000)
|
||||
.delay(1000).pause().delay(1000).play()
|
||||
.delay(1000).pause().seek(120000).delay(1000).play()
|
||||
.delay(1000).pause().seekAndWait(120000).delay(1000).play()
|
||||
.build();
|
||||
private static final ActionSchedule RENDERER_DISABLING_SCHEDULE = new ActionSchedule.Builder(TAG)
|
||||
// Wait 10 seconds, disable the video renderer, wait another 10 seconds and enable it again.
|
||||
|
|
|
|||
|
|
@ -422,6 +422,39 @@ public abstract class Action {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for {@link Player.EventListener#onSeekProcessed()}.
|
||||
*/
|
||||
public static final class WaitForSeekProcessed extends Action {
|
||||
|
||||
/**
|
||||
* @param tag A tag to use for logging.
|
||||
*/
|
||||
public WaitForSeekProcessed(String tag) {
|
||||
super(tag, "WaitForSeekProcessed");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doActionAndScheduleNextImpl(final SimpleExoPlayer player,
|
||||
final MappingTrackSelector trackSelector, final Surface surface, final Handler handler,
|
||||
final ActionNode nextAction) {
|
||||
player.addListener(new Player.DefaultEventListener() {
|
||||
@Override
|
||||
public void onSeekProcessed() {
|
||||
player.removeListener(this);
|
||||
nextAction.schedule(player, trackSelector, surface, handler);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doActionImpl(SimpleExoPlayer player, MappingTrackSelector trackSelector,
|
||||
Surface surface) {
|
||||
// Not triggered.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls {@link Runnable#run()}.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import com.google.android.exoplayer2.testutil.Action.SetVideoSurface;
|
|||
import com.google.android.exoplayer2.testutil.Action.Stop;
|
||||
import com.google.android.exoplayer2.testutil.Action.WaitForPlaybackState;
|
||||
import com.google.android.exoplayer2.testutil.Action.WaitForPositionDiscontinuity;
|
||||
import com.google.android.exoplayer2.testutil.Action.WaitForSeekProcessed;
|
||||
import com.google.android.exoplayer2.testutil.Action.WaitForTimelineChanged;
|
||||
import com.google.android.exoplayer2.trackselection.MappingTrackSelector;
|
||||
import com.google.android.exoplayer2.util.Clock;
|
||||
|
|
@ -138,6 +139,18 @@ public final class ActionSchedule {
|
|||
return apply(new Seek(tag, positionMs));
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules a seek action to be executed and waits until playback resumes after the seek.
|
||||
*
|
||||
* @param positionMs The seek position.
|
||||
* @return The builder, for convenience.
|
||||
*/
|
||||
public Builder seekAndWait(long positionMs) {
|
||||
return apply(new Seek(tag, positionMs))
|
||||
.apply(new WaitForSeekProcessed(tag))
|
||||
.apply(new WaitForPlaybackState(tag, Player.STATE_READY));
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules a stop action to be executed.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue