Make PlayerView
Compose workaround opt-in
The workaround causes issues with XML-based shared transitions, so we can't apply it unilaterally. Issue: androidx/media#1594 Issue: androidx/media#1237 PiperOrigin-RevId: 670960693
This commit is contained in:
parent
c851464063
commit
87bd9ba585
@ -23,6 +23,13 @@
|
|||||||
* IMA extension:
|
* IMA extension:
|
||||||
* Session:
|
* Session:
|
||||||
* UI:
|
* UI:
|
||||||
|
* Make the stretched/cropped video in
|
||||||
|
`PlayerView`-in-Compose-`AndroidView` workaround opt-in, due to issues
|
||||||
|
with XML-based shared transitions. Apps using `PlayerView` inside
|
||||||
|
`AndroidView` need to call
|
||||||
|
`PlayerView.setEnableComposeSurfaceSyncWorkaround` in order to opt-in
|
||||||
|
([#1237](https://github.com/androidx/media/issues/1237),
|
||||||
|
[#1594](https://github.com/androidx/media/issues/1594)).
|
||||||
* Downloads:
|
* Downloads:
|
||||||
* OkHttp Extension:
|
* OkHttp Extension:
|
||||||
* Cronet Extension:
|
* Cronet Extension:
|
||||||
|
@ -333,6 +333,7 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
|||||||
private boolean controllerAutoShow;
|
private boolean controllerAutoShow;
|
||||||
private boolean controllerHideDuringAds;
|
private boolean controllerHideDuringAds;
|
||||||
private boolean controllerHideOnTouch;
|
private boolean controllerHideOnTouch;
|
||||||
|
private boolean enableComposeSurfaceSyncWorkaround;
|
||||||
|
|
||||||
public PlayerView(Context context) {
|
public PlayerView(Context context) {
|
||||||
this(context, /* attrs= */ null);
|
this(context, /* attrs= */ null);
|
||||||
@ -1304,6 +1305,19 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
|||||||
contentFrame.setAspectRatioListener(listener);
|
contentFrame.setAspectRatioListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to enable a workaround for the Compose {@code AndroidView} and {@link SurfaceView}
|
||||||
|
* compatibility issue described in <a
|
||||||
|
* href="https://github.com/androidx/media/issues/1237">androidx/media#1237</a>.
|
||||||
|
*
|
||||||
|
* <p>This workaround causes issues with shared element transitions in XML views, so is disabled
|
||||||
|
* by default (<a href="https://github.com/androidx/media/issues/1594">androidx/media#1594</a>).
|
||||||
|
*/
|
||||||
|
@UnstableApi
|
||||||
|
public void setEnableComposeSurfaceSyncWorkaround(boolean enableComposeSurfaceSyncWorkaround) {
|
||||||
|
this.enableComposeSurfaceSyncWorkaround = enableComposeSurfaceSyncWorkaround;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the view onto which video is rendered. This is a:
|
* Gets the view onto which video is rendered. This is a:
|
||||||
*
|
*
|
||||||
@ -1758,7 +1772,7 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
|||||||
@Override
|
@Override
|
||||||
protected void dispatchDraw(Canvas canvas) {
|
protected void dispatchDraw(Canvas canvas) {
|
||||||
super.dispatchDraw(canvas);
|
super.dispatchDraw(canvas);
|
||||||
if (Util.SDK_INT == 34 && surfaceSyncGroupV34 != null) {
|
if (Util.SDK_INT == 34 && surfaceSyncGroupV34 != null && enableComposeSurfaceSyncWorkaround) {
|
||||||
surfaceSyncGroupV34.maybeMarkSyncReadyAndClear();
|
surfaceSyncGroupV34.maybeMarkSyncReadyAndClear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1830,7 +1844,9 @@ public class PlayerView extends FrameLayout implements AdViewProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSurfaceSizeChanged(int width, int height) {
|
public void onSurfaceSizeChanged(int width, int height) {
|
||||||
if (Util.SDK_INT == 34 && surfaceView instanceof SurfaceView) {
|
if (Util.SDK_INT == 34
|
||||||
|
&& surfaceView instanceof SurfaceView
|
||||||
|
&& enableComposeSurfaceSyncWorkaround) {
|
||||||
// Register a SurfaceSyncGroup to work around https://github.com/androidx/media/issues/1237
|
// Register a SurfaceSyncGroup to work around https://github.com/androidx/media/issues/1237
|
||||||
// (only present on API 34, fixed on API 35).
|
// (only present on API 34, fixed on API 35).
|
||||||
checkNotNull(surfaceSyncGroupV34)
|
checkNotNull(surfaceSyncGroupV34)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user