Search code examples
androidlibvlc

LibVlc Disable subtitle track


I would like to disable a subtitle track in LibVlc. This is how I set one:

vlcPlayer.setSpuTrack(id);

I already tried setting the id to -1 and a high value like 99 but the subtitle track was still there.

I've read about the command

--no-spu

but I don't know how to enter a command into my LibVlc instance.

Thanks


Solution

  • I am up to solving the same issue. setSpuTrack(-1) works but only if its called after MediaPlayer.Event.Playing event has been received. If you find a better solution to this issue please share it with me.

    Ive just found better way to disable subtitles. You need to use Media.addOption method to add --sub-track-id=<integer> option. Unfortunately it wont work if you use it with -1 so i use it with Integer.MAX_VALUE

    final Media media = new Media(mLibVLC, uri);
    final String subtitleTrackOption = MessageFormat.format(":sub-track-id={0}", String.valueOf(Integer.MAX_VALUE));
    media.addOption(subtitleTrackOption);
    mMediaPlayer.setMedia(media);
    

    You can see more on how ive done this here