GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Nov 27, 2014 9:16 am

All times are UTC




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 19 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Gtk and LibVLC Multimedia Player Example (C)
PostPosted: Sat Apr 02, 2011 3:38 am 
Offline
Familiar Face

Joined: Fri Mar 25, 2011 7:55 am
Posts: 35
Location: romania
Hi,

Thanks for your code, with a little modification is work on windoze,

in gtk-libvlc-media-player.c, must replace XID with HWND:

//XID xid = gdk_x11_drawable_get_xid(GTK_WIDGET(self)->window);
HWND hWnd = ( HWND )gdk_win32_drawable_get_handle(GTK_WIDGET(self)->window );

//libvlc_media_player_set_xwindow (priv->libvlc_mediaplayer, xid);
libvlc_media_player_set_hwnd (priv->libvlc_mediaplayer, hWnd);

and is working !

I'm using CodeBlocks&MinGW

thanks again !

_________________
c/c++ for ever


Top
 Profile  
 
 Post subject: Re: Gtk and LibVLC Multimedia Player Example (C)
PostPosted: Tue Apr 05, 2011 12:26 pm 
Offline
Familiar Face

Joined: Fri Mar 25, 2011 7:55 am
Posts: 35
Location: romania
window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
and that
hWndMain = ( HWND )gdk_win32_drawable_get_handle( GTK_WIDGET( window )->window );
hInst = ( HINSTANCE )GetWindowLong( hWndMain, GWL_HINSTANCE );
getting hwnd for window and set that to libvlc will result a strange result in gtk player. all player gtk window will be covered by the played stream.

we need a window handler inside the gtk player, and this is the vlc widget.
first step, attach a windows window to a gtk window, and followi with the windows window the evolution of gtk widget.
Code:
#include <windows.h>
#include <gdk\gdkwin32.h>
#include <gtk\gtk.h>
#include <glib.h>

static HWND      hWndMain;
static HINSTANCE hInst;

char *pszVLC  = "vlc";
HWND  hWndVLC = ( HWND )0;

#define WM_RESIZE 1213

LRESULT CALLBACK VLCProc( HWND   hWnd,
                          UINT   iMsg,
                          WPARAM wParam,
                          LPARAM lParam ) {
   switch ( iMsg ) {
   case WM_CREATE:
   return( TRUE );
   case WM_PAINT: {
      HDC         hdc;
      PAINTSTRUCT ps;

      hdc = BeginPaint( hWnd, &ps );
      EndPaint( hWnd, &ps );
   }
   return( 0L );
   case WM_RESIZE:
      // here we get frame2 coordinates and size and we do the same with windows window.
      MoveWindow( hWnd, LOWORD( wParam ), HIWORD( wParam ), LOWORD( lParam ), HIWORD( lParam ), TRUE );
   break;
   case WM_CLOSE:
      DestroyWindow( hWnd );
   return( TRUE );
   case WM_DESTROY:
      hWndVLC = 0;
      UnregisterClass( pszVLC, hInst );
   return( TRUE );
   } /* endswitch */
   return DefWindowProc( hWnd, iMsg, wParam, lParam );
} // ***** Function VLCProc ***** //                         

ATOM pascal RegisterVLCClass( HINSTANCE hInstance ) {
   ATOM        atResult;
   WNDCLASSEX  wndclass ;

   wndclass.hInstance     = hInstance;
   wndclass.lpszClassName = ( LPSTR )pszVLC;
   wndclass.lpfnWndProc   = VLCProc;
   wndclass.style         = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
   wndclass.cbSize        = sizeof( WNDCLASSEX );
   wndclass.hIcon         = NULL;
   wndclass.hIconSm       = NULL;
   wndclass.hCursor       = LoadCursor( NULL, IDC_ARROW );
   wndclass.lpszMenuName  = NULL;
   wndclass.cbClsExtra    = 0;
   wndclass.cbWndExtra    = 0;
   wndclass.hbrBackground = ( HBRUSH )( COLOR_BTNFACE + 1 );
   return( RegisterClassEx( &wndclass ) );
} // ***** Function RegisterVLCClass ***** //

static WPARAM BuildWParam( unsigned short low, unsigned short high ) {
    return ((( WPARAM )high << 16 ) | ( WPARAM )low );
}

