use of com.google.android.exoplayer2.ui.PlayerControlView in project Slide by ccrama.
the class ExoVideoView method setupUI.
/**
* Sets up the player UI
*/
private void setupUI() {
// Create a PlayerControlView for our video controls and add it
playerUI = new PlayerControlView(context);
playerUI.setPlayer(player);
playerUI.setShowTimeoutMs(2000);
playerUI.hide();
addView(playerUI);
// Show/hide the player UI on tap
setOnClickListener((v) -> {
playerUI.clearAnimation();
if (playerUI.isVisible()) {
playerUI.startAnimation(new PlayerUIFadeInAnimation(playerUI, false, 300));
} else {
playerUI.startAnimation(new PlayerUIFadeInAnimation(playerUI, true, 300));
}
});
}
use of com.google.android.exoplayer2.ui.PlayerControlView in project ExoPlayer by google.
the class MainActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
playerControlView = findViewById(R.id.player_control_view);
fullScreenView = findViewById(R.id.full_screen_view);
fullScreenView.setOnClickListener(v -> {
setCurrentOutputView(nonFullScreenView);
Assertions.checkNotNull(fullScreenView).setVisibility(View.GONE);
});
attachSurfaceListener(fullScreenView);
isOwner = getIntent().getBooleanExtra(OWNER_EXTRA, /* defaultValue= */
true);
GridLayout gridLayout = findViewById(R.id.grid_layout);
for (int i = 0; i < 9; i++) {
View view;
if (i == 0) {
Button button = new Button(/* context= */
this);
view = button;
button.setText(getString(R.string.no_output_label));
button.setOnClickListener(v -> reparent(/* surfaceView= */
null));
} else if (i == 1) {
Button button = new Button(/* context= */
this);
view = button;
button.setText(getString(R.string.full_screen_label));
button.setOnClickListener(v -> {
setCurrentOutputView(fullScreenView);
Assertions.checkNotNull(fullScreenView).setVisibility(View.VISIBLE);
});
} else if (i == 2) {
Button button = new Button(/* context= */
this);
view = button;
button.setText(getString(R.string.new_activity_label));
button.setOnClickListener(v -> startActivity(new Intent(MainActivity.this, MainActivity.class).putExtra(OWNER_EXTRA, /* value= */
false)));
} else {
SurfaceView surfaceView = new SurfaceView(this);
view = surfaceView;
attachSurfaceListener(surfaceView);
surfaceView.setOnClickListener(v -> {
setCurrentOutputView(surfaceView);
nonFullScreenView = surfaceView;
});
if (nonFullScreenView == null) {
nonFullScreenView = surfaceView;
}
}
gridLayout.addView(view);
GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams();
layoutParams.width = 0;
layoutParams.height = 0;
layoutParams.columnSpec = GridLayout.spec(i % 3, 1f);
layoutParams.rowSpec = GridLayout.spec(i / 3, 1f);
layoutParams.bottomMargin = 10;
layoutParams.leftMargin = 10;
layoutParams.topMargin = 10;
layoutParams.rightMargin = 10;
view.setLayoutParams(layoutParams);
}
}
use of com.google.android.exoplayer2.ui.PlayerControlView in project ExoPlayer by google.
the class MainActivity method onResume.
@Override
public void onResume() {
super.onResume();
if (isOwner && player == null) {
initializePlayer();
}
setCurrentOutputView(nonFullScreenView);
PlayerControlView playerControlView = Assertions.checkNotNull(this.playerControlView);
playerControlView.setPlayer(player);
playerControlView.show();
}
Aggregations