Exoplayer 2.12, dose not load local subtitles

688 views Asked by At

Even after going through many questions on Stackoverflow and other threads we could not find any solution for the subtitle issue in Exoplayer.

Following is the code snippet we are using to load video and subtitle from local storage.

public void setVideo(String absolutePath, String vtt){
    player = new SimpleExoPlayer.Builder(this).build();
    videoView.setPlayer(player);
  //  MediaItem mediaItem = MediaItem.fromUri(absolutePath);
    MediaItem.Subtitle subtitle = new MediaItem.Subtitle(Uri.parse(vtt),MimeTypes.TEXT_VTT,"en-US");
    List<MediaItem.Subtitle> subtitleList = new ArrayList<>();
    subtitleList.add(subtitle);


    videoView.setShowSubtitleButton(true);
    MediaItem mediaItem = new MediaItem.Builder()
            .setUri(absolutePath)
            .setDrmUuid(C.WIDEVINE_UUID)
            .setDrmMultiSession(true)
            .setSubtitles(subtitleList)
            .build();
    player.setMediaItem(mediaItem);
    player.setPlayWhenReady(true);
    player.prepare();

}

Here absolutePath is path to the video and vtt is the path to .srt subtitle file. We would really appreciate any suggestions or alternative way to achieve this.

0

There are 0 answers