-->

MP4Parser Can we have Android MediaPlayer directly

2019-08-14 14:50发布

问题:

Lets say my I have my Mp4Parser Container java object and then instead of writing to a file and then supplying the URL of this file to the Android Media Player to play this video.

Container outMux = new DefaultMp4Builder().build(countVideo);
        FileOutputStream fos = new FileOutputStream(
                new File("outputFinalVideo.mp4"));
        outMux.writeContainer(fos.getChannel());
        fos.close();

In the above I am concatenating multiple videos and then Muxing with Audio and then I want this to be in memory and play directly in android media player or if there is any other way.

Can we write the object representation to Android media Player directly so android media player will be acting like a sink. Is that even possible ? or is there any better way to achieve playing this video all in memory ?

So it will be like all done in Memory rather than writing to a file as the sink and then supplying the file URL to the android media player.

import android.media.MediaPlayer;
public class MainActivity implements Activity{

    private MediaPlayer mediaPlayer; 
    //url is the url for the outputFinalVideo.mp4 after being generated
    mediaPlayer.setDataSource(getApplicationContext(), url);

.......

}

The video is 20 minute long I was able to do everything in memory in iOS using AVFoundation Framework.