Page 2 of 6

Posted: Mon Dec 22, 2008 1:27 pm
by Inner

Code: Select all

; /**
;  * Set the drawable where the media player should render its video output
;  *
;  * \param p_mi the Media Player
;  * \param drawable the libvlc_drawable_t where the media player
;  *        should render its video
;  * \param p_e an initialized exception pointer
;  */
;  VLC_PUBLIC_API void libvlc_media_player_set_drawable ( libvlc_media_player_t *, libvlc_drawable_t, libvlc_exception_t * );
  libvlc_media_player_set_drawable (*media.l,*drawable.l,*exception.l ) As "libvlc_media_player_set_drawable"
This is the likely place, the problem he is we don't know what VLC is asking for when it says 'drawable' it could be pretty much darn near anything.

Posted: Mon Dec 22, 2008 1:32 pm
by Inner
As I susspected;

;libvlc_media_player_set_drawable(p\mp, p\drawable, @exeption)

Comment that out you do get a few seconds of video, VLC will open it's own window and render to that.

http://wiki.videolan.org/LibVLC_Tutorial

It's looking for a window handle.

---- might be a PB issue not returning a valid window pointer on linux, don't quote me on that though.

Posted: Mon Dec 22, 2008 2:13 pm
by Coolman
there is an error.

PB 4.30 : win xp pro
line 1268, try this : Procedure makeargs(Array Array.s(1), num, Array newarr(1))

line 1306, for try a clip video : p\file$ = "E:\Multimedias\Test.avi"

The motion in the clip does not work.

We must also make pbVLC.exe put the executable in the directory for VLC it works ...

Great job 8)

Posted: Mon Dec 22, 2008 3:15 pm
by Inner
Coolman wrote:there is an error.

PB 4.30 : win xp pro
line 1268, try this : Procedure makeargs(Array Array.s(1), num, Array newarr(1))

line 1306, for try a clip video : p\file$ = "E:\Multimedias\Test.avi"

The motion in the clip does not work.

We must also make pbVLC.exe put the executable in the directory for VLC it works ...

Great job 8)
It ain't a great job yet, till either I or someone figures out why we can't draw to a PB window rather than having VLC have to open it's own.

Posted: Mon Dec 22, 2008 4:02 pm
by Coolman
Inner wrote:
Coolman wrote:there is an error.

PB 4.30 : win xp pro
line 1268, try this : Procedure makeargs(Array Array.s(1), num, Array newarr(1))

line 1306, for try a clip video : p\file$ = "E:\Multimedias\Test.avi"

The motion in the clip does not work.

We must also make pbVLC.exe put the executable in the directory for VLC it works ...

Great job 8)
It ain't a great job yet, till either I or someone figures out why we can't draw to a PB window rather than having VLC have to open it's own.
it's true, there is again flaws, but we must encourage such initiatives, a multiplatform solution ...

8)

Re: LibVLC using ImportC

Posted: Mon Dec 22, 2008 5:15 pm
by Philippe-felixer76-2
Inner wrote:
Philippe-felixer76-2 wrote:
Inner wrote:http://rainbowplayer.googlecode.com/files/pbVLC.zip

This is where I'm up to.
Wow Inner, nice work. I adjusted your code a bit so that
is't also usable under windows using a .lib file created with
polib.

Strange thing is, under windows it works more or less, i get
audio/video output. But i NEED to set the current directory
in the compiler options to the directory of VLC, otherwise
i get the same error as in Linux, quit unexpectedly.

Here's the libvlc.pb i adjusted, im out of options ATM:
When your using the the IDE to compile with PB looks in /compilers by default for the location of any .dll / .lib, linux is a different story :)

Added you code to ImportC handling.

I'll have a poke around a little bit more, when I last posted my vlc wasn't even capable of playing videos at all though the normal interface that comes with, I've sorted that out .. don't ask it's a gentoo thing.

Code: Select all

[????????] x11 video output error: X11 request 2.0 failed with error code 3:
 BadWindow (invalid Window parameter)
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  2 (X_ChangeWindowAttributes)
  Resource id in failed request:  0x80db108
  Serial number of failed request:  31
  Current serial number in output stream:  32
Wouldn't happen to be that error would it ?
VLC plays fine on my linux, i checked :P

