mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Tap the video playback view to switch audio output.
PiperOrigin-RevId: 524027177
This commit is contained in:
parent
a358ccb046
commit
2ee84b809d
3 changed files with 23 additions and 5 deletions
|
|
@ -690,6 +690,7 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||||
ExoPlayer outputPlayer = new ExoPlayer.Builder(/* context= */ this).build();
|
ExoPlayer outputPlayer = new ExoPlayer.Builder(/* context= */ this).build();
|
||||||
outputPlayerView.setPlayer(outputPlayer);
|
outputPlayerView.setPlayer(outputPlayer);
|
||||||
outputPlayerView.setControllerAutoShow(false);
|
outputPlayerView.setControllerAutoShow(false);
|
||||||
|
outputPlayerView.setOnClickListener(this::onClickingPlayerView);
|
||||||
outputPlayer.setMediaItem(outputMediaItem);
|
outputPlayer.setMediaItem(outputMediaItem);
|
||||||
outputPlayer.prepare();
|
outputPlayer.prepare();
|
||||||
this.outputPlayer = outputPlayer;
|
this.outputPlayer = outputPlayer;
|
||||||
|
|
@ -711,12 +712,13 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||||
} else {
|
} else {
|
||||||
inputPlayerView.setVisibility(View.VISIBLE);
|
inputPlayerView.setVisibility(View.VISIBLE);
|
||||||
inputImageView.setVisibility(View.GONE);
|
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();
|
ExoPlayer inputPlayer = new ExoPlayer.Builder(/* context= */ this).build();
|
||||||
inputPlayerView.setPlayer(inputPlayer);
|
inputPlayerView.setPlayer(inputPlayer);
|
||||||
inputPlayerView.setControllerAutoShow(false);
|
inputPlayerView.setControllerAutoShow(false);
|
||||||
inputPlayer.setMediaItem(inputMediaItem);
|
inputPlayer.setMediaItem(inputMediaItem);
|
||||||
|
inputPlayerView.setOnClickListener(this::onClickingPlayerView);
|
||||||
inputPlayer.prepare();
|
inputPlayer.prepare();
|
||||||
this.inputPlayer = inputPlayer;
|
this.inputPlayer = inputPlayer;
|
||||||
inputPlayer.setVolume(0f);
|
inputPlayer.setVolume(0f);
|
||||||
|
|
@ -728,6 +730,20 @@ public final class TransformerActivity extends AppCompatActivity {
|
||||||
debugTextViewHelper.start();
|
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() {
|
private void releasePlayer() {
|
||||||
if (debugTextViewHelper != null) {
|
if (debugTextViewHelper != null) {
|
||||||
debugTextViewHelper.stop();
|
debugTextViewHelper.stop();
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:text="@string/input_video" />
|
android:text="@string/input_video_no_sound" />
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|
@ -118,7 +118,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="8dp"
|
android:layout_margin="8dp"
|
||||||
android:text="@string/output_video" />
|
android:text="@string/output_video_playing_sound" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/debug_text_view"
|
android:id="@+id/debug_text_view"
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,10 @@
|
||||||
<string name="saturation_adjustment">Saturation adjustment</string>
|
<string name="saturation_adjustment">Saturation adjustment</string>
|
||||||
<string name="lightness_adjustment">Lightness adjustment</string>
|
<string name="lightness_adjustment">Lightness adjustment</string>
|
||||||
<string name="input_image">Input image:</string>
|
<string name="input_image">Input image:</string>
|
||||||
<string name="input_video">Input video:</string>
|
<string name="input_video_no_sound">Input video (tap to play sound):</string>
|
||||||
<string name="output_video">Output video:</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="permission_denied">Permission Denied</string>
|
||||||
<string name="hide_input_video">Hide input video</string>
|
<string name="hide_input_video">Hide input video</string>
|
||||||
<string name="show_input_video">Show input video</string>
|
<string name="show_input_video">Show input video</string>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue