Android video Player for video streaming (currently using ExoPlayer )

2.6k views Asked by At

In android application I am showing videos using ExoPlayer , I am facing memory issues and slow video rendering, if there is any alternative android native video player please suggest.

Thanks in advance

2

There are 2 answers

0
yakobom On

You did not specify any special requirements - have you tried MediaPlayer? I had good experience with it.

0
Ankit Lathiya On

You can use below code to play .m3u8 file before initializing your exoplayer:-

Handler mHandler = new Handler();

String userAgent = Util.getUserAgent(context, "APPLICATION_NAME");

DataSource.Factory dataSourceFactory = new DefaultHttpDataSourceFactory(
                userAgent, null,
                DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
                1800000,
                true);

HlsMediaSource mediaSource = new HlsMediaSource(Uri.parse(mediaUrl),dataSourceFactory, 1800000,mHandler, null);

if (mediaUrl != null) {
    videoPlayer.prepare(mediaSource);
    videoPlayer.setPlayWhenReady(true);
}