summaryrefslogtreecommitdiff
path: root/main/src
diff options
context:
space:
mode:
authorSetup Wizard Team <android-setup-team-eng@google.com>2019-04-11 19:05:47 -0700
committerMaurice Lam <yukl@google.com>2019-04-12 02:08:34 +0000
commit683556acbc791c2e6d3e2529c3caac330d3e7f4c (patch)
tree9b3e2b8a2edad98eaf05f3ddd66fc2d96f6ee5e6 /main/src
parent9d1af16dcc2cc148af312a8ae4f65ba58ad7f5bf (diff)
downloadsetupdesign-683556acbc791c2e6d3e2529c3caac330d3e7f4c.tar.gz
Import updated Android Setupdesign Library 243187242
Copied from google3/third_party/java_src/android_libs/setupdesign Test: mm Included changes: - 243187242 Set IllustrationVideoView to be visible until we are read... Bug: 130366161 PiperOrigin-RevId: 243187242 Change-Id: Id6e2fda9b40362cf6a977983efab7246792b5b5b
Diffstat (limited to 'main/src')
-rw-r--r--main/src/com/google/android/setupdesign/view/IllustrationVideoView.java28
1 files changed, 14 insertions, 14 deletions
diff --git a/main/src/com/google/android/setupdesign/view/IllustrationVideoView.java b/main/src/com/google/android/setupdesign/view/IllustrationVideoView.java
index 41531cd..939b8de 100644
--- a/main/src/com/google/android/setupdesign/view/IllustrationVideoView.java
+++ b/main/src/com/google/android/setupdesign/view/IllustrationVideoView.java
@@ -78,16 +78,17 @@ public class IllustrationVideoView extends TextureView
/**
* The visibility of this view as set by the user. This view combines this with {@link
- * #isReadyToShow} to determine the final visibility.
+ * #isMediaPlayerLoading} to determine the final visibility.
*/
private int visibility = View.VISIBLE;
/**
- * Whether this view is ready to show. Since texture views loads asynchronously, to avoid a flash
- * with a color different from the background, set this view to invisible until the video is ready
- * to show.
+ * Whether the media player is loading. This is used to hide this view to avoid a flash with a
+ * color different from the background while the media player is trying to render the first frame.
+ * Note: if this TextureView is not visible, it will never load the surface texture, and never
+ * play the video.
*/
- private boolean isReadyToShow = false;
+ private boolean isMediaPlayerLoading = false;
public IllustrationVideoView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -199,7 +200,7 @@ public class IllustrationVideoView extends TextureView
// Reattach only if it has been previously released
SurfaceTexture surfaceTexture = getSurfaceTexture();
if (surfaceTexture != null) {
- setIsReadyToShow(false);
+ setIsMediaPlayerLoading(true);
surface = new Surface(surfaceTexture);
}
}
@@ -217,14 +218,14 @@ public class IllustrationVideoView extends TextureView
@Override
public void setVisibility(int visibility) {
this.visibility = visibility;
- if (!isReadyToShow && visibility == View.VISIBLE) {
+ if (isMediaPlayerLoading && visibility == View.VISIBLE) {
visibility = View.INVISIBLE;
}
super.setVisibility(visibility);
}
- private void setIsReadyToShow(boolean isReadyToShow) {
- this.isReadyToShow = isReadyToShow;
+ private void setIsMediaPlayerLoading(boolean isMediaPlayerLoading) {
+ this.isMediaPlayerLoading = isMediaPlayerLoading;
setVisibility(this.visibility);
}
@@ -265,7 +266,8 @@ public class IllustrationVideoView extends TextureView
if (surface != null) {
createMediaPlayer();
} else {
- Log.w(TAG, "Surface creation failed");
+ // This can happen if this view hasn't been drawn yet
+ Log.i(TAG, "Surface is null");
}
}
@@ -275,8 +277,7 @@ public class IllustrationVideoView extends TextureView
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width, int height) {
- // Keep the view hidden until video starts
- setIsReadyToShow(false);
+ setIsMediaPlayerLoading(true);
initVideo();
}
@@ -318,8 +319,7 @@ public class IllustrationVideoView extends TextureView
@Override
public boolean onInfo(MediaPlayer mp, int what, int extra) {
if (what == MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START) {
- // Video available, show view now
- setIsReadyToShow(true);
+ setIsMediaPlayerLoading(false);
onRenderingStart();
}
return false;