google / google/ExoPlayer

How to show multiple playerViews simultaneously with one simpleExoPlayer instance?

Open
#9,567 3 comments 0 reactions 1 assignee Claimed by @claincly View on GitHub
question
Dominant language
Java
Stars
21.9k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

I am developing a video streaming app with android.

And I found some problem while developing using exoplayer2.

I want to show multiple playerViews simultaneously with one simpleExoPlayer instance

But I couldn't assign the same simpleExoPlayer instance to multiple playerViews.

How to show multiple playerViews simultaneously with one simpleExoPlayer instance?

Below is the code I wrote.

playerView = findViewById(R.id.player_view);
playerViewL = findViewById(R.id.player_viewL);
playerViewR = findViewById(R.id.player_viewR);
// exoPlayer = new ExoPlayer().
simpleExoPlayer1 = new SimpleExoPlayer.Builder(this).build();
simpleExoPlayer2 = new SimpleExoPlayer.Builder(this).build();
simpleExoPlayer3 = new SimpleExoPlayer.Builder(this).build();
playerView.setPlayer(simpleExoPlayer1); // PlayerView cannot play video by simpleExoPlayer1, I want to play both (and all after)
playerViewL.setPlayer(simpleExoPlayer2); // PlayerView can play video by simpleExoPlayer2
playerViewR.setPlayer(simpleExoPlayer1); // PlayerView only can play video by simpleExoPlayer1
simpleExoPlayer1.setRepeatMode(simpleExoPlayer1.REPEAT_MODE_ALL);
simpleExoPlayer2.setRepeatMode(simpleExoPlayer2.REPEAT_MODE_ALL);
simpleExoPlayer3.setRepeatMode(simpleExoPlayer3.REPEAT_MODE_ALL);

I hope you have a simple way.

thank you

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.