diff --git a/demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/TransformerActivity.java b/demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/TransformerActivity.java
index c1df2fe67b2..6e82df3c5a8 100644
--- a/demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/TransformerActivity.java
+++ b/demos/transformer/src/main/java/com/google/android/exoplayer2/transformerdemo/TransformerActivity.java
@@ -31,6 +31,7 @@
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
@@ -77,6 +78,7 @@
public final class TransformerActivity extends AppCompatActivity {
private static final String TAG = "TransformerActivity";
+ private @MonotonicNonNull Button displayInputButton;
private @MonotonicNonNull MaterialCardView inputCardView;
private @MonotonicNonNull StyledPlayerView inputPlayerView;
private @MonotonicNonNull StyledPlayerView outputPlayerView;
@@ -106,6 +108,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
progressViewGroup = findViewById(R.id.progress_view_group);
progressIndicator = findViewById(R.id.progress_indicator);
debugFrame = findViewById(R.id.debug_aspect_ratio_frame_layout);
+ displayInputButton = findViewById(R.id.display_input_button);
+ displayInputButton.setOnClickListener(this::toggleInputVideoDisplay);
transformationStopwatch =
Stopwatch.createUnstarted(
@@ -130,6 +134,7 @@ protected void onStart() {
checkNotNull(debugTextView);
checkNotNull(progressViewGroup);
checkNotNull(debugFrame);
+ checkNotNull(displayInputButton);
startTransformation();
inputPlayerView.onResume();
@@ -159,6 +164,7 @@ protected void onStop() {
"inputCardView",
"inputPlayerView",
"outputPlayerView",
+ "displayInputButton",
"debugTextView",
"informationTextView",
"progressIndicator",
@@ -228,6 +234,7 @@ private MediaItem createMediaItem(@Nullable Bundle bundle, Uri uri) {
"inputCardView",
"inputPlayerView",
"outputPlayerView",
+ "displayInputButton",
"debugTextView",
"informationTextView",
"transformationStopwatch",
@@ -464,6 +471,7 @@ private void onTransformationError(TransformationException exception) {
"inputCardView",
"inputPlayerView",
"outputPlayerView",
+ "displayInputButton",
"debugTextView",
"informationTextView",
"progressViewGroup",
@@ -479,6 +487,7 @@ private void onTransformationCompleted(String filePath, MediaItem inputMediaItem
debugFrame.removeAllViews();
inputCardView.setVisibility(View.VISIBLE);
outputPlayerView.setVisibility(View.VISIBLE);
+ displayInputButton.setVisibility(View.VISIBLE);
playMediaItems(inputMediaItem, MediaItem.fromUri("file://" + filePath));
Log.d(TAG, "Output file path: file://" + filePath);
}
@@ -541,6 +550,21 @@ private void showToast(@StringRes int messageResource) {
Toast.makeText(getApplicationContext(), getString(messageResource), Toast.LENGTH_LONG).show();
}
+ @RequiresNonNull({
+ "inputCardView",
+ "displayInputButton",
+ })
+ private void toggleInputVideoDisplay(View view) {
+ if (inputCardView.getVisibility() == View.GONE) {
+ inputCardView.setVisibility(View.VISIBLE);
+ displayInputButton.setText(getString(R.string.hide_input_video));
+ } else if (inputCardView.getVisibility() == View.VISIBLE) {
+ checkNotNull(inputPlayer).pause();
+ inputCardView.setVisibility(View.GONE);
+ displayInputButton.setText(getString(R.string.show_input_video));
+ }
+ }
+
private final class DemoDebugViewProvider implements DebugViewProvider {
private @MonotonicNonNull SurfaceView surfaceView;
diff --git a/demos/transformer/src/main/res/layout/transformer_activity.xml b/demos/transformer/src/main/res/layout/transformer_activity.xml
index 26a84764f40..1f4c110cfe6 100644
--- a/demos/transformer/src/main/res/layout/transformer_activity.xml
+++ b/demos/transformer/src/main/res/layout/transformer_activity.xml
@@ -29,12 +29,28 @@
app:cardElevation="2dp"
android:gravity="center_vertical" >
-
+ android:layout_height="wrap_content">
+
+
+
+
+
+
+
diff --git a/demos/transformer/src/main/res/values/strings.xml b/demos/transformer/src/main/res/values/strings.xml
index fdf638bca6c..f777d876f9d 100644
--- a/demos/transformer/src/main/res/values/strings.xml
+++ b/demos/transformer/src/main/res/values/strings.xml
@@ -61,4 +61,6 @@
Lightness adjustment
Input video:
Output video:
+ Hide input video
+ Show input video