libVLC help

Linux specific forum
vwidmer
Enthusiast
Enthusiast
Posts: 282
Joined: Mon Jan 20, 2014 6:32 pm

libVLC help

Post by vwidmer »

I am trying to figure out how to make it work correctly its working right now but in a new window.

How can I make it play in the PB window and not in the VLC window?

Code: Select all

Enumeration
  #winMain
  #canvasPlayer
  #libVLC
EndEnumeration

Define.i vlcInst, vlcPlayer, media

SetEnvironmentVariable("VLC_PLUGIN_PATH", "/usr/lib/vlc/plugins/")
OpenLibrary(libVLC, "/usr/lib/libvlc.so")

OpenWindow(winMain, 10, 10, 400, 300, "", #PB_Window_SystemMenu)
CanvasGadget(canvasPlayer, 0, 0, 400, 300, #PB_Canvas_Container)

vlcInst = CallFunction(libVLC, "libvlc_new", 0, #Null)
vlcPlayer = CallFunction(libVLC, "libvlc_media_player_new", vlcInst)

CallFunction(libVLC, "libvlc_media_player_set_xwindow", vlcPlayer, WindowID(winMain))

*mediaPath = Ascii("/home/user/Videos/test.mp4")
media = CallFunction(libVLC, "libvlc_media_new_path", vlcInst, *mediaPath)

CallFunction(libVLC, "libvlc_media_parse", media)
Debug "Duration: " + FormatDate ( "%hh:%ii:%ss",CallFunction(libVLC, "libvlc_media_get_duration", media)/ 1000 )

CallFunction(libVLC, "libvlc_media_player_set_media", vlcPlayer, media)
CallFunction(libVLC, "libvlc_media_player_play", vlcPlayer)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Thanks
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
vwidmer
Enthusiast
Enthusiast
Posts: 282
Joined: Mon Jan 20, 2014 6:32 pm

Re: libVLC help

Post by vwidmer »

On another note just playing around which way is more correct or better way to write it as in the first post or like this?

Code: Select all

Enumeration
  #winMain
  #canvasPlayer
EndEnumeration

ImportC "-lvlc"
  libvlc_new.i(argc.i,argv.i)
  libvlc_media_player_new.i(*p_instance)
  libvlc_media_player_set_xwindow(*p_mi,drawable.i)
  libvlc_media_new_path(*p_instance,*path)
  libvlc_media_parse(*p_md)
  libvlc_media_get_duration(*p_md)
  libvlc_media_player_set_media(*p_mi,*p_md)
  libvlc_media_player_play(*p_mi)
EndImport

Define.i p_instance, p_mi, p_md

OpenWindow(winMain, 10, 10, 400, 300, "", #PB_Window_SystemMenu)
CanvasGadget(canvasPlayer, 0, 0, 400, 300, #PB_Canvas_Container)

p_instance = libvlc_new(0,#Null)
p_mi = libvlc_media_player_new(p_instance)

libvlc_media_player_set_xwindow(p_mi, WindowID(winMain))

*mediaPath = Ascii("/home/user/Videos/test.mp4")
p_md = libvlc_media_new_path(p_instance, *mediaPath)

libvlc_media_parse(p_md)
Debug "Duration: " + FormatDate ( "%hh:%ii:%ss",libvlc_media_get_duration(p_md)/ 1000 )

libvlc_media_player_set_media(p_mi, p_md)
libvlc_media_player_play(p_mi)

Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
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
Post Reply