Search code examples
libvlcvlc-android

Setting dynamically program ID (sid) to LibVLC in Android


In my Android app, I use libvlc 3.1.1 to read DVB stream. So I build my LibVLC specifying arguments, I build the MediaPlayer and I build the Media from an URI corresponding to my DVB stream.

That is working. Now I would like to set the SID dynamically ("--program=769") after the creation of the VLCLib, to avoid the heavy library loading. Any idea ?

I read this documentation: https://wiki.videolan.org/Documentation:Advanced_Use_of_VLC/

    final ArrayList<String> args = new ArrayList<>();
    args.add("--video-filter=deinterlace");
    args.add("--aout=opensles");
    args.add("--deinterlace=-1");
    args.add("--sout-deinterlace-mode=bob");
    args.add("--vbi-opaque");
   // args.add("--program=769"); -> That is working
    mLibVLC = new LibVLC(this, args);
    mMediaPlayer = new MediaPlayer(mLibVLC);
    mMediaPlayer.setEventListener(event -> {
        ...
    }
    final IVLCVout vlcVout = mMediaPlayer.getVLCVout();
    vlcVout.setVideoView(mVideoSurface);
    vlcVout.setSubtitlesView(mSubtitlesSurface);
    mMediaPlayer.getVLCVout().attachViews(this);

    [...]

    if (mMediaPlayer.isPlaying()) {
        mMediaPlayer.stop();
    }
    final Media media = new Media(mLibVLC, uri);
   // There, I would like to set the SID(=program number)

    media.setHWDecoderEnabled(true, false);
    mMediaPlayer.setMedia(media);
    mMediaPlayer.play();
    media.release();

Solution

  • I think you can set it as a media option:

    media.addOption(":program=769");