google / google/ExoPlayer

PIP flickering

Open
#8,611 5 comments 0 reactions 1 assignee Assigned to @icbaker View on GitHub
bug: in platform
Dominant language
Java
Stars
21.9k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Hi,
I'm implementing PIP feature following the android developer guide.
When animating I'm using a `SurfaceView` (I can't use a `TextureView` because I can't play HDR videos).
When I am in pip mode and i tap on the pip window in order to show the control player i notice a flickering: the SurfaceView has a strange behavior as shown below:

![2021-02-19 17 10 00](https://user-images.githubusercontent.com/30128519/108530503-f5a89a00-72d5-11eb-9e92-cebd816a0d3c.jpg)
![2021-02-19 17 10 10](https://user-images.githubusercontent.com/30128519/108530519-f93c2100-72d5-11eb-9a36-82db7b8c0fbb.jpg)

You can reproduce the same problem updating the Exoplayer demo project:
here you can find the `git diff`

```
diff --git a/demos/main/src/main/AndroidManifest.xml b/demos/main/src/main/AndroidManifest.xml
index 053665502..2c36edab7 100644
--- a/demos/main/src/main/AndroidManifest.xml
+++ b/demos/main/src/main/AndroidManifest.xml
@@ -65,6 +65,7 @@
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode"
android:launchMode="singleTop"
android:label="@string/application_name"
+ android:supportsPictureInPicture="true"
android:theme="@style/PlayerTheme">


diff --git a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
index 5fb342be4..1da9a3634 100644
--- a/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
+++ b/demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
@@ -19,6 +19,7 @@ import static com.google.android.exoplayer2.util.Assertions.checkNotNull;

import android.content.Intent;
import android.content.pm.PackageManager;
+import android.os.Build;
import android.os.Bundle;
import android.util.Pair;
import android.view.KeyEvent;
@@ -105,6 +106,10 @@ public class PlayerActivity extends AppCompatActivity
setContentView();
debugRootView = findViewById(R.id.controls_root);
debugTextView = findViewById(R.id.debug_text_view);
+
+ debugRootView.setVisibility(View.GONE);
+ debugTextView.setVisibility(View.GONE);
+
selectTracksButton = findViewById(R.id.select_tracks_button);
selectTracksButton.setOnClickListener(this);

@@ -160,11 +165,8 @@ public class PlayerActivity extends AppCompatActivity
@Override
public void onPause() {
super.onPause();
- if (Util.SDK_INT <= 23) {
- if (playerView != null) {
- playerView.onPause();
- }
- releasePlayer();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ enterPictureInPictureMode();
}
}
```

Android version: all android versions that support pip feature (from Android 24)
Tested on many different devices (Samsung Galaxy S20+, Samsung Galaxy S9, Pixel 3, Nexus 6 ecc...)
Exoplayer version: 2.13.1

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.