Commit 46ebba38 by claincly Committed by Rohit Singh

Fix crash when there's no input player view.

This happens when the input is an image. The output will always be video so the
outputPlayer and outputVideoTextView will always present.

PiperOrigin-RevId: 524329436
parent 93412907
......@@ -689,7 +689,6 @@ public final class TransformerActivity extends AppCompatActivity {
ExoPlayer outputPlayer = new ExoPlayer.Builder(/* context= */ this).build();
outputPlayerView.setPlayer(outputPlayer);
outputPlayerView.setControllerAutoShow(false);
outputPlayerView.setOnClickListener(this::onClickingPlayerView);
outputPlayer.setMediaItem(outputMediaItem);
outputPlayer.prepare();
this.outputPlayer = outputPlayer;
......@@ -717,6 +716,7 @@ public final class TransformerActivity extends AppCompatActivity {
inputPlayerView.setPlayer(inputPlayer);
inputPlayerView.setControllerAutoShow(false);
inputPlayerView.setOnClickListener(this::onClickingPlayerView);
outputPlayerView.setOnClickListener(this::onClickingPlayerView);
inputPlayer.setMediaItem(inputMediaItem);
inputPlayer.prepare();
this.inputPlayer = inputPlayer;
......@@ -731,13 +731,17 @@ public final class TransformerActivity extends AppCompatActivity {
private void onClickingPlayerView(View view) {
if (view == inputPlayerView) {
checkNotNull(inputPlayer).setVolume(1f);
checkNotNull(inputTextView).setText(R.string.input_video_playing_sound);
if (inputPlayer != null && inputTextView != null) {
inputPlayer.setVolume(1f);
inputTextView.setText(R.string.input_video_playing_sound);
}
checkNotNull(outputPlayer).setVolume(0f);
checkNotNull(outputVideoTextView).setText(R.string.output_video_no_sound);
} else {
checkNotNull(inputPlayer).setVolume(0f);
checkNotNull(inputTextView).setText(getString(R.string.input_video_no_sound));
if (inputPlayer != null && inputTextView != null) {
inputPlayer.setVolume(0f);
inputTextView.setText(getString(R.string.input_video_no_sound));
}
checkNotNull(outputPlayer).setVolume(1f);
checkNotNull(outputVideoTextView).setText(R.string.output_video_playing_sound);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment