Video Player based on VLC

Windows specific forum
Philippe-felixer76-2
Enthusiast
Enthusiast
Posts: 135
Joined: Sat Aug 18, 2007 7:09 am
Location: Netherlands

Post by Philippe-felixer76-2 »

Coolman wrote: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)
Glad your also happy.. we need you :)

Work in progress.. you can help ..

Gr,
Phil.
Coolman
Enthusiast
Enthusiast
Posts: 103
Joined: Sat Sep 03, 2005 4:07 pm

Post by Coolman »

Philippe-felixer76-2 wrote:
Coolman wrote: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)
Glad your also happy.. we need you :)

Work in progress.. you can help ..

Gr,
Phil.
I found this :wink:

*** http://bob.developpez.com/tutapiwin/full.php

http://bob.developpez.com/tutapiwin/article_1.php
http://texel3d.free.fr/win32/base2.htm
http://texel3d.free.fr/win32/base3.htm
http://chgi.developpez.com/windows/winmain/

http://www.purebasic.com/french/documen ... event.html

Sorry, it's in French ...

Good luck, I believe we should use a callback on the window for the refresh...

8)
*** Excuse my bad English, I uses has translating program ***
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post by Inner »

just a quick word your doing something really bad in your code, not earth shattering but bad none the less;

Some of the API commands your using in libvlc are deprecated.
http://www.videolan.org/developers/vlc/ ... ylist.html

Don't know if that term is formilure to you at all, I've only noticed it myself around linux circles, basically deprecated means the functions are going to be gone soon, and there is no telling when they'll disappear, which is why I paid no effort in converting those for the Includes to LibVLC.

I couldn't figure out why you'd gone back to library() open calls, until I started making an example template to go with the (yet to be release new version of the includes), using your OpenLibrary() example as guide to get things done, and suddenly found missing commands, then I realized why they where deprecated.

It's not going to harm anything for now.. but it would be a good step to move away from them.

Using deprecated commands and then having to redo your whole code style to fit a new API it tiresome and time consuming.
Philippe-felixer76-2
Enthusiast
Enthusiast
Posts: 135
Joined: Sat Aug 18, 2007 7:09 am
Location: Netherlands

Post by Philippe-felixer76-2 »

Inner wrote:just a quick word your doing something really bad in your code, not earth shattering but bad none the less;

Some of the API commands your using in libvlc are deprecated.
http://www.videolan.org/developers/vlc/ ... ylist.html

Don't know if that term is formilure to you at all, I've only noticed it myself around linux circles, basically deprecated means the functions are going to be gone soon, and there is no telling when they'll disappear, which is why I paid no effort in converting those for the Includes to LibVLC.

I couldn't figure out why you'd gone back to library() open calls, until I started making an example template to go with the (yet to be release new version of the includes), using your OpenLibrary() example as guide to get things done, and suddenly found missing commands, then I realized why they where deprecated.

It's not going to harm anything for now.. but it would be a good step to move away from them.

Using deprecated commands and then having to redo your whole code style to fit a new API it tiresome and time consuming.
Yeah i know Inner, i call it the 0.9 + and the 0.9 - way.

From 0.8.6 + new commands added, but using the new commands
i can't reload another file, so i can only load 1 file.

Code: Select all

    ;; 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)
    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)
Thats why i use the old method in my sources, help me :)
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post by Inner »

http://rainbowplayer.googlecode.com/fil ... alpha2.zip

Alright it's -all- in there I mean all the command even the deprecated.

Now.. I've not tested this at all, the example doesn't work at all really, and that's work in progress too, but it's better to have something out there that can be tested.

If it crashes check the argument types I've converted to PB are correct before blaming your own code, it's likely -very- likely my fault.

And feel free to slap me with what I did wrong so I can change it.
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post by Inner »

Right then, here is a working example at least on linux using old deprecated functions :( haven't gotten around to upgrading it yet, one thing at a time, I first needed to *cough* clean *cough* the code a bit so that I could understand what was going on, hope you can identify your finger prints :)

Code: Select all

;*****************************************************************************
; Example: pbvlc.pb
; By: T.J.Roughton
; Requires: libvlc.pb (includes)
;*****************************************************************************
IncludeFile "libvlc.pb"

Enumeration
  #WINDOW_PLAYMEDIA
EndEnumeration

Enumeration
  #GAD_TRACKBAR
  #GAD_FILE
  #GAD_PLAYPAUSE
  #GAD_MEDIACONTAINER
EndEnumeration

Global Dim vlc_args.s(8)
Global Dim utf8args(8)
;*****************************************************************************
; VLC Exception
;*****************************************************************************
Procedure Debug_Exception(cmd.s,ex.l,result.l=-1)
  *exception.libvlc_exception=ex
  OpenConsole()
    PrintN(cmd+" = "+Str(result))
    PrintN("libvlc_exception\raised="+Str(*exception\raised))
    PrintN("libvlc_exception\code="+Str(*exception\code))
    PrintN("libvlc_exception\message="+*exception\message)
  CloseConsole()
EndProcedure

;*****************************************************************************
; Choose URL/File
;*****************************************************************************
Procedure.s OpenWindow_ChooseURLFILE()
  result.s=""
  If OpenWindow(0, 0, 0, 300, 50, "Choose URL/File", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_ScreenCentered)
    ButtonGadget(1,10,10,135,30,"URL")
    ButtonGadget(2,155,10,135,30,"FILE")
    While wevent<>#PB_Event_CloseWindow
      wevent = WindowEvent()  
      If wevent = #PB_Event_Gadget
        Select EventGadget()
          Case 1 ; URL
            result.s=InputRequester("URL","Enter URL","")
            wevent=#PB_Event_CloseWindow
          Case 2 ; FILE
            result.s=OpenFileRequester("File","","",0)
            wevent=#PB_Event_CloseWindow
        EndSelect
      EndIf
    Wend
  EndIf
  CloseWindow(0)
  ProcedureReturn result
EndProcedure

;*****************************************************************************
; Set Args
;*****************************************************************************
Procedure SetArguments(location.s)
  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" 
  PBVLC_MakeArgs(vlc_args(), 8, utf8args())
EndProcedure

;*****************************************************************************
; Roll it!
;*****************************************************************************
Procedure OpenWindow_PlayMedia(location.s)
  exception.libvlc_exception

  If OpenWindow(#WINDOW_PLAYMEDIA, 0, 0, 60, 20, "PureBasic VLC", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget)
    ButtonGadget(#GAD_PLAYPAUSE, 0, 0, 0, 0, "F")
    ButtonGadget(#GAD_FILE, 0, 0, 0, 0, ">")
    ScrollBarGadget(#GAD_TRACKBAR, 0, 0, 0, 0, 0, 1000, 1)
    ContainerGadget(#GAD_MEDIACONTAINER, 0, 0, 0, 0)    
    drawable=PBVLC_XDisplayFromWindowID(GadgetID(#GAD_MEDIACONTAINER))
    ; Set the arguments up for VLC
    SetArguments(location)
    ; Init
    libvlc_exception_init(@exception)
    instants = libvlc_new (8,@utf8args(),@exception)            
    item = libvlc_playlist_add (instants,@location,#Null,@exception)
    libvlc_playlist_play (instants,item,0,#Null,@exception)
    mplayer = libvlc_playlist_get_media_player (instants,@exception)
    
    ; we must start playing so that libvlc_video_set_parent has some input first! 
    libvlc_video_set_parent (instants,drawable,@exception) 
    
    oldwsize.l=0
    oldhsize.l=0
    oldcurpos.q=0
    
    While wevent<>#PB_Event_CloseWindow
      wevent = WindowEvent()  
      If wevent = #PB_Event_Gadget
        Select EventGadget()
          Case #GAD_TRACKBAR
          Case #GAD_FILE
          Case #GAD_PLAYPAUSE
          Case #GAD_MEDIACONTAINER
        EndSelect
      EndIf
      If wevent=#PB_Event_SizeWindow
        If IsGadget(#GAD_TRACKBAR)
          ResizeGadget(#GAD_TRACKBAR, 40, WindowHeight(#WINDOW_PLAYMEDIA)-20, WindowWidth(#WINDOW_PLAYMEDIA)-40, 20)
        EndIf
        If IsGadget(#GAD_FILE)
          ResizeGadget(#GAD_FILE, 0, WindowHeight(#WINDOW_PLAYMEDIA)-20, 20, 20)
        EndIf
        If IsGadget(#GAD_PLAYPAUSE)
          ResizeGadget(#GAD_PLAYPAUSE, 20, WindowHeight(#WINDOW_PLAYMEDIA)-20, 20, 20)
        EndIf
        If IsGadget(#GAD_MEDIACONTAINER)
          ResizeGadget(#GAD_MEDIACONTAINER, 0, 0, WindowWidth(#WINDOW_PLAYMEDIA), WindowHeight(#WINDOW_PLAYMEDIA)-20)
        EndIf
      EndIf

      state = libvlc_media_player_get_state(mplayer, @exception)
      Select state
        Case 0 ; libvlc_NothingSpecial    
        Case 1 ; libvlc_Opening    
        Case 2 ; libvlc_Buffering    
        Case 3 ; libvlc_Playing
          width=libvlc_video_get_width(mplayer,@exception)
          height=libvlc_video_get_height(mplayer,@exception)
          curpos.q=libvlc_media_player_get_time(mplayer,@exception)
          If (width<>oldwsize And height<>oldhsize)
            oldwsize=width
            oldhsize=height
            ResizeWindow(#WINDOW_PLAYMEDIA,#PB_Ignore,#PB_Ignore,width,height+20)
            ;
            length.q=libvlc_media_player_get_length(mplayer,@exception)
            stukje.q=length.q/1000
            If length=0
              DisableGadget(#GAD_TRACKBAR,1)
            Else
              DisableGadget(#GAD_TRACKBAR,0)
            EndIf
            SetGadgetText(#GAD_PLAYPAUSE, "||")                             
          EndIf   
          If curpos<>oldcurpos          
            curposo=curpos
             stukje.q = length / 1000
             If (stukje>0 And curpos>0)
              SetGadgetState(#GAD_TRACKBAR,curpos/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
      Delay(1)
    Wend  
    If mplayer
       libvlc_media_player_stop(mplayer,@exception)
       libvlc_media_player_release(mplayer)
    EndIf
    libvlc_release(instants)
    CloseWindow(#WINDOW_PLAYMEDIA)
  EndIf
EndProcedure
;-----------------------------------------------------------------------------
OpenWindow_PlayMedia(OpenWindow_ChooseURLFILE())
Philippe-felixer76-2
Enthusiast
Enthusiast
Posts: 135
Joined: Sat Aug 18, 2007 7:09 am
Location: Netherlands

Post by Philippe-felixer76-2 »

Inner wrote:Right then, here is a working example at least on linux using old deprecated functions :( haven't gotten around to upgrading it yet, one thing at a time, I first needed to *cough* clean *cough* the code a bit so that I could understand what was going on, hope you can identify your finger prints :)

Code: Select all

 .code. 
Wow nice work.. i needed to adjust some things to get it to
work on windows.

A few defs (17+/-) from ImportC like for example
libvlc_exception_init( *exception.l ) As "libvlc_exception_init"
only works like this:
libvlc_exception_init( *exception.l )

The drawable needed a compilerif because on windows
it uses a plain gadgetid().

The most strange things is, on windows you need to set
the defaultdirectory in compiler options in PB to the directory
where the libvlc.dll is. Otherwise a you get a error not finding
the dll.

Apart from this its multiOS already :)

I have bad luck getting PB to run on OSX BTW.. :(
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Post by lexvictory »

Philippe-felixer76-2 wrote:The most strange things is, on windows you need to set
the defaultdirectory in compiler options in PB to the directory
where the libvlc.dll is. Otherwise a you get a error not finding
the dll.
that's due to where windows looks for dlls; copy libvlc.dll into the source's directory (as this is where it would be in a finalised project, i.e. the exe's directory), or into the system32 dir (in system32 is not advisable if you ask me)
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
Philippe-felixer76-2
Enthusiast
Enthusiast
Posts: 135
Joined: Sat Aug 18, 2007 7:09 am
Location: Netherlands

Post by Philippe-felixer76-2 »

lexvictory wrote:
Philippe-felixer76-2 wrote:The most strange things is, on windows you need to set
the defaultdirectory in compiler options in PB to the directory
where the libvlc.dll is. Otherwise a you get a error not finding
the dll.
that's due to where windows looks for dlls; copy libvlc.dll into the source's directory (as this is where it would be in a finalised project, i.e. the exe's directory), or into the system32 dir (in system32 is not advisable if you ask me)
So it seems setcurrentdirectory() doesn't work with using ImportC on windows, it does work with using Openlibrary(). Strange..

For OSX i'm Going to try this:

http://osx86.thefreesuite.com/leo_intel.php

I think .. :P
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post by Inner »

Philippe-felixer76-2 wrote: The drawable needed a compilerif because on windows
it uses a plain gadgetid().
Fixed.
Philippe-felixer76-2 wrote: A few defs (17+/-) from ImportC like for example
libvlc_exception_init( *exception.l ) As "libvlc_exception_init"
only works like this:
libvlc_exception_init( *exception.l )
Uhmm there probably all like that you know, we're just using a small amount of the commands available so.. (ponders) I'll make a CompilerSelect on OS to select the right include of libvlc_linux.pb / libvlc_windows.pb / libvlc_macos.pb, where by you would just include as normal libvlc.pb and the compiler would choose the right one, appears the simplest way around this banana.
Philippe-felixer76-2 wrote: The most strange things is, on windows you need to set
the defaultdirectory in compiler options in PB to the directory
where the libvlc.dll is. Otherwise a you get a error not finding
the dll.
You can redistribute the dlls/codecs for VLC it's open source as you likely know and GPL if I recall, just remember to include the verious legal bumbo jumbo, then it won't matter where it is as much.

The draw back of course is that you could have 2 conflicting versions of VLC on the same system, which could be problematic.

Philippe-felixer76-2 wrote: Apart from this its multiOS already :)

I have bad luck getting PB to run on OSX BTW.. :(
:( well, I'm sure someone out there using OSX even Fred might like to just look at that part of it, dunno you'd have to ask him, but right now if memory recalls his normal traditions at this time of year he has disappeared and rightly so, and if he hasn't he darn well should be off doing something other than working on PB or reading the forum.
Last edited by Inner on Fri Dec 26, 2008 1:06 pm, edited 1 time in total.
lexvictory
Addict
Addict
Posts: 1027
Joined: Sun May 15, 2005 5:15 am
Location: Australia
Contact:

Post by lexvictory »

Philippe-felixer76-2 wrote:So it seems setcurrentdirectory() doesn't work with using ImportC on windows, it does work with using Openlibrary(). Strange..
not strange at all really... using openlibrary is like opening a file; it doesn't really matter where it is, but using Import/ImportC means that the exe is linked to the dll and cant function if windows cant find it.
From memory Windows looks in the exe dir, the current dir, then the system dir (perhaps not in that order though)
if on linux you moved libvlc from /usr/lib, you would get the equivalent error message

hehe i use OSX 10.4.8 in vmware (10.5.2 doesn't seem to like it)
OSX doesnt support my wireless card, i dont like to run an ethernet cable thru the house and my graphics card is too new, so running it w/o virtualisation is a hassle :lol:
Demonio Ardente

Currently managing Linux & OS X Tailbite
OS X TailBite now up to date with Windows!
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post by Inner »

lexvictory wrote:
Philippe-felixer76-2 wrote: hehe i use OSX 10.4.8 in vmware (10.5.2 doesn't seem to like it)
OSX doesnt support my wireless card, i dont like to run an ethernet cable thru the house and my graphics card is too new, so running it w/o virtualisation is a hassle :lol:
And I don't really want to uhmm .. copy it .. although tempting I've wondered what that OS feels like to run.
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post by Inner »

http://rainbowplayer.googlecode.com/fil ... alpha3.zip

Alpha 3
Fixed: pbvlc_example.pb PBVLC_XDisplayFromWindowID() only required for linux

Changed: Split up the include files for each OS and made a central include to include only the include the source being compiled on.
Philippe-felixer76-2
Enthusiast
Enthusiast
Posts: 135
Joined: Sat Aug 18, 2007 7:09 am
Location: Netherlands

Post by Philippe-felixer76-2 »

Inner wrote:http://rainbowplayer.googlecode.com/fil ... alpha3.zip

Alpha 3
Fixed: pbvlc_example.pb PBVLC_XDisplayFromWindowID() only required for linux

Changed: Split up the include files for each OS and made a central include to include only the include the source being compiled on.
Wow thats fast..

I forgot i little thing, apart from that it runs good here.

Linux:

Procedure PBVLC_MakeArgs(array Array.s(1), num, array newarr(1))
i = 0
Repeat
newarr(i) = AllocateMemory(StringByteLength(Array(i))+1)
PokeS(newarr(i), Array(i), -1, #PB_UTF8)
i+1
Until i>=num
EndProcedure

windows:

Procedure PBVLC_MakeArgs(Array.s(1), num, newarr(1))
i = 0
Repeat
newarr(i) = AllocateMemory(StringByteLength(Array(i))+1)
PokeS(newarr(i), Array(i), -1, #PB_UTF8)
i+1
Until i>=num
EndProcedure

macos:

????
Philippe-felixer76-2
Enthusiast
Enthusiast
Posts: 135
Joined: Sat Aug 18, 2007 7:09 am
Location: Netherlands

Post by Philippe-felixer76-2 »

lexvictory wrote:
Philippe-felixer76-2 wrote:So it seems setcurrentdirectory() doesn't work with using ImportC on windows, it does work with using Openlibrary(). Strange..
not strange at all really... using openlibrary is like opening a file; it doesn't really matter where it is, but using Import/ImportC means that the exe is linked to the dll and cant function if windows cant find it.
From memory Windows looks in the exe dir, the current dir, then the system dir (perhaps not in that order though)
if on linux you moved libvlc from /usr/lib, you would get the equivalent error message

hehe i use OSX 10.4.8 in vmware (10.5.2 doesn't seem to like it)
OSX doesnt support my wireless card, i dont like to run an ethernet cable thru the house and my graphics card is too new, so running it w/o virtualisation is a hassle :lol:
Yeah but before i call ImportC is do a setcurrentdirectory() to
VLC. So the program directory should be good, and for OpenLibrary()
this works and is needed.

And can you run PB also?
Post Reply