It is currently Sun Sep 24, 2017 2:51 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Trying libvlc VLC Player
PostPosted: Sun Sep 10, 2017 11:19 am 
Offline
Enthusiast
Enthusiast

Joined: Sat Apr 26, 2003 2:49 pm
Posts: 494
Has anyone tried libvlc with macos? it works with windows and linux but not in macos.
I think the critical call is libvlc_media_player_set_nsobject() i used a canvas but does not work.
Main page https://www.videolan.org/index.html
API https://www.videolan.org/developers/vlc/doc/doxygen/html/group__libvlc__media__player.html#ga46c26a395b496e48917101198acc31f6
You need to install vlc player.
This code creates a player and a media instances but it does not play:
Code:

EnableExplicit

Define.i win, canvas
Define.i vlcInst, vlcPlayer
Define.s libstr
Define.i lib, media

Define.s path, mediaPath

path = "/Applications/VLC.app/Contents/MacOS/lib/"
SetEnvironmentVariable("VLC_PLUGIN_PATH", "/Applications/VLC.app/Contents/MacOS/plugins/")
libstr = "libvlc.dylib"

lib = OpenLibrary(#PB_Any, path + libstr)

win = OpenWindow(#PB_Any, 10, 10, 400, 300, "", #PB_Window_SystemMenu)
canvas = CanvasGadget(#PB_Any, 0, 0, 400, 300, #PB_Canvas_Container)

vlcInst = CallFunction(lib, "libvlc_new", 0, #Null)
Debug vlcInst

vlcPlayer = CallFunction(lib, "libvlc_media_player_new", vlcInst)
Debug vlcPlayer
CallFunction(lib, "libvlc_media_player_set_nsobject", vlcPlayer, GadgetID(canvas))
mediaPath = "yourmediafile.mp4"
media = CallFunction(lib, "libvlc_media_new_path", vlcInst, @mediaPath)
Debug media
CallFunction(lib, "libvlc_media_player_set_media", vlcPlayer, media)

CallFunction(lib, "libvlc_media_player_play", vlcPlayer)

Repeat
 
Until WaitWindowEvent() = #PB_Event_CloseWindow


Top
 Profile  
Reply with quote  
 Post subject: Re: Trying libvlc VLC Player
PostPosted: Sun Sep 10, 2017 1:31 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 322
The Code works here. OSX 10.7, PB 5.45, ASCI Mode and without #PB_Canvas_Container (because not supported in PB 5.45).


Top
 Profile  
Reply with quote  
 Post subject: Re: Trying libvlc VLC Player
PostPosted: Sun Sep 10, 2017 4:29 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Apr 26, 2003 2:49 pm
Posts: 494
Strange, it does not work here on PB 5.60 64bit wihout #PB_Canvas_Container although i am running OSX 10.11 64bit on virtualbox, can someone test 5.60 on a real machine?
Are you running PB 32 or 64 bit?
Maybe Fred could give us some hint on what has changed in the canvas?


Top
 Profile  
Reply with quote  
 Post subject: Re: Trying libvlc VLC Player
PostPosted: Sun Sep 10, 2017 5:31 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 322
PB 5.6 is unicode only.
So you have to change this line.

Code:
*mediaPath = Ascii("yourmediafile.mp4")
media = CallFunction(lib, "libvlc_media_new_path", vlcInst, *mediaPath)

Don't forget to use FreeMemory(*mediaPath) when you close the file.


Top
 Profile  
Reply with quote  
 Post subject: Re: Trying libvlc VLC Player
PostPosted: Sun Sep 10, 2017 5:45 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Apr 26, 2003 2:49 pm
Posts: 494
It does not work, i think is a problem of the virtual machine, is a know problem it seems. VLC Player itself does not work either.


Top
 Profile  
Reply with quote  
 Post subject: Re: Trying libvlc VLC Player
PostPosted: Sun Sep 10, 2017 5:57 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 322
How does you "yourmediafile.mp4" look?
It should look like "/Users/yourName/Desktop/yourMovie.mp4"
If the path is wrong I get an blank Window too.


Top
 Profile  
Reply with quote  
 Post subject: Re: Trying libvlc VLC Player
PostPosted: Sun Sep 10, 2017 7:28 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 2981
Location: Netherlands
It works on my iMac but it does seem to give problems when the media path contains spaces. :?
And a CanvasGadget isn't required. A ContainerGadget works just as well.

_________________
MacOS 10.12, PB 5.51 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: Trying libvlc VLC Player
PostPosted: Sun Sep 10, 2017 7:36 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Apr 26, 2003 2:49 pm
Posts: 494
There is an issue with the encoding, only if I use ascii or utf8 I can get the media duration but the video still does not play. It seems virtual box does not support playing video on OS X there is some info if you google it.
This gets the correct duration, maybe someone could test it on PB 5.60.
Code:
mediapathi = Ascii("/Users/name/Documents/video.avi") ;or utf8
media = CallFunction(lib, "libvlc_media_new_path", vlcInst, mediaPathi)
Debug media
CallFunction(lib, "libvlc_media_parse", media)
Debug "dur"
Debug CallFunction(lib, "libvlc_media_get_duration", media)

Thanks.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye