Automatically play the gesture video when the setting is launched.

- and save the video pause state on config change so that the paused
video will not auto start again on screen rotation.

Change-Id: I3f41849ee3063942fb4141e4556e494bc8439226
Fix: 63145847
Test: make RunSettingsRoboTests
This commit is contained in:
Doris Ling
2017-07-11 10:38:24 -07:00
parent 70a48e66eb
commit a689787b71
3 changed files with 76 additions and 6 deletions

View File

@@ -45,6 +45,7 @@ public class VideoPreference extends Preference {
private MediaPlayer mMediaPlayer;
private boolean mAnimationAvailable;
private boolean mVideoReady;
private boolean mVideoPaused;
private int mPreviewResource;
public VideoPreference(Context context, AttributeSet attrs) {
@@ -100,9 +101,11 @@ public class VideoPreference extends Preference {
if (mMediaPlayer.isPlaying()) {
mMediaPlayer.pause();
playButton.setVisibility(View.VISIBLE);
mVideoPaused = true;
} else {
mMediaPlayer.start();
playButton.setVisibility(View.GONE);
mVideoPaused = false;
}
}
});
@@ -133,6 +136,10 @@ public class VideoPreference extends Preference {
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
if (mVideoReady && imageView.getVisibility() == View.VISIBLE) {
imageView.setVisibility(View.GONE);
if (!mVideoPaused && mMediaPlayer != null && !mMediaPlayer.isPlaying()) {
mMediaPlayer.start();
playButton.setVisibility(View.GONE);
}
}
if (mMediaPlayer != null && !mMediaPlayer.isPlaying() &&
playButton.getVisibility() != View.VISIBLE) {
@@ -152,7 +159,8 @@ public class VideoPreference extends Preference {
super.onDetached();
}
public void onViewVisible() {
public void onViewVisible(boolean videoPaused) {
mVideoPaused = videoPaused;
if (mVideoReady && mMediaPlayer != null && !mMediaPlayer.isPlaying()) {
mMediaPlayer.seekTo(0);
}
@@ -163,4 +171,9 @@ public class VideoPreference extends Preference {
mMediaPlayer.pause();
}
}
public boolean isVideoPaused() {
return mVideoPaused;
}
}