Search code examples
vlcj

MediaList play items with run time option


I use the MediaList to play some movies and streams in a list.

String[] paths = { "\tmp\movie1.mp4", "\tmp\movie2.mp4", "http://stream.mp4" };
String[] options = { "--run-time=2", "--run-time=5", "--run-time=10" };

The initialization of the media list is as follows

mediaListPlayer = factory.newMediaListPlayer();                    
mediaListPlayer.setMediaPlayer(mediaPlayer);

MediaList mediaList = factory.newMediaList();                    
for ( int i = 0; i < paths.length; i++ ) 
{
    if ( options[i].length() > 0 )
    {
        mediaList.addMedia(paths[i], options[i]);
    }
    else
    {
         mediaList.addMedia(paths[i]);                            
    }
}
mediaListPlayer.setMediaList(mediaList);
mediaListPlayer.setMode(MediaListPlayerMode.LOOP);
mediaListPlayer.play();

The media list player ignores the optons. What is wrong with the code? Any help is welcome, thanks


Solution

  • The syntax for the options is not obvious, this works:

    :start-time=30
    :run-time=5
    

    The above options would start at 30 seconds, (you can use e.g. 30.5 for fractions of a second), and run for 5 seconds.

    So replace your "--run-time=5" with ":run-time=5".