But you need to set the default directory in PB compiler
options to the directory of VLC, because the libvlc.dll also
needs libvlccore.dll.

Hope you have any better luck ..

Posted: Mon Dec 22, 2008 5:23 pm
by Philippe-felixer76-2
Inner wrote:As I susspected;

;libvlc_media_player_set_drawable(p\mp, p\drawable, @exeption)

Comment that out you do get a few seconds of video, VLC will open it's own window and render to that.

http://wiki.videolan.org/LibVLC_Tutorial

It's looking for a window handle.

---- might be a PB issue not returning a valid window pointer on linux, don't quote me on that though.
Yeah your right it works on linux now, the drawable is just
a pointer to a window, and on windows all gadgets are windows
so i point it out to gadgetid(3), but on linux this don't seem to
work.

In my earlyer examples in this post i used a second window
to handle the video, mabe thats a solution again.

Ill try..

But now i see whats the problem..

Posted: Mon Dec 22, 2008 5:29 pm
by Philippe-felixer76-2
Coolman wrote:
Inner wrote:
Coolman wrote:there is an error.

PB 4.30 : win xp pro
line 1268, try this : Procedure makeargs(Array Array.s(1), num, Array newarr(1))

line 1306, for try a clip video : p\file$ = "E:\Multimedias\Test.avi"

The motion in the clip does not work.

We must also make pbVLC.exe put the executable in the directory for VLC it works ...

Great job 8)
It ain't a great job yet, till either I or someone figures out why we can't draw to a PB window rather than having VLC have to open it's own.
it's true, there is again flaws, but we must encourage such initiatives, a multiplatform solution ...

8)
YES!

And there is so much possible if it all works,
like try this:
vlc_args(x) = "--video-filter"
vlc_args(x+1) = "psychedelic"
(x = your enum position)

;-)

Posted: Tue Dec 23, 2008 12:29 am
by Inner
alright on linux what is returned from an OpenWindow is a *gtkwindow, so I'll assume gadget return some sort of *gtk<insert gadget type> as well, this is probably not what VLC is after.

Here is something interesting;
http://forum.videolan.org/viewtopic.php ... 18#p129782

I have however tried gdk_x11_drawable_get_xid() on a pbgtk_window and it says it isn't a window or a pixmap.

There is however some hope as you can render to an SDL surface.

http://wiki.videolan.org/LibVLC_SampleCode_SDL

Obviously this again separating it from a window (maybe)

Posted: Tue Dec 23, 2008 1:25 pm
by Philippe-felixer76-2
Inner wrote:alright on linux what is returned from an OpenWindow is a *gtkwindow, so I'll assume gadget return some sort of *gtk<insert gadget type> as well, this is probably not what VLC is after.

Here is something interesting;
http://forum.videolan.org/viewtopic.php ... 18#p129782

I have however tried gdk_x11_drawable_get_xid() on a pbgtk_window and it says it isn't a window or a pixmap.

There is however some hope as you can render to an SDL surface.

http://wiki.videolan.org/LibVLC_SampleCode_SDL

Obviously this again separating it from a window (maybe)
Your right..

libvlc_video_set_parent

Parameters:
p_instance libvlc instance
drawable the new parent window (Drawable on X11, CGrafPort on MacOSX, HWND on Win32)
p_exception an initialized exception

We need a drawable on linux... to be continued...

Posted: Tue Dec 23, 2008 3:32 pm
by Coolman
Philippe-felixer76-2 wrote:
Coolman wrote:
Inner wrote:
Coolman wrote:there is an error.

PB 4.30 : win xp pro
line 1268, try this : Procedure makeargs(Array Array.s(1), num, Array newarr(1))

line 1306, for try a clip video : p\file$ = "E:\Multimedias\Test.avi"

The motion in the clip does not work.

We must also make pbVLC.exe put the executable in the directory for VLC it works ...

Great job 8)
It ain't a great job yet, till either I or someone figures out why we can't draw to a PB window rather than having VLC have to open it's own.
it's true, there is again flaws, but we must encourage such initiatives, a multiplatform solution ...

8)
YES!

And there is so much possible if it all works,
like try this:
vlc_args(x) = "--video-filter"
vlc_args(x+1) = "psychedelic"
(x = your enum position)

