Page 1 of 2
libVLC in pb (Windows Only)
Posted: Fri Sep 03, 2021 9:12 am
by CELTIC88

hola
libVLC is the core engine and the interface to the multimedia framework on which VLC media player is based.
libVLC is modularized into hundreds of plugins, which may be loaded at runtime. This architecture provides great flexibility to developers (both VLC devs and devs consuming the library). It allows developers to create a wide range of multimedia applications using the VLC features.....
more ...
https://www.videolan.org/vlc/libvlc.html
API Documentation
https://videolan.videolan.me/vlc/group__libvlc.html
Requirements
vlc media player
https://www.videolan.org/vlc/
vlc.pb
https://www.mediafire.com/file/jkqzr8sf ... b.zip/file

Re: libVLC in pb
Posted: Fri Sep 03, 2021 9:35 am
by Mijikai
Thank you CELTIC88, thats pretty cool im sure it will help me coding a subbing tool

Re: libVLC in pb
Posted: Fri Sep 03, 2021 9:42 am
by Marc56us
Very interesting.
I've dreamed several times to use the VLC API instead of Fmodex for my little webradio program (function: network stream in VLC), but I gave up because of the amount of documentation.

Re: libVLC in pb
Posted: Fri Sep 03, 2021 9:10 pm
by infratec
A lot of work.
Thank you very much!
At the first try of the example, I saw nothing.
Then I noticed, that vlc_loadlibvlc() returns nothing.
So I modified it a bit:
Code: Select all
Procedure.i vlc_loadlibvlc(libvlcpath.s)
Protected cd.s = GetCurrentDirectory()
SetCurrentDirectory(GetPathPart(libvlcpath))
vlc_libisloaded = libvlc_loadapi(OpenLibrary(#PB_Any, GetFilePart(libvlcpath)))
SetCurrentDirectory(cd)
ProcedureReturn vlc_libisloaded
EndProcedure
And modified the example:
Code: Select all
IncludeFile "vlc.pb"
CompilerIf Not #PB_Compiler_Thread
CompilerError "You have to enable thread save!"
CompilerEndIf
If vlc_loadlibvlc("C:\Program Files\VideoLAN\VLC\libvlc.dll") ; select vlc dll
OpenWindow(0, 0, 0, 800, 700, "")
CanvasGadget(1, 0, 0, 800, 700)
vlc = vlc_createplayer(GadgetID(1), #True)
vlc_setvolume(vlc, 80)
; vlc_play(vlc,"https://www.youtube.com/watch?v=sOlP10fDclE&ab_channel=ClassicMrBean") ; not work for youtube video
vlc_addplaylist(vlc,"https://www.youtube.com/watch?v=sOlP10fDclE&ab_channel=ClassicMrBean")
vlc_playplaylist(vlc)
While WaitWindowEvent() <> #PB_Event_CloseWindow
Wend
vlc_freeplayer(vlc)
Else
Debug "Was not able to load libvlc.dll"
EndIf
So I was able to see that the dll was not loaded, but the path was correct.
Then I remebered that I used PB x86. So the dll was not usable.
I started it with PB x64 and ...
it worked.
Btw.: the CompilerIf should be placed in vlc.pb, which should be a vlc.pbi
Oh and you should use
Code: Select all
CompilerIf #PB_Compiler_IsMainFile
EnableExplicit
CompilerEndIf
In your files, else you 'force' a user to use EnableExplicit.

Re: libVLC in pb
Posted: Sat Sep 04, 2021 1:54 pm
by vwidmer
I get a "Invalid memory access" on
Procedure.s vlc_stringformat(fmt,va_list)
Protected sret.s
Protected c = snprintf(0,0,fmt,va_list)
Re: libVLC in pb
Posted: Sun Sep 05, 2021 3:42 pm
by collectordave
Hi
How do I get this to work on the MAC?
Re: libVLC in pb
Posted: Mon Sep 06, 2021 7:26 am
by fsw
collectordave wrote: Sun Sep 05, 2021 3:42 pm
How do I get this to work on the MAC?
Maybe this helps:
viewtopic.php?f=13&t=70862
Re: libVLC in pb
Posted: Mon Sep 13, 2021 7:32 pm
by Kwai chang caine
Works perfectly here
Thanks a lot my friend for sharing this great job

Re: libVLC in pb
Posted: Thu Sep 23, 2021 3:12 pm
by collectordave
Finally got it to work on macOS Big Sur!
Used vlc 2.2.8 and changed a few bits.
Now I just need to sort out Play, Pause, Stop.
I am only using this to play my audio files which are right old mix.
I think the sequence I need is to:-
1. Create Player
2. Play the song
3. When stopping
Stop the player
Free the player
Then wind back to step 1 to play the next song.
If I have some success I will post back here.
Hopefully I can wait for InitSound() on Big Sur to be fixed.
Re: libVLC in pb
Posted: Mon Oct 04, 2021 7:08 am
by collectordave
Got it working playing my .ogg and .mp3 and added to my audio player.
Just want to read Artist and title from the meta data if possible.
Tried:-
Code: Select all
vlc_play(Myvlc,"File:///" + FileName)
Debug "Meta Data"
Debug vlc_getmeta(Myvlc,#libvlc_meta_Artist)
Debug "End Meta"
The song plays straight away no bother but I get no meta data.
What am I missing?
PS if I change the line to
Debug vlc_getmeta(Myvlc,#libvlc_meta_Title)
It returns the Filename
Re: libVLC in pb
Posted: Tue Oct 12, 2021 6:35 am
by collectordave
Lovely.
Spurred on by InitSound() not working on Big Sur
Tried this and got it working for playing MP3, .ogg and FLAC.
Downloaded VLC 2.2.8 then pulled out the libs and plugins etc.
Had to change one bit in the libvlc.pb
I now have the player start,Stop, Pause etc and volume control and a status line to display time played.
Very scrappy GUI as just trying it out.
Code still has my debug statements in as well.
Works on MAC Big Sur.
I think you will need to change the CreatePlayer() procedure to get it to work on windows and or linux.
The whole thing can be downloaded here:-
https://www.mediafire.com/file/zsi4cxg4 ... t.zip/file
This includes the libs etc
In the download there is a TI Media.db file this can be deleted just me trying to get other things working.
Re: libVLC in pb
Posted: Sat Oct 23, 2021 8:30 pm
by Inner
I'm guessing this is for MacOS?
https://paste.pics/157d4a2e48de397a37963f8d9972a8ce
Judging from the error above, or should I download from somewhere

the Windows .libs and replace them.
Re: libVLC in pb
Posted: Tue Oct 26, 2021 5:45 am
by collectordave
"Works on MAC Big Sur."
I have not done the same for windows .
I downloaded VLC 2.2.8. and extracted the libs and plugins.
Replace these with the ones for the version of windows/vlc you are using and modify the createplayer routine.
Re: libVLC in pb
Posted: Fri Apr 29, 2022 8:35 pm
by RSrole
This example is excellent! Thank you for providing it.
I've got it working for a basic video player, but I need to get the video and audio data so I can output to a SDI video card. The libvlc api makes that possible with a set callbacks routine. However I'm getting crashes in the first callback. I'm sure that I don't properly know how to define the call back.
The C (c++?) call back looks like this:
static void *lock(void *data, void **p_pixels)
{
struct ctx *ctx = data;
SDL_LockMutex(ctx->mutex);
SDL_LockSurface(ctx->surf);
*p_pixels = ctx->surf->pixels;
return NULL; /* picture identifier, not needed here */
}
I may or may not use SDL for this project. Most importantly I need the pixel data. Anyone know how to translate this to Purebasic?
Thanks,
Russ
Re: libVLC in pb
Posted: Fri Apr 29, 2022 9:02 pm
by infratec
Don't know anything about the SDL stuff, but my general solution would look like this:
Code: Select all
ProcedureC.i lock(*Data, *p_pixels)
Protected *ctx.ctx
*ctx = *Data
SDL_LockMutex(*ctx\mutex)
SDL_LockSurface(*ctx\surf)
PokeI(*p_pixels, *ctx\surf\pixels)
ProcedureReturn #Null
EndProcedure