gint destroyapp( GtkWidget *widget, gpointer gdata ) {
   g_print ("Quitting...\n");
   SendMessage( hWndVLC, WM_CLOSE, 0L, 0L );
   gtk_main_quit();
   return (FALSE);
}

void gtkVLCEvent( GtkWidget *widget, gpointer gdata ) {
   if ( hWndVLC )
      SendMessage( hWndVLC,
                   WM_RESIZE,
                   BuildWParam( widget->allocation.x    , widget->allocation.y ),
                   BuildWParam( widget->allocation.width, widget->allocation.height ));
}

int main( int   argc,
          char *argv[] ) {
   GtkWidget *window = NULL;
   GtkWidget *main_vbox;
   GtkWidget *vbox;
   GtkWidget *frame_horz;
   GtkWidget *button;

   gtk_init( &argc, &argv );
   window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
   gtk_window_set_title( GTK_WINDOW( window ), "test window" );
   gtk_widget_set_size_request( GTK_WIDGET( window ), 200, 200 );
   g_signal_connect( G_OBJECT( window ), "destroy", G_CALLBACK( gtk_main_quit ), NULL );
   gtk_container_set_border_width( GTK_CONTAINER( window ), 10 );
   main_vbox = gtk_vbox_new( FALSE, 0 );
   gtk_container_add( GTK_CONTAINER ( window ), main_vbox );
   
   frame_horz = gtk_frame_new( "frame1" );
   gtk_box_pack_start( GTK_BOX( main_vbox ), frame_horz, TRUE, TRUE, 10 );

   frame_horz = gtk_frame_new( "frame2" );
   gtk_box_pack_start( GTK_BOX( main_vbox ), frame_horz, TRUE, TRUE, 10 );
   g_signal_connect( G_OBJECT( frame_horz ), "size-allocate", G_CALLBACK( gtkVLCEvent ), frame_horz );
 
   vbox = gtk_hbox_new( FALSE, 0 );
   gtk_box_pack_start( GTK_BOX( main_vbox ), vbox, TRUE, TRUE, 0 );


   button = gtk_button_new_with_label("click");
   gtk_box_pack_start( GTK_BOX( vbox ), button, TRUE, FALSE, 0);
   
   gtk_widget_show_all( window );
   // main handler and instance to window.
   hWndMain = ( HWND )gdk_win32_drawable_get_handle( GTK_WIDGET( window )->window );
   hInst    = ( HINSTANCE )GetWindowLong( hWndMain, GWL_HINSTANCE );
   RegisterVLCClass( hInst );
   hWndVLC  = CreateWindowEx( 0,
                              pszVLC,
                              "",
                              WS_CHILD | WS_VISIBLE | WS_BORDER | WS_CLIPSIBLINGS,
                              frame_horz->allocation.x,
                              frame_horz->allocation.y,
                              frame_horz->allocation.width,
                              frame_horz->allocation.height,
                              hWndMain,
                              NULL,
                              hInst,
                              NULL );

   ShowWindow( hWndVLC, SW_SHOW );
   UpdateWindow( hWndVLC );
   gtk_main();
   return 0;
}


and now we will follow the gtk "frame2" in all his actions with a hWndVLC windows, and this window will be set to libvlc player.

_________________
c/c++ for ever


Top
 Profile  
 
 Post subject: Re: Gtk and LibVLC Multimedia Player Example (C)
PostPosted: Wed Aug 29, 2012 4:27 am 
Offline
GTK+ Geek

Joined: Wed Mar 18, 2009 2:26 pm
Posts: 62
does anyone know where to get the working example????

both of the links don't work

http://code.google.com/p/libvlc-gtk/
svn checkout http://libvlc-gtk.googlecode.com/svn/trunk/ libvlc-gtk-read-only

_________________
Hello, העלו, Здравствулте!


Top
 Profile  
 
 Post subject: Re: Gtk and LibVLC Multimedia Player Example (C)
PostPosted: Wed Aug 29, 2012 6:59 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 781
Location: UK
Hi,

Please do not top post a very old topic as this does not help anybody. The original topic started in 2009 it is now August 2012.

To answer your question the original poster has not been on this forum since 2011 and maybe the project has been removed from google code because it could now be a dead project.

_________________
E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 19 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group