;-)
*** The motion in the clip does not work. ***

Maybe a bad translation, I was talking about ScrollBarGadget is not possible to move in the video, I tried with several videos clips ...

pbVLC.exe to be more precise depends on many dlls in the repertoire of vlc is why it is better to copy pbVLC.exe in this directory ...

I see a certain interest in the fact of control VLC with PureBasic, I use a very heavy media center, and I want a simple way to watch movies by adding the remote control is for this reason that project seems interesting ...

I do not have too much time at the moment, but I try to watch DULY your progress in this area ...

8)

LibVLC Linux and Windows support!

Posted: Tue Dec 23, 2008 5:33 pm
by Philippe-felixer76-2
Inner wrote:alright on linux what is returned from an OpenWindow is a *gtkwindow, so I'll assume gadget return some sort of *gtk<insert gadget type> as well, this is probably not what VLC is after.

Here is something interesting;
http://forum.videolan.org/viewtopic.php ... 18#p129782

I have however tried gdk_x11_drawable_get_xid() on a pbgtk_window and it says it isn't a window or a pixmap.

There is however some hope as you can render to an SDL surface.

http://wiki.videolan.org/LibVLC_SampleCode_SDL

Obviously this again separating it from a window (maybe)
After some search i found a solution ..

Code: Select all

Structure prog
   *inst
   *base
   *mp
   *m
   *state
   *item
   drawable.l
   wevent.l
   procent.l
   stukje.q
   reload.b
   sizex.l
   sizey.l
   osizex.l
   osizey.l
   length.q
   curpos.q
   curposo.q
   ex.l
   file$
   i.l
EndStructure

Global Dim vlc_args.s(8) 
Global Dim utf8args(8)
Global p.prog

