Jump to content

libVLC


Something you would be interrested in?  

10 members have voted

  1. 1. Something you would be interrested in?

    • Yes
      10
    • No
      0


Recommended Posts

logo.png

So I've been playing around with libvlc.dll and i'm wondering if anyone's interested in the code and some examples?
Can't seem to find anyone who has done this in AutoIt, via the dll.

 

Thanks for your time :)

 

Edit:

Well I'm happy to know someone finds it interesting :)

I'll post the half done stuff here for now, but i will create a post in AutoIt Example Scripts, When i get more examples done :).

For now, any feedback would be great :D

The file itself: LibVLC.au3

Note: Before running the examples you need libvlc.dll, libvlccore.dll and the plugins folder from VLC. If you have it installed, you can copy them from your install folder, however i would recommend a fresh download, as i personally had some old plugins that gave me annoying message-boxes i have yet to find a way to deal with.

So getting the files without installing: download the windows installer (2.2.4 is the current as of this post). Open the exe with 7zip or your preferred program and extract the files and folder to the folder you wish to run the examples.

As i have not looked into rules and legal matters with VLC files i won't upload them ^^'

Example:

#include "LibVLC.au3"

Opt("GuiOnEventMode", 1)

$hWnd = GUICreate("AutoIt + VLC Example", 700, 320)
GUISetState(@SW_SHOW, $hWnd)

;pick a short video/audio-file, if you want to get the event
$sFilePath = FileOpenDialog("Select VLC compatible file", "", "All (*.*)", 1+2, "", $hWnd)
If @error<>0 Then Exit

$hLibVLC_dll = DllOpen("libvlc.dll")

$hVLC = libvlc_new($hLibVLC_dll, 0, 0)
$m = libvlc_media_new_path($hLibVLC_dll, $hVLC, $sFilePath);path object
$mp = libvlc_media_player_new_from_media($hLibVLC_dll, $m);player object
libvlc_media_release($hLibVLC_dll, $m);release the path object. We're done with it.
$mp_em = libvlc_media_player_event_manager($hLibVLC_dll, $mp);player event manager

;Create dllcallback to function and set to event: media player end reached
$pEndReached = DllCallbackRegister("_VLC_Event_EndReached", "none:cdecl", "handle;handle")
libvlc_event_attach($hLibVLC_dll, $mp_em, $libvlc_MediaPlayerEndReached, DllCallbackGetPtr($pEndReached), 0)

libvlc_media_player_set_hwnd($hLibVLC_dll, $mp, $hWnd)
libvlc_media_player_play($hLibVLC_dll, $mp)

;~ OnAutoItExitRegister("_CleanUp")
GUISetOnEvent(-3, "_MyExit", $hWnd)

While 1
    Sleep(10)
WEnd

Func _CleanUp()
    libvlc_media_player_stop($hLibVLC_dll, $mp);stop the video
    libvlc_media_player_release($hLibVLC_dll, $mp)
    libvlc_release($hLibVLC_dll, $hVLC)
    DllClose($hLibVLC_dll)
    DllCallbackFree($pEndReached)
    GUIDelete($hWnd)
EndFunc

Func _MyExit()
    _CleanUp()
    Exit
EndFunc

Func _VLC_Event_EndReached($event, $data); the event function
    ConsoleWrite("EndReached"&@CRLF)
EndFunc

The script sometimes won't shut down. Not sure what's causing it. Found a possible cause from a discussion, suggesting it may be something to do with certain functions having problems being called from the main thread. I plan to experiment and post my results soon.

 

Edit2 (19th March 2017):

First of all, sorry about the lack of updates on this project. I always start too many projects and end up ignoring old projects, if I run into problems ^^'.

So I've started moving my AutoIt scripts to GitHub. I will still post the most recent script version here.

 

Edit3 (12th April 2017):

So I've uploaded the example on my Github repository with the files needed (except a video file) to run the example.

Sometimes the example will freeze. I found a thread suggesting that calling libvlc_media_player_stop and related functions from the same thread with the window message handling, may result in the problem occurring. I have a possible solution, but am unable to currently test it, as some needed code is hiding in my unorganized mess of projects.

Edited by genius257
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...