I just began using VLCJ and had a quick question about how to get MediaDetails. My goal is to scan a folder of videos and get the MediaDetails for each file as efficiently as possible. Currently, I can't do that without displaying the video. I've been using a 75ms delay, grabbing the details, then killing the video, but this hardly seems like the ideal solution. According to the api: "The details are available after the video has started playing, regardless of whether nor not a video output has been created." How can I play the video without displaying it? It seems like even when I do the bare minimum to create the MediaPlayer and play the file, I still get visible video. Any suggestions would really be appreciated. I've included an example below:
Code: Select all
NativeLibrary.addSearchPath(
RuntimeUtil.getLibVlcLibraryName(), "C:/Program Files/VideoLAN/VLC");
Native.loadLibrary(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);
MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory();
MediaPlayer mediaPlayer = mediaPlayerFactory.newHeadlessMediaPlayer();
mediaPlayer.playMedia("C:\\Users\\Public\\Videos\\Sample Videos\\Wildlife.wmv");
try {
Thread.sleep(75);
} catch (InterruptedException e) {
LOGGER.error(String.format("ERROR: %s\n",e.getMessage()));
}
MediaMeta mediaMeta = mediaPlayer.getMediaMeta();
MediaDetails mediaDetails = mediaPlayer.getMediaDetails();
LOGGER.debug(String.format("MEDIA_META: %s\n",mediaMeta.toString()));
LOGGER.debug(String.format("MEDIA_PLAYER_LEN: %d\n",mediaPlayer.getLength()));
LOGGER.debug(String.format("MEDIA_DETAILS: %s\n",mediaDetails.toString()));
mediaPlayer.stop();