Page 1 of 1

change video window position

Posted: 13 Nov 2014 02:43
by mquevedob
hi all,

i am using the example code for libVLC

#include <stdio.h>
#include <stdlib.h>
#include <vlc/vlc.h>

int main(int argc, char* argv[])
{
libvlc_instance_t * inst;
libvlc_media_player_t *mp;
libvlc_media_t *m;

/* Load the VLC engine */
inst = libvlc_new (0, NULL);

/* Create a new item */
m = libvlc_media_new_path (inst, "/usr/src/test.wmv");

/* Create a media player playing environement */
mp = libvlc_media_player_new_from_media (m);

/* No need to keep the media now */
libvlc_media_release (m);

/* play the media_player */
libvlc_media_player_play (mp);

while(1) sleep (10); /* Let it play a bit */

/* Stop playing */
libvlc_media_player_stop (mp);

/* Free the media_player */
libvlc_media_player_release (mp);

libvlc_release (inst);

return 0;
}

on a ubuntu server.

I can see a window is automatically created an the video is played on this window.

my question is:

is it possible to change the position of this window?

thanks in advance
Martin

Re: change video window position

Posted: 13 Nov 2014 08:21
by mquevedob
i added command line options --video-x and --video-y but they dont modify window position.

char const *vlc_argv[] =
{
"--video-x=100",
"--video-y=100",
"--no-embedded-video", "--no-video-deco",
};
int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);

/* Load the VLC engine */
inst = libvlc_new (vlc_argc, vlc_argv);

Re: change video window position

Posted: 13 Nov 2014 08:22
by RSATom
use libvlc_media_player_set_hwnd

Re: change video window position

Posted: 13 Nov 2014 08:49
by mquevedob
well I am on Ubuntu.

i think if i would use libvlc_media_player_set_xwindow I would need to setup the widget.
the example i am compiling does not use any widget ... so i was thinking if there is a way to move window position without widget...

Re: change video window position

Posted: 13 Nov 2014 08:53
by RSATom
Yes, with X11 you will need libvlc_media_player_set_xwindow

And I don't remember any function in libvlc API to move window if it created by libvlc itself...

Re: change video window position

Posted: 13 Nov 2014 09:04
by Rémi Denis-Courmont
There is no function to move the window in LibVLC; it wouldn't make much sense anyway xsince the video is most often either embedded or not shown.

Re: change video window position

Posted: 13 Nov 2014 09:45
by mquevedob
may I ask what the --video-x and --video-y parameters do ?
are they obsolete now ?

Re: change video window position

Posted: 13 Nov 2014 10:20
by Rémi Denis-Courmont
They set the requested window X and Y coordinates, which practically any window manager ignores and overrides.

Re: change video window position

Posted: 14 Nov 2014 17:12
by mquevedob
Hello guys!

i just wanted to post here how I made it work, for those out there who eventually need to change window position.

i found out that the window used by libvlc uses the libxcb library which is handled by modules/video_output/xcb/window.c

On line 343 of this file i added the following (right after the xcb_get_geometry call)

values[0] = cfg->x;
values[1] = cfg->y;
xcb_configure_window (conn, window,
XCB_CONFIG_WINDOW_X |
XCB_CONFIG_WINDOW_Y, values);

Also, some other modifications are required, since cfg->x and cfg->y are only enabled for APPLE.

on file src/video_output/video_output.c, comment the lines 172, and 175 like this

//#ifdef __APPLE__
.x = var_InheritInteger(vout, "video-x"),
.y = var_InheritInteger(vout, "video-y"),
//#endif

and on file include/vlc_vout_window.h lines 71 and 75 also comment them, like this

//#ifdef __APPLE__
/* Window position hint */
int x;
int y;
//#endif


Please also notice that on file "modules/video_output/xcb/window.c" on line 256 the function xcb_create_window_checked() also allows to set window position, but this seems to be ignored by the window manager.

Another thing that I tried and it didn't make the window move was putting the xcb_configure_window call right after the xcb_create_window_checked call. It only works if you put it after the xcb_map_window call (which shows the window on screen)

By the way,

this is how i call my libvlc_new function

char const *vlc_argv[] =
{
"-q",
"--video-x=123",
"--video-y=213",
"--no-embedded-video", "--no-video-deco",
"--no-audio",
};
int vlc_argc = sizeof(vlc_argv) / sizeof(*vlc_argv);

/* Load the VLC engine */
inst = libvlc_new (vlc_argc, vlc_argv);


Regards,
Martin

Re: change video window position

Posted: 19 Nov 2014 01:32
by tyana
Martin, isn't there an easier way to change the window position? All my videos open in the lower right of my screen, obscuring all the control functions (e.g., volume, pause). This occurred out of the blue -- or so it seemed -- because they had always opened in the center of the screen and all control functions were visible. I must have inadvertently clicked on something, but I have no idea what that could have been. I've tried different settings in "Preferences" and "Customize Interface," but nothing has worked. And it won't allow moving the window using the cursor arrow. I'd sure appreciate knowing if there's an easy fix.

Re: change video window position

Posted: 05 Dec 2014 01:45
by mquevedob
hello tyana,

I really dont know about the VLC application. I was explaining my case on using libVLC with a custom player application.

sorry I cant help further.

regards,
Martin