Add overlay FrameLayout to hosted tests
PiperOrigin-RevId: 303283147
This commit is contained in:
parent
25d9f76a07
commit
4454520e93
@ -21,6 +21,7 @@ import android.media.MediaDrm;
|
|||||||
import android.media.UnsupportedSchemeException;
|
import android.media.UnsupportedSchemeException;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
import androidx.annotation.RequiresApi;
|
import androidx.annotation.RequiresApi;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
@ -297,7 +298,10 @@ import java.util.List;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MediaSource buildSource(
|
protected MediaSource buildSource(
|
||||||
HostActivity host, String userAgent, DrmSessionManager drmSessionManager) {
|
HostActivity host,
|
||||||
|
String userAgent,
|
||||||
|
DrmSessionManager drmSessionManager,
|
||||||
|
FrameLayout overlayFrameLayout) {
|
||||||
DataSource.Factory dataSourceFactory =
|
DataSource.Factory dataSourceFactory =
|
||||||
this.dataSourceFactory != null
|
this.dataSourceFactory != null
|
||||||
? this.dataSourceFactory
|
? this.dataSourceFactory
|
||||||
|
@ -20,6 +20,7 @@ import static com.google.common.truth.Truth.assertWithMessage;
|
|||||||
import android.os.ConditionVariable;
|
import android.os.ConditionVariable;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.DefaultRenderersFactory;
|
import com.google.android.exoplayer2.DefaultRenderersFactory;
|
||||||
@ -126,7 +127,7 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest {
|
|||||||
// HostedTest implementation
|
// HostedTest implementation
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void onStart(HostActivity host, Surface surface) {
|
public final void onStart(HostActivity host, Surface surface, FrameLayout overlayFrameLayout) {
|
||||||
this.surface = surface;
|
this.surface = surface;
|
||||||
// Build the player.
|
// Build the player.
|
||||||
trackSelector = buildTrackSelector(host);
|
trackSelector = buildTrackSelector(host);
|
||||||
@ -142,7 +143,9 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest {
|
|||||||
pendingSchedule = null;
|
pendingSchedule = null;
|
||||||
}
|
}
|
||||||
DrmSessionManager drmSessionManager = buildDrmSessionManager(userAgent);
|
DrmSessionManager drmSessionManager = buildDrmSessionManager(userAgent);
|
||||||
player.setMediaSource(buildSource(host, Util.getUserAgent(host, userAgent), drmSessionManager));
|
player.setMediaSource(
|
||||||
|
buildSource(
|
||||||
|
host, Util.getUserAgent(host, userAgent), drmSessionManager, overlayFrameLayout));
|
||||||
player.prepare();
|
player.prepare();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +257,10 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected abstract MediaSource buildSource(
|
protected abstract MediaSource buildSource(
|
||||||
HostActivity host, String userAgent, DrmSessionManager drmSessionManager);
|
HostActivity host,
|
||||||
|
String userAgent,
|
||||||
|
DrmSessionManager drmSessionManager,
|
||||||
|
FrameLayout overlayFrameLayout);
|
||||||
|
|
||||||
protected void onPlayerErrorInternal(ExoPlaybackException error) {
|
protected void onPlayerErrorInternal(ExoPlaybackException error) {
|
||||||
// Do nothing. Interested subclasses may override.
|
// Do nothing. Interested subclasses may override.
|
||||||
|
@ -29,6 +29,7 @@ import android.view.Surface;
|
|||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
import android.view.SurfaceView;
|
import android.view.SurfaceView;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import com.google.android.exoplayer2.util.Assertions;
|
import com.google.android.exoplayer2.util.Assertions;
|
||||||
import com.google.android.exoplayer2.util.Log;
|
import com.google.android.exoplayer2.util.Log;
|
||||||
@ -45,14 +46,15 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on the main thread when the test is started.
|
* Called on the main thread when the test is started.
|
||||||
* <p>
|
*
|
||||||
* The test will not be started until the {@link HostActivity} has been resumed and its
|
* <p>The test will not be started until the {@link HostActivity} has been resumed and its
|
||||||
* {@link Surface} has been created.
|
* {@link Surface} has been created.
|
||||||
*
|
*
|
||||||
* @param host The {@link HostActivity} in which the test is being run.
|
* @param host The {@link HostActivity} in which the test is being run.
|
||||||
* @param surface The {@link Surface}.
|
* @param surface The {@link Surface}.
|
||||||
|
* @param overlayFrameLayout A {@link FrameLayout} that is on top of the surface.
|
||||||
*/
|
*/
|
||||||
void onStart(HostActivity host, Surface surface);
|
void onStart(HostActivity host, Surface surface, FrameLayout overlayFrameLayout);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on the main thread to block until the test has stopped or {@link #forceStop()} is
|
* Called on the main thread to block until the test has stopped or {@link #forceStop()} is
|
||||||
@ -86,6 +88,7 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba
|
|||||||
@Nullable private WakeLock wakeLock;
|
@Nullable private WakeLock wakeLock;
|
||||||
@Nullable private WifiLock wifiLock;
|
@Nullable private WifiLock wifiLock;
|
||||||
private @MonotonicNonNull SurfaceView surfaceView;
|
private @MonotonicNonNull SurfaceView surfaceView;
|
||||||
|
private @MonotonicNonNull FrameLayout overlayFrameLayout;
|
||||||
|
|
||||||
@Nullable private HostedTest hostedTest;
|
@Nullable private HostedTest hostedTest;
|
||||||
private boolean hostedTestStarted;
|
private boolean hostedTestStarted;
|
||||||
@ -171,6 +174,8 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba
|
|||||||
surfaceView = findViewById(
|
surfaceView = findViewById(
|
||||||
getResources().getIdentifier("surface_view", "id", getPackageName()));
|
getResources().getIdentifier("surface_view", "id", getPackageName()));
|
||||||
surfaceView.getHolder().addCallback(this);
|
surfaceView.getHolder().addCallback(this);
|
||||||
|
overlayFrameLayout =
|
||||||
|
findViewById(getResources().getIdentifier("overlay_frame_layout", "id", getPackageName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -240,7 +245,8 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba
|
|||||||
if (surface != null && surface.isValid()) {
|
if (surface != null && surface.isValid()) {
|
||||||
hostedTestStarted = true;
|
hostedTestStarted = true;
|
||||||
Log.d(TAG, "Starting test.");
|
Log.d(TAG, "Starting test.");
|
||||||
Util.castNonNull(hostedTest).onStart(this, surface);
|
Util.castNonNull(hostedTest)
|
||||||
|
.onStart(this, surface, Assertions.checkNotNull(overlayFrameLayout));
|
||||||
Util.castNonNull(hostedTestStartedCondition).open();
|
Util.castNonNull(hostedTestStartedCondition).open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,4 +25,8 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center"/>
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
|
<FrameLayout android:id="@+id/overlay_frame_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user