Page 1 of 1

jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 17 Feb 2009 17:55
by MarceloAmaral_Usp
I try to do a application with VLC 1.0.0 git, i want put the video output of vlc in a canvas component in JPanel.
There are 2 ways to do this.
The first form is use the method reparent(MediaPlayer, Canvas) of class Video, but this method still not working, but there is a ticket to solve this problem.

The second form is use the method setVideoOutput(Canvas) of class JVLC, but this method not working too, that crash the JMV, there are same problem in the code of C in libxvideo_plugin.so. But i'm not sure!

I'm going to show my example code and please someone help me! :-|

Excuse me for my English!

public class TesteJvlc {

public static void main(String[] args) {
// TODO Auto-generated method stub
java.awt.GridBagConstraints gridBagConstraints;
JVLC jvlc;
Video video;
MediaPlayer mp;
MediaDescriptor ds;
Canvas jvcanvas;
JPanel jvcc;

jvlc = new JVLC(" --vvv");
ds = new MediaDescriptor(jvlc, "Elephants.avi");
mp = ds.getMediaPlayer();
video = new Video(jvlc);

//Canvas
GraphicsEnvironment graphEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice graphDevice = graphEnv.getDefaultScreenDevice();
GraphicsConfiguration graphicConf = graphDevice.getDefaultConfiguration();

jvcanvas = new java.awt.Canvas(graphicConf);
jvcanvas.setBackground(Color.black);
jvcanvas.setSize(800,600);
jvcanvas.invalidate();
jvcanvas.setVisible(true);

//Panel
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.CENTER;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
jvcc = new JPanel(true);
jvcc.setLayout(new java.awt.GridBagLayout());
jvcc.setSize(jvcanvas.getWidth()+30, jvcanvas.getHeight()+50);
jvcc.add(jvcanvas, gridBagConstraints);

//Frame
JFrame frame = new JFrame("VLC");
frame.setBounds(0, 0,jvcc.getWidth(),jvcc.getHeight());
frame.setPreferredSize(new Dimension(jvcc.getWidth(), jvcc.getHeight()));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Container cner = frame.getContentPane();
cner.setLayout(new BoxLayout(cner, BoxLayout.Y_AXIS));

frame.setLayout(new FlowLayout());
frame.setLayout(new java.awt.GridBagLayout());

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.CENTER;
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
cner.add(jvcc, gridBagConstraints);

frame.pack();
frame.addWindowListener(new WindowAdapter()
{

@Override
public void windowClosing(WindowEvent ev)
{
System.exit(0);
}
});
frame.setVisible(true);

jvcanvas.addNotify();
jvcanvas.requestFocus();
jvcanvas.createBufferStrategy(2);

//video.reparent(mp, jvcanvas); //first way

jvlc.setVideoOutput(jvcanvas); //second way

mp.play();
}

}

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 03 Mar 2009 18:12
by MarceloAmaral_Usp
Someone try fix this?

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 13 Mar 2009 00:47
by n1kolaus
got the same issue here...any solutions for this now?

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 13 Mar 2009 13:31
by MarceloAmaral_Usp
Sorry not yet!
Do you do the some things and has the same problems?
Or there are a different thing?
Tanks

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 13 Mar 2009 22:02
by n1kolaus
Hi

Yes I tried both methods, while setVideoOutput(Canvas) just delegates the call to the reparent() method..
I also looked into the vlc code which receives the drawable parameter..it looked somekind of "unfinished" for me, showing you the following lines:

Code: Select all

