Search in sources :

Example 1 with PlayerControlView

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));
        }
    });
}
Also used : PlayerControlView(com.google.android.exoplayer2.ui.PlayerControlView)

Example 2 with PlayerControlView

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);
    }
}
Also used : Util(com.google.android.exoplayer2.util.Util) PlayerControlView(com.google.android.exoplayer2.ui.PlayerControlView) Bundle(android.os.Bundle) SurfaceView(android.view.SurfaceView) FrameworkMediaDrm(com.google.android.exoplayer2.drm.FrameworkMediaDrm) ProgressiveMediaSource(com.google.android.exoplayer2.source.ProgressiveMediaSource) Uri(android.net.Uri) Intent(android.content.Intent) Player(com.google.android.exoplayer2.Player) DashMediaSource(com.google.android.exoplayer2.source.dash.DashMediaSource) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) DefaultDataSource(com.google.android.exoplayer2.upstream.DefaultDataSource) View(android.view.View) Button(android.widget.Button) SurfaceHolder(android.view.SurfaceHolder) MediaSource(com.google.android.exoplayer2.source.MediaSource) GridLayout(android.widget.GridLayout) C(com.google.android.exoplayer2.C) DefaultDrmSessionManager(com.google.android.exoplayer2.drm.DefaultDrmSessionManager) MediaItem(com.google.android.exoplayer2.MediaItem) HttpMediaDrmCallback(com.google.android.exoplayer2.drm.HttpMediaDrmCallback) Surface(android.view.Surface) UUID(java.util.UUID) HttpDataSource(com.google.android.exoplayer2.upstream.HttpDataSource) DataSource(com.google.android.exoplayer2.upstream.DataSource) DefaultHttpDataSource(com.google.android.exoplayer2.upstream.DefaultHttpDataSource) Nullable(androidx.annotation.Nullable) SurfaceControl(android.view.SurfaceControl) DrmSessionManager(com.google.android.exoplayer2.drm.DrmSessionManager) Activity(android.app.Activity) Assertions(com.google.android.exoplayer2.util.Assertions) GridLayout(android.widget.GridLayout) Button(android.widget.Button) Intent(android.content.Intent) PlayerControlView(com.google.android.exoplayer2.ui.PlayerControlView) SurfaceView(android.view.SurfaceView) View(android.view.View) SurfaceView(android.view.SurfaceView)

Example 3 with PlayerControlView

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();
}
Also used : PlayerControlView(com.google.android.exoplayer2.ui.PlayerControlView)

Aggregations

PlayerControlView (com.google.android.exoplayer2.ui.PlayerControlView)3 Activity (android.app.Activity)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 Surface (android.view.Surface)1 SurfaceControl (android.view.SurfaceControl)1 SurfaceHolder (android.view.SurfaceHolder)1 SurfaceView (android.view.SurfaceView)1 View (android.view.View)1 Button (android.widget.Button)1 GridLayout (android.widget.GridLayout)1 Nullable (androidx.annotation.Nullable)1 C (com.google.android.exoplayer2.C)1 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)1 MediaItem (com.google.android.exoplayer2.MediaItem)1 Player (com.google.android.exoplayer2.Player)1 DefaultDrmSessionManager (com.google.android.exoplayer2.drm.DefaultDrmSessionManager)1 DrmSessionManager (com.google.android.exoplayer2.drm.DrmSessionManager)1 FrameworkMediaDrm (com.google.android.exoplayer2.drm.FrameworkMediaDrm)1