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

For questions and discussion that is NOT (I repeat NOT) specific to a certain Operating System.
MarceloAmaral_Usp
New Cone
New Cone
Posts: 4
Joined: 17 Feb 2009 15:51

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

Postby MarceloAmaral_Usp » 17 Feb 2009 17:55

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

}

MarceloAmaral_Usp
New Cone
New Cone
Posts: 4
Joined: 17 Feb 2009 15:51

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

Postby MarceloAmaral_Usp » 03 Mar 2009 18:12

Someone try fix this?

n1kolaus
New Cone
New Cone
Posts: 7
Joined: 26 Feb 2009 20:51

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

Postby n1kolaus » 13 Mar 2009 00:47

got the same issue here...any solutions for this now?

MarceloAmaral_Usp
New Cone
New Cone
Posts: 4
Joined: 17 Feb 2009 15:51

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

Postby MarceloAmaral_Usp » 13 Mar 2009 13:31

Sorry not yet!
Do you do the some things and has the same problems?
Or there are a different thing?
Tanks

n1kolaus
New Cone
New Cone
Posts: 7
Joined: 26 Feb 2009 20:51

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

Postby n1kolaus » 13 Mar 2009 22:02

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??

Rémi Denis-Courmont
Developer
Developer
Posts: 15133
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

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

Postby Rémi Denis-Courmont » 14 Mar 2009 15:54

You must set the parent BEFORE you start playback. It does work fine (at least with the browser plugins).
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

n1kolaus
New Cone
New Cone
Posts: 7
Joined: 26 Feb 2009 20:51

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

Postby n1kolaus » 16 Mar 2009 22:57

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!

Rémi Denis-Courmont
Developer
Developer
Posts: 15133
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

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

Postby Rémi Denis-Courmont » 17 Mar 2009 19:37

Before starting the playback... but I'm not using JVLC.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

n1kolaus
New Cone
New Cone
Posts: 7
Joined: 26 Feb 2009 20:51

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

Postby n1kolaus » 23 Mar 2009 16:19

ok great...thanks for ur detailed answer :)

catchmartin
New Cone
New Cone
Posts: 2
Joined: 24 Mar 2009 19:35

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

Postby catchmartin » 26 Mar 2009 19:08

Any progress here? I'm caught with the same problem.

n1kolaus
New Cone
New Cone
Posts: 7
Joined: 26 Feb 2009 20:51

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

Postby n1kolaus » 03 Apr 2009 11:59

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

quorthon
Blank Cone
Blank Cone
Posts: 28
Joined: 22 Mar 2009 17:32

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

Postby quorthon » 17 May 2009 22:03

Could you solve this problem? I have a similar problem:
viewtopic.php?f=32&t=59426

Thanks for you help.
Peter

Gawain
Blank Cone
Blank Cone
Posts: 31
Joined: 08 Jan 2009 11:38
VLC version: 0.9.8a - 1.0.0
Operating System: Windows XP

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

Postby Gawain » 29 Jun 2009 12:09

Has anyone figured out how to put the video in a different Canvas?

MarceloAmaral_Usp
New Cone
New Cone
Posts: 4
Joined: 17 Feb 2009 15:51

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

Postby MarceloAmaral_Usp » 29 Jun 2009 12:51

still no solution for this....sorry!

Gawain
Blank Cone
Blank Cone
Posts: 31
Joined: 08 Jan 2009 11:38
VLC version: 0.9.8a - 1.0.0
Operating System: Windows XP

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

Postby Gawain » 22 Jul 2009 17:36

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!

syuki
New Cone
New Cone
Posts: 2
Joined: 30 Sep 2009 05:32

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

Postby syuki » 30 Sep 2009 05:38

same problem, too. :cry:

syuki
New Cone
New Cone
Posts: 2
Joined: 30 Sep 2009 05:32

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

Postby syuki » 01 Oct 2009 03:05

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.

M0Vi3Fr3ak
New Cone
New Cone
Posts: 6
Joined: 04 Dec 2008 00:10

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

Postby M0Vi3Fr3ak » 06 Oct 2009 17:38

Thx works greate:) *thumb up*

Gawain
Blank Cone
Blank Cone
Posts: 31
Joined: 08 Jan 2009 11:38
VLC version: 0.9.8a - 1.0.0
Operating System: Windows XP

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

Postby Gawain » 06 Oct 2009 18:22

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!

M0Vi3Fr3ak
New Cone
New Cone
Posts: 6
Joined: 04 Dec 2008 00:10

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

Postby M0Vi3Fr3ak » 06 Oct 2009 18:28


Gawain
Blank Cone
Blank Cone
Posts: 31
Joined: 08 Jan 2009 11:38
VLC version: 0.9.8a - 1.0.0
Operating System: Windows XP

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

Postby Gawain » 06 Oct 2009 18:52

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.

M0Vi3Fr3ak
New Cone
New Cone
Posts: 6
Joined: 04 Dec 2008 00:10

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

Postby M0Vi3Fr3ak » 06 Oct 2009 19:07

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/

Gawain
Blank Cone
Blank Cone
Posts: 31
Joined: 08 Jan 2009 11:38
VLC version: 0.9.8a - 1.0.0
Operating System: Windows XP

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

Postby Gawain » 07 Oct 2009 12:14

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?

M0Vi3Fr3ak
New Cone
New Cone
Posts: 6
Joined: 04 Dec 2008 00:10

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

Postby M0Vi3Fr3ak » 07 Oct 2009 17:24

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

Gawain
Blank Cone
Blank Cone
Posts: 31
Joined: 08 Jan 2009 11:38
VLC version: 0.9.8a - 1.0.0
Operating System: Windows XP

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

Postby Gawain » 08 Oct 2009 15:37

thanks! Now everything works just fine.


Return to “General VLC media player Troubleshooting”

Who is online

Users browsing this forum: No registered users and 17 guests