i am working on a project where i should play .srt files along with video in android. I was working through the samples of Exoplayer but cant able to play .srt files with vi
PopupMenu popup = new PopupMenu(getContext(), v);
popup.getMenuInflater().inflate(R.menu.subtile_menu, popup.getMenu());
popup.setOnMenuItemClickListener(item -> {
if (item.getItemId()==R.id.remove_subtitle){
//player.prepare(videoSource);
player.prepare(videoSource, false, false);
}else if (item.getItemId()==R.id.english){
if (caption){
Format textFormat = Format.createTextSampleFormat(null, MimeTypes.APPLICATION_SUBRIP,
null, Format.NO_VALUE, Format.NO_VALUE, "en", null, Format.OFFSET_SAMPLE_RELATIVE);
MediaSource textMediaSource = new SingleSampleMediaSource.Factory(dataSourceFactory)
.createMediaSource(Uri.parse(sub_url), textFormat, C.TIME_UNSET);
MergingMediaSource mediaSource = new MergingMediaSource(videoSource, textMediaSource);
player.prepare(mediaSource, false, false);
}else {
Toast.makeText(getContext(), "Subtitle not available", Toast.LENGTH_SHORT).show();
}
}
return true;
});
popup.show();