My problem is similar to this one, but there was no correct answer, so I thought I give it a go.
In my application I've got two video players (TextureView
+ MediaPlayer
- based on VideoView
) playing from URL side by side on one screen. I got it working quite right. As I need then them to play simultaneously I synced their controllers, to when I start one of them the second starts too (the same with pausing, seeking, buffering, etc).
videoView1.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
mp.setVolume(0.0f, 0.0f);
firstVideoPrepared = true;
tryStart();
}
});
videoView2.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
secondVideoPrepared = true;
tryStart();
}
});
private void tryStart() {
// here is also buffered data level check
if (firstVideoPrepared && secondVideoPrepared) {
videoView1.start();
videoView2.start();
}
}
The problem is that despite pausing both videos for buffering, when I start()
them they sometimes get out of sync. Let's say that there is the same video in both players- I need them to be sync almost ideally as I can see any difference. Is there any way to keep them synced so precisely?
I've read about libraries like ExoPlayer, FFMPEGMediaPlayer or MediaPalyer-Extended but none of them seems to have what I need.
Is it even possible to keep that accuracy of videos sync?