Tap the video playback view to switch audio output.
PiperOrigin-RevId: 524027177
This commit is contained in:
parent
a358ccb046
commit
2ee84b809d
@ -690,6 +690,7 @@ 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;
|
||||
@ -711,12 +712,13 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
} else {
|
||||
inputPlayerView.setVisibility(View.VISIBLE);
|
||||
inputImageView.setVisibility(View.GONE);
|
||||
inputTextView.setText(getString(R.string.input_video));
|
||||
inputTextView.setText(getString(R.string.input_video_no_sound));
|
||||
|
||||
ExoPlayer inputPlayer = new ExoPlayer.Builder(/* context= */ this).build();
|
||||
inputPlayerView.setPlayer(inputPlayer);
|
||||
inputPlayerView.setControllerAutoShow(false);
|
||||
inputPlayer.setMediaItem(inputMediaItem);
|
||||
inputPlayerView.setOnClickListener(this::onClickingPlayerView);
|
||||
inputPlayer.prepare();
|
||||
this.inputPlayer = inputPlayer;
|
||||
inputPlayer.setVolume(0f);
|
||||
@ -728,6 +730,20 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||
debugTextViewHelper.start();
|
||||
}
|
||||
|
||||
private void onClickingPlayerView(View view) {
|
||||
if (view == inputPlayerView) {
|
||||
checkNotNull(inputPlayer).setVolume(1f);
|
||||
checkNotNull(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));
|
||||
checkNotNull(outputPlayer).setVolume(1f);
|
||||
checkNotNull(outputVideoTextView).setText(R.string.output_video_playing_sound);
|
||||
}
|
||||
}
|
||||
|
||||
private void releasePlayer() {
|
||||
if (debugTextViewHelper != null) {
|
||||
debugTextViewHelper.stop();
|
||||
|
@ -74,7 +74,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:padding="8dp"
|
||||
android:text="@string/input_video" />
|
||||
android:text="@string/input_video_no_sound" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
@ -118,7 +118,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:text="@string/output_video" />
|
||||
android:text="@string/output_video_playing_sound" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/debug_text_view"
|
||||
|
@ -63,8 +63,10 @@
|
||||
<string name="saturation_adjustment">Saturation adjustment</string>
|
||||
<string name="lightness_adjustment">Lightness adjustment</string>
|
||||
<string name="input_image">Input image:</string>
|
||||
<string name="input_video">Input video:</string>
|
||||
<string name="output_video">Output video:</string>
|
||||
<string name="input_video_no_sound">Input video (tap to play sound):</string>
|
||||
<string name="input_video_playing_sound">Input video (sound playing):</string>
|
||||
<string name="output_video_no_sound">Output video (tap to play sound):</string>
|
||||
<string name="output_video_playing_sound">Output video (sound playing):</string>
|
||||
<string name="permission_denied">Permission Denied</string>
|
||||
<string name="hide_input_video">Hide input video</string>
|
||||
<string name="show_input_video">Show input video</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user