libVLC in pb

Share your advanced PureBasic knowledge/code with the community.
User avatar
CELTIC88
Enthusiast
Enthusiast
Posts: 151
Joined: Thu Sep 17, 2015 3:39 pm

libVLC in pb

Post by CELTIC88 »

:D 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

Image

:wink:
interested in Cybersecurity..
User avatar
Mijikai
Addict
Addict
Posts: 1032
Joined: Sun Sep 11, 2016 2:17 pm

Re: libVLC in pb

Post by Mijikai »

Thank you CELTIC88, thats pretty cool im sure it will help me coding a subbing tool 8)
Marc56us
Addict
Addict
Posts: 1108
Joined: Sat Feb 08, 2014 3:26 pm
Location: France

Re: libVLC in pb

Post 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.
:wink:
(English is not my native language, I use an online translator.)
infratec
Always Here
Always Here
Posts: 5527
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: libVLC in pb

Post 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 :wink:

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. :mrgreen:
vwidmer
Enthusiast
Enthusiast
Posts: 260
Joined: Mon Jan 20, 2014 6:32 pm

Re: libVLC in pb

Post 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)
WARNING: I dont know what I am doing! I just put stuff here and there and sometimes like magic it works. So please improve on my code and post your changes so I can learn more. TIA
collectordave
Addict
Addict
Posts: 1272
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: libVLC in pb

Post by collectordave »

Hi

How do I get this to work on the MAC?
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
fsw
Addict
Addict
Posts: 1493
Joined: Tue Apr 29, 2003 9:18 pm
Location: North by Northwest

Re: libVLC in pb

Post 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

I am to provide the public with beneficial shocks.
Alfred Hitshock
User avatar
Kwai chang caine
Addict
Addict
Posts: 4968
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: libVLC in pb

Post by Kwai chang caine »

Works perfectly here :D
Thanks a lot my friend for sharing this great job 8)
ImageThe happiness is a road...
Not a destination
collectordave
Addict
Addict
Posts: 1272
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: libVLC in pb

Post 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.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
collectordave
Addict
Addict
Posts: 1272
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: libVLC in pb

Post 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
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
collectordave
Addict
Addict
Posts: 1272
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: libVLC in pb

Post 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.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 645
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Re: libVLC in pb

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