I have implemented Exoplayer in recyclerview. Every 3rd item in the recyclerview is the video view while others are just images.
What i needed is to play the videos automatically as the videos are muted. So there are chances to show 2 players at the same time, so i want to play 2 videos simultaneously if there are 2 video items are even half visible.
But the first video starts playing automatically and when user scrolls the 2nd video player become visible and starts playing, so the first video player stops or pauses the video.
Is there a way to play 2 videos at same time in Exoplayer ?
Here is my code used for the onBindViewHolder method.
public void bindVideo(ExoplyerViewHolder holder, String url) {
Uri videoUrl = Uri.parse(url);
MediaSource mediaSource = new ProgressiveMediaSource.Factory( new CacheDataSourceFactory(context, 100 * 1024 * 1024, 15 * 1024 * 1024))
.createMediaSource(videoUrl);
SimpleExoPlayer simpleExoPlayer = new SimpleExoPlayer.Builder(context).build();
simpleExoPlayer.setAudioAttributes(AudioAttributes.DEFAULT, true);
simpleExoPlayer.setPlayWhenReady(true);
simpleExoPlayer.setRepeatMode(Player.REPEAT_MODE_OFF);
simpleExoPlayer.setVolume(0);
simpleExoPlayer.prepare(mediaSource, true, true);
holder.playerView.setPlayer(simpleExoPlayer);
holder.playerView.setPlaybackPreparer(this);
holder.playerView.setUseController(false);
}