Accessing Media-Information (with VLCJ)

This forum is about all development around libVLC.
FlavorFlav
New Cone
New Cone
Posts: 7
Joined: 09 Dec 2010 11:55

Accessing Media-Information (with VLCJ)

Postby FlavorFlav » 30 Oct 2020 12:23

Hi,
first question: I am using VLCJ. Is this general videolan forum suitable for specific questions for VLCJ or is there maybe a better forum/community?

My question:
I am using libVLC (with VLCJ wrapper) to read out media information (like length, resolution, codec and so on). My problem is: What is the best way to access these information? I didn't really found a way in VLCJ do get these information directly. My current approach is, to start playing the video and grab these media information (like mediaPlayer.media().info().videoTracks());). It looks like these media finfos get loaded sometie during the playback. My problem is: How do I know when these informations are available?

Code: Select all

mediaPlayer.events().addMediaPlayerEventListener(new MediaPlayerEventAdapter() { @Override public void mediaPlayerReady(MediaPlayer mediaPlayer) { if (isMediaInfoReady()) { System.out.println("mediaPlayerReady"); MediaUtil.showMediaInfo(mediaPlayer); readMediaInfo(); } } @Override public void playing(MediaPlayer mediaPlayer) { if (isMediaInfoReady()) { System.out.println("playing"); MediaUtil.showMediaInfo(mediaPlayer); readMediaInfo(); } } @Override public void positionChanged(MediaPlayer mediaPlayer, float newPosition) { if (isMediaInfoReady()) { System.out.println("positionChanged"); MediaUtil.showMediaInfo(mediaPlayer); readMediaInfo(); } } @Override public void videoOutput(MediaPlayer mediaPlayer, int newCount) { if (isMediaInfoReady()) { System.out.println("videoOutput"); MediaUtil.showMediaInfo(mediaPlayer); readMediaInfo(); } } private boolean isMediaInfoReady() { if (mediaPlayer.media().info().videoTracks().size()==1) { if (mediaPlayer.media().info().videoTracks().get(0).width()>0) { return true; } } return false; } }); mediaPlayer.media().start(mediaTitle.getMedium().getPath());
At the moment I am asking like brute force on several media player events if the resolution information is loaded. This feels really clumsy, error-prone and cumbersome. Anyone knows a better approach?

mfkl
Developer
Developer
Posts: 739
Joined: 13 Jun 2017 10:41

Re: Accessing Media-Information (with VLCJ)

Postby mfkl » 02 Nov 2020 04:05

Is this general videolan forum suitable for specific questions for VLCJ or is there maybe a better forum/community?
the LibVLC community discord server would be a better place, especially for VLCJ related questions, as the maintainer hangs out there. https://discord.gg/3h3K3JF

You need to parse the media to be able to access its information. See https://github.com/caprica/vlcj-example ... oTest.java
https://mfkl.github.io


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 27 guests