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());