My sync issues with Android MediaPlayer

I have a simple Android multimedia player that can play multiple videos simultaneously on one screen. Thus, basically one screen of the media player is divided into 4 parts, with a copy of 4 glued together mediaPlayer, and each part plays this video.

It works almost normally when my video files are stored locally on the device. There are synchronization problems, but minor ones. But when I entered the URL for HTTP streaming, there are significant synchronization issues. What is the problem? How can I remove synchronization problems?

The only thing I could do was create media planners and prepare()them first, then call them start()one by one, so that at least the start time would be close to eachother. This does not have much effect.

Here I have a method that returns each of the instances mediaPlayer:

MediaPlayer mediaPreparation(String filename, boolean setMute) {
    String url = "myURL"; // your URL here
    // create mediaplayer instance
    MediaPlayer mediaPlayer = new MediaPlayer();
    if (setMute) {
        mediaPlayer.setVolume(0, 0);
    }
    try {

        mediaPlayer.setDataSource(url);
        mediaPlayer.prepare();

    } catch (IOException e) {
    }

    mediaPlayer.setLooping(true);
    // mediaPlayer.start();
    return mediaPlayer;
}

And then I start them one by one:

mp[0].start();
mp[1].start();
mp[2].start();
mp[3].start();

enter image description here

+4
source share
2 answers

I'm not sure if any Android player for Android offers this feature.

, , HW , SW .., .

, - .

, , MediaCodec HW - , .

, - , , ( ), , . , , , . , -, HW - . Intel, ​​:

, , - , - , , - .

+1

, , . . , , . . https://developer.android.com/reference/android/media/MediaCodec.html.

, , releaseOutputBuffer() . ( , , ). , 4 , .

+1

Source: https://habr.com/ru/post/1649229/


All Articles