CompilerSelect #PB_Compiler_OS
  CompilerCase #PB_OS_Linux
    SetCurrentDirectory("/usr/lib/")
    Global p\base = OpenLibrary(0, "/usr/lib/libvlc.so")
    Procedure makeargs(Array Array.s(1), num, Array newarr(1))
      p\i = 0
      Repeat
         newarr(p\i) = AllocateMemory(StringByteLength(Array(p\i))+1)
         PokeS(newarr(p\i), Array(p\i), -1, #PB_UTF8)
         p\i+1
      Until p\i>=num
    EndProcedure 
   Structure _GdkScreen Extends GdkScreen ; PB def seems to be incomplete
    *font_options;
    resolution.d;      /* pixels/points scale factor for fonts */
  EndStructure
  Structure GdkScreenX11
    parent_instance._GdkScreen;
    *display;
    *xdisplay;
    *xscreen;
  EndStructure
  Structure GdkDrawableImplX11
    parent_instance.GdkDrawable
    *wrapper;
    *colormap;
    xid.l
    *screen
     picture.l ;Picture
    *cairo_surface;
  EndStructure
   Structure _GdkWindowObject ; PB def is empty!
    parent_instance.GdkDrawable;
    *impl.GdkDrawable ; /* window-system-specific delegate object */
    *parent;
    user_data.l
  EndStructure
  Procedure XDisplayFromWindowID(*Window.GtkWidget) 
    *gdkwindowobj._GdkWindowObject = *Window\window
    *impl.GdkDrawableImplX11 = *gdkwindowobj\impl
    *screen.GdkScreenX11 = *impl\screen
    ProcedureReturn *impl\xid ;*screen\xdisplay       
  EndProcedure      
  CompilerCase #PB_OS_Windows
    SetCurrentDirectory("C:\Program Files\VideoLAN\VLC")
    Global p\base = OpenLibrary(0, "C:\Program Files\VideoLAN\VLC\libvlc.dll") 
    Procedure makeargs(Array.s(1), num, newarr(1))
      p\i = 0
      Repeat
         newarr(p\i) = AllocateMemory(StringByteLength(Array(p\i))+1)
         PokeS(newarr(p\i), Array(p\i), -1, #PB_UTF8)
         p\i+1
      Until p\i>=num
    EndProcedure 
CompilerEndSelect 

If p\base
    OpenWindow(1, 0, 0, 60, 20, "PureBasic VLC", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget)
    ScrollBarGadget(0, 0, 0, 0, 0, 0, 1000, 1)
    ButtonGadget(1, 0, 0, 0, 0, "F")
    ButtonGadget(2, 0, 0, 0, 0, ">")
    SetGadgetText(2, "||")
    ContainerGadget(3, 0, 0, 0, 0)
    vlc_args(0) = "-I"
    vlc_args(1) = "dummy"
    vlc_args(2) = "--ignore-config"
    CompilerIf #PB_Compiler_OS = #PB_OS_Linux
        vlc_args(3) = "--plugin-path=/usr/lib/vlc/codecs/"
    CompilerEndIf      
    CompilerIf #PB_Compiler_OS = #PB_OS_Windows
        vlc_args(3) = "--plugin-path=C:\\Program Files\\VideoLAN\\VLC\\plugins\"
    CompilerEndIf      
    vlc_args(4) = "--mms-caching"
    vlc_args(5) = "3200"
    vlc_args(6) = "--http-caching"
    vlc_args(7) = "3200"  
    makeargs(vlc_args(), 8, utf8args())
    CallFunction(0, "libvlc_exception_init", @p\ex) 
    p\inst = CallFunction(0, "libvlc_new", 8, @utf8args(), @p\ex) ;vlc_args(), @p\ex)
    p\file$ = "mms://85.119.217.29/TMFLive"  

    ;; 0.9+ way
    ;p\m = CallFunction(0, "libvlc_media_new", p\inst, p\file$, @p\ex) 
    ;p\mp = CallFunction(0, "libvlc_media_player_new_from_media", p\m, @p\ex)
    ;CallFunction(0, "libvlc_media_release", p\m, @p\ex) 
    ;p\drawable = GadgetID(3) 
    ;CallFunction(0, "libvlc_media_player_set_drawable", p\mp, p\drawable, @p\ex)
    ;CallFunction(0, "libvlc_media_player_play", p\mp, @p\ex) 
    ;p\reload=1
    
    ; 0.9- way
    p\item = CallFunction(0, "libvlc_playlist_add", p\inst, p\file$, #Null, @p\ex) 
    p\drawable = GadgetID(3)
    CompilerIf #PB_Compiler_OS = #PB_OS_Linux
     p\drawable =  XDisplayFromWindowID(GadgetID(3)) 
    CompilerEndIf 
    CallFunction(0, "libvlc_video_set_parent", p\inst, p\drawable, @p\ex)  
    CallFunction(0, "libvlc_playlist_play", p\inst, p\item, 0, #Null, @p\ex) 


    While p\wevent<>#PB_Event_CloseWindow
        p\wevent = WindowEvent()
        
        If p\wevent = #PB_Event_Gadget
           Select EventGadget()
              Case 0 ; slider
                 If p\mp
                    p\procent.l = GetGadgetState(0)      
                    CallFunction(0, "libvlc_media_player_set_time", p\mp, p\stukje.q*p\procent, @p\ex)
                 EndIf
              Case 1 ; file
                 p\file$ = OpenFileRequester("Select media file", "", "*.*", 0)
                 If Len(p\file$)
                    
                    ; v9+
   
                    ; v9-
                    CallFunction(0, "libvlc_playlist_stop", p\inst, @p\ex) 
                    CallFunction(0, "libvlc_playlist_clear", p\inst, @p\ex)
                    p\item = CallFunction(0, "libvlc_playlist_add", p\inst, p\file$, #Null, @p\ex) 
                    CallFunction(0, "libvlc_playlist_play", p\inst, p\item, 0, #Null, @p\ex)
                    p\reload=0                                  
                 EndIf
              Case 2 ; play / pause
                 If GetGadgetText(2) = ">"
                    CallFunction(0, "libvlc_media_player_play", p\mp, @p\ex) 
                    SetGadgetText(2, "||")                  
                 Else
                    CallFunction(0, "libvlc_media_player_pause", p\mp, @p\ex)
                    SetGadgetText(2, ">")
                 EndIf
           EndSelect
        EndIf
        
        If p\wevent=#PB_Event_SizeWindow
           If IsGadget(0)
              ResizeGadget(0, 40, WindowHeight(1)-20, WindowWidth(1)-40, 20)
           EndIf
           If IsGadget(1)
              ResizeGadget(1, 0, WindowHeight(1)-20, 20, 20)
           EndIf
           If IsGadget(2)
              ResizeGadget(2, 20, WindowHeight(1)-20, 20, 20)
           EndIf
           If IsGadget(3)
              ResizeGadget(3, 0, 0, WindowWidth(1), WindowHeight(1)-20)
           EndIf
        EndIf
        
        Delay(10)
       
        If p\reload=0
           p\mp = CallFunction(0, "libvlc_playlist_get_media_player", p\inst, @p\ex)
           If p\mp And p\m=0
              p\m = CallFunction(0, "libvlc_media_player_get_media", p\mp, @p\ex)  		 
              p\reload=1
           EndIf
        EndIf
        
        p\state = CallFunction(0, "libvlc_media_player_get_state", p\mp, @p\ex)
        Select p\state
           Case 0 ; libvlc_NothingSpecial 	
           Case 1 ; libvlc_Opening 	
           Case 2 ; libvlc_Buffering 	
           Case 3 ; libvlc_Playing 	
              p\sizex = CallFunction(0, "libvlc_video_get_width", p\mp, @p\ex)
              p\sizey = CallFunction(0, "libvlc_video_get_height", p\mp, @p\ex)
              If p\sizex<>p\osizex And p\sizey<>p\osizey
                 p\osizex=p\sizex
                 p\osizey=p\sizey
                 ResizeWindow(1, #PB_Ignore, #PB_Ignore, p\sizex, p\sizey+20)
                 p\length.q = CallFunction(0, "libvlc_media_player_get_length", p\mp, @p\ex)                 
                 p\stukje.q = p\length.q / 1000
                 If p\length=0
                    DisableGadget(0, 1)
                 Else
                    DisableGadget(0, 0)
                 EndIf
                 SetGadgetText(2, "||")                              
              EndIf   
              p\curpos.q = CallFunction(0, "libvlc_media_player_get_time", p\mp, @p\ex)
              If p\curpos.q<>p\curposo.q
                 p\curposo.q = p\curpos.q
                 p\stukje.q = p\length.q / 1000
                 If p\stukje>0 And p\curpos>0
                    SetGadgetState(0, p\curpos/p\stukje)
                 EndIf
              EndIf
           Case 4 ; libvlc_Paused 	
           Case 5 ; libvlc_Stopped 	
           Case 6 ; libvlc_Forward 	
           Case 7 ; libvlc_Backward 	
           Case 8 ; libvlc_Ended 	
           Case 9 ; libvlc_Error
        EndSelect
        
    Wend
    If p\mp
       CallFunction(0, "libvlc_media_player_stop", p\mp, @p\ex)
       CallFunction(0, "libvlc_media_player_release", p\mp)
    EndIf
    CallFunction(0, "libvlc_release", p\inst)
    CloseLibrary(0)
EndIf
End
Next, MacOS ;-)

Gr,
Phil.

Re: LibVLC Linux and Windows support!

Posted: Wed Dec 24, 2008 12:53 pm
by Inner
Philippe-felixer76-2 wrote:
Inner wrote: Next, MacOS ;-)

Gr,
Phil.
That one your on your own with I don't have MacOS :)

Well done in fix the linux problem, that direct drawing to a window might also become more useful as well, I was working on it but I was hit with a nasty stomach and I'm still recovering, I'm glad I got out my leads for your help before I came down with it though.

Posted: Wed Dec 24, 2008 5:45 pm
by Coolman
Now ScrollBarGadget works :wink:

There is no need to copy pbVLC in the directory VLC :)

but the display window is altered if covered by another ...

8)

Re: LibVLC Linux and Windows support!

Posted: Wed Dec 24, 2008 6:38 pm
by Philippe-felixer76-2
Inner wrote:
Philippe-felixer76-2 wrote:
Inner wrote: Next, MacOS ;-)

Gr,
Phil.
That one your on your own with I don't have MacOS :)

Well done in fix the linux problem, that direct drawing to a window might also become more useful as well, I was working on it but I was hit with a nasty stomach and I'm still recovering, I'm glad I got out my leads for your help before I came down with it though.
Ohh yeah great tnx, leave it up to me with my vmware ;-P

Hope your getting better man, because as you know this is just
a raw source alpha/beta attempt, far away from beeing perfect.

Gr,
Phil.