change video window position

This forum is about all development around libVLC.
mquevedob
New Cone
New Cone
Posts: 8
Joined: 13 Nov 2014 02:32

change video window position

Postby mquevedob » 13 Nov 2014 02:43

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

mquevedob
New Cone
New Cone
Posts: 8
Joined: 13 Nov 2014 02:32

Re: change video window position

Postby mquevedob » 13 Nov 2014 08:21

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

RSATom
Big Cone-huna
Big Cone-huna
Posts: 513
Joined: 24 Nov 2011 06:55
Operating System: Windows/Linux/OsX
Location: Russia, Tomsk

Re: change video window position

Postby RSATom » 13 Nov 2014 08:22

use libvlc_media_player_set_hwnd

mquevedob
New Cone
New Cone
Posts: 8
Joined: 13 Nov 2014 02:32

Re: change video window position

Postby mquevedob » 13 Nov 2014 08:49

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

RSATom
Big Cone-huna
Big Cone-huna
Posts: 513
Joined: 24 Nov 2011 06:55
Operating System: Windows/Linux/OsX
Location: Russia, Tomsk

Re: change video window position

Postby RSATom » 13 Nov 2014 08:53

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

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

Re: change video window position

Postby Rémi Denis-Courmont » 13 Nov 2014 09:04

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.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

mquevedob
New Cone
New Cone
Posts: 8
Joined: 13 Nov 2014 02:32

Re: change video window position

Postby mquevedob » 13 Nov 2014 09:45

may I ask what the --video-x and --video-y parameters do ?
are they obsolete now ?

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

Re: change video window position

Postby Rémi Denis-Courmont » 13 Nov 2014 10:20

They set the requested window X and Y coordinates, which practically any window manager ignores and overrides.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

mquevedob
New Cone
New Cone
Posts: 8
Joined: 13 Nov 2014 02:32

Re: change video window position

Postby mquevedob » 14 Nov 2014 17:12

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

tyana
New Cone
New Cone
Posts: 1
Joined: 19 Nov 2014 01:06

Re: change video window position

Postby tyana » 19 Nov 2014 01:32

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.

mquevedob
New Cone
New Cone
Posts: 8
Joined: 13 Nov 2014 02:32

Re: change video window position

Postby mquevedob » 05 Dec 2014 01:45

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


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 17 guests