Java Code Examples for com.google.android.exoplayer2.Player#VideoComponent

The following examples show how to use com.google.android.exoplayer2.Player#VideoComponent . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PlayerSurfaceHolder.java    From no-player with Apache License 2.0 5 votes vote down vote up
public void attach(Player.VideoComponent videoPlayer) {
    if (containsSurfaceView()) {
        videoPlayer.setVideoSurfaceView(surfaceView);
    } else if (containsTextureView()) {
        videoPlayer.setVideoTextureView(textureView);
    } else {
        throw new IllegalArgumentException("Surface container does not contain any of the expected views");
    }
}
 
Example 2
Source File: CustomizePlayerView.java    From bcm-android with GNU General Public License v3.0 4 votes vote down vote up
public void setPlayer(Player player) {
    if (this.player == player) {
        return;
    }
    if (this.player != null) {
        this.player.removeListener(componentListener);
        Player.VideoComponent oldVideoComponent = this.player.getVideoComponent();
        if (oldVideoComponent != null) {
            oldVideoComponent.removeVideoListener(componentListener);
            if (surfaceView instanceof TextureView) {
                oldVideoComponent.clearVideoTextureView((TextureView) surfaceView);
            } else if (surfaceView instanceof SurfaceView) {
                oldVideoComponent.clearVideoSurfaceView((SurfaceView) surfaceView);
            }
        }
        Player.TextComponent oldTextComponent = this.player.getTextComponent();
        if (oldTextComponent != null) {
            oldTextComponent.removeTextOutput(componentListener);
        }
    }
    this.player = player;
    if (useController) {
        controller.setPlayer(player);
    }
    if (subtitleView != null) {
        subtitleView.setCues(null);
    }
    updateBuffering();
    updateErrorMessage();
    updateForCurrentTrackSelections(/* isNewPlayer= */ true);
    if (player != null) {
        Player.VideoComponent newVideoComponent = player.getVideoComponent();
        if (newVideoComponent != null) {
            if (surfaceView instanceof TextureView) {
                newVideoComponent.setVideoTextureView((TextureView) surfaceView);
            } else if (surfaceView instanceof SurfaceView) {
                newVideoComponent.setVideoSurfaceView((SurfaceView) surfaceView);
            }
            newVideoComponent.addVideoListener(componentListener);
        }
        Player.TextComponent newTextComponent = player.getTextComponent();
        if (newTextComponent != null) {
            newTextComponent.addTextOutput(componentListener);
        }
        player.addListener(componentListener);
        maybeShowController(false);
    } else {
        hideController();
    }
}