/* Deprecated use libvlc_media_player_set_drawable() */ void libvlc_video_set_parent( libvlc_instance_t *p_instance, libvlc_drawable_t d, libvlc_exception_t *p_e ) { /* set as default for future vout instances */ #ifdef WIN32 vlc_value_t val; if( sizeof(HWND) > sizeof(libvlc_drawable_t) ) return; /* BOOM! we told you not to use this function! */ val.p_address = (void *)(uintptr_t)d; var_Set( p_instance->p_libvlc_int, "drawable-hwnd", val ); #else var_SetInteger( p_instance->p_libvlc_int, "drawable-xid", d ); #endif libvlc_media_player_t *p_mi = libvlc_playlist_get_media_player(p_instance, p_e); if( p_mi ) { libvlc_media_player_set_drawable( p_mi, d, p_e ); libvlc_media_player_release(p_mi); } }
I also commented out the 2 lines with the strange "BOOM-comment"...recompilied it and run...no success..
Also tried out many different ways of creating a and setting canvas to jvlc...
but the video window always appears in a new window :(

somebody existing who was successfully playing a video in a canvas??

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 14 Mar 2009 15:54
by Rémi Denis-Courmont
You must set the parent BEFORE you start playback. It does work fine (at least with the browser plugins).

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 16 Mar 2009 22:57
by n1kolaus
Hello Rémi!

What do you exactly mean with "BEFORE playback".
Of course I set the canvas before starting playing a video..if you mean that?
I also tried setting it in several positions...directly after creating a jvlc instance, after creating an audio instance, after creating an video instance etc..doesn't work.
So please, where exactly did you place your call?

Also I didn't understand what you ment with "at least with the browser plugins"..?

thanks and greetings!

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 17 Mar 2009 19:37
by Rémi Denis-Courmont
Before starting the playback... but I'm not using JVLC.

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 23 Mar 2009 16:19
by n1kolaus
ok great...thanks for ur detailed answer :)

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 26 Mar 2009 19:08
by catchmartin
Any progress here? I'm caught with the same problem.

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 03 Apr 2009 11:59
by n1kolaus
still no solution for this...trying out an example whcih was using the deprecated playlist classes...embedding a video in a canvas worked fine there!
but unfortunately, these classes are deprecated...and also i wasnt able to control the audio/video instances of the playing video while using the playlist class.. :-(

damn it, please help somebody...i searched through the vlc code but that didn't help though..hmpf

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 17 May 2009 22:03
by quorthon
Could you solve this problem? I have a similar problem:
viewtopic.php?f=32&t=59426

Thanks for you help.
Peter

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 29 Jun 2009 12:09
by Gawain
Has anyone figured out how to put the video in a different Canvas?

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 29 Jun 2009 12:51
by MarceloAmaral_Usp
still no solution for this....sorry!

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 22 Jul 2009 17:36
by Gawain
is anyone working on that problem? Is it going to work soon?
If not it would be interessting to know how to reference the opening window (title: VLC (hardware YUV overlay DirectX output)) to get for example the size position and change the title ans the TitleBar-Icon.

Thanks for helping!

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 30 Sep 2009 05:38
by syuki
same problem, too. :cry:

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 01 Oct 2009 03:05
by syuki
Since Playlist works fine and MediaList or MediaListPlayer doesn't, I figure out maybe the only solution is to rewrite JVLC source. And I made it. Here is how:
1. in setVideoOutput(Canvas)@JVLC.java, change drawable into a field and let JVLC remeber it.

Code: Select all

this.drawable = Native.getComponentID(canvas);
2. in play()@MediaPlayer.java, let the instance set drawable itself.

Code: Select all

public void play() { int drawable = (int) jvlc.getVideoHandle(); libvlc_exception_t exception = new libvlc_exception_t(); if (drawable > 0) { // IMPORTANT! this is the exact method that EMBEDs the canvas for us libvlc.libvlc_media_player_set_drawable(instance, drawable, exception); } libvlc.libvlc_media_player_play(instance, exception); }
3. This thus requires the caller of MediaPlayer set JVLC instance into it in advance. So setJVLC(JVLC jvlc) in MediaPlayer is required, too.

Code: Select all

public void setJVLC(JVLC jvlc) { this.jvlc = jvlc; }
I succeed in embedding the canvas into a JFrame with above codes. Wish they are helpful.

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 06 Oct 2009 17:38
by M0Vi3Fr3ak
Thx works greate:) *thumb up*

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 06 Oct 2009 18:22
by Gawain
can someone please create a new snapshot-JAR with that bugfix? That would be amazing, because I've never done this before...Thanks a lot!

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 06 Oct 2009 18:28
by M0Vi3Fr3ak

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 06 Oct 2009 18:52
by Gawain
unfortunately it's not working. the following exception, when I init my JVLC object:

Code: Select all

jvlc = new JVLC(JVLC_PARAMS);
To help you, we need messages, to completely understand what your problems is.
To fix this, please be sure before you start the playback to:
  1. Open: Tools -> Messages.
  2. Set Verbosity to 2
  3. Start playback to reproduce your issue
  4. Save text in a file or copy into clipboard
  5. Then paste the full resulting log here between [​code]and[​/code] (or use Pastebin.com if it's too long)
Also don't forget to name your Operating System and provide the VLC media player version.

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 06 Oct 2009 19:07
by M0Vi3Fr3ak
jna lib is not in the jar file. you must download jna.jar and put it to the class path.
https://jna.dev.java.net/

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 07 Oct 2009 12:14
by Gawain
thanks, now I can start my app, but still get a exception after starting to play my movie with:

Code: Select all

MediaPlayer.play();
java.lang.NullPointerException
at org.videolan.jvlc.MediaPlayer.play(MediaPlayer.java:82)


any ideas?

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 07 Oct 2009 17:24
by M0Vi3Fr3ak
Yes i added a new method "setJVLC" from syuki

JVLC jvlc = new JVLC(vlcArguments);
MediaList medialist = new MediaList(jvlc);
jvlc.setLogVerbosity(LoggerVerbosityLevel.ERROR);

//mediendiscriptor
mediaDescriptor = new MediaDescriptor(jvlc, source);
medialist.addMedia(mediaDescriptor);

//get mediaplayer
player = new MediaPlayer(mediaDescriptor);
player.setJVLC(jvlc);

Add the jvlc object with setJVLC to your MediaPlayer object and all works :D

Re: jVLC 1.0.0git don't video output in a diferent canvas place

Posted: 08 Oct 2009 15:37
by Gawain
thanks! Now everything works just fine.