Jump to content

Recommended Posts

Posted (edited)

VLC Media Player

Many times I have seen attemps to get the famous VLC Payer into AU3.

VLC media player - the cross-platform media player and streaming server

VLC media player is a highly portable multimedia player for various audio and video formats (MPEG-1, MPEG-2, MPEG-4, DivX, mp3, ogg, ...) as well as DVDs, VCDs, and various streaming protocols. It can also be used as a server to stream in unicast or multicast in IPv4 or IPv6 on a high-bandwidth network

I seemed always to crash the GUI when using the VLC ActiveX object ?

Before running the script download and install the VLC Player

opt("GUIOnEventMode", 1)
#include <GUIConstantsEX.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>

;VLCPlaylistMode
Const $VLCPlayListInsert = 1
Const $VLCPlayListReplace = 2
Const $VLCPlayListAppend = 4
Const $VLCPlayListGo = 8
Const $VLCPlayListInsertAndGo = 9
Const $VLCPlayListReplaceAndGo = 10
Const $VLCPlayListAppendAndGo = 12
Const $VLCPlayListCheckInsert = 16

; Initialize error handler
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

; ---------------------------------- Declare objects -------------------------------
$oVLC = ObjCreate("VideoLAN.VLCPlugin.1")

; -------------------------------------------- Main Gui ---------------------------------
$hGui = GuiCreate("VLC Viewer", 500, 390,-1, -1, Bitor($WS_OVERLAPPEDWINDOW,$WS_VISIBLE, $WS_CLIPSIBLINGS))
GUISetOnEvent($GUI_EVENT_CLOSE, "GUIeventClose")

$bSelect = GUICtrlCreateButton("Select ... ", 10, 20, 70)
         GUICtrlSetOnEvent(-1, "_SelectFile")

;$oVLC_Object = GUICtrlCreateObj ($hGui, 10, 70 , 700 , 460)
;GUICtrlSetStyle ( $oVLC_Object, $WS_VISIBLE )
;GUICtrlSetResizing ($oVLC_Object,$GUI_DOCKAUTO)        ; $GUI_DOCKAUTO Auto Resize Object

GuiSetState()
$size = WinGetPos("[active]")

While 1
    Sleep(100)
WEnd

Func _SelectFile ()
        $File = FileOpenDialog("Select a movie File ", @MyDocumentsDir & "", "Images (*.flv;*.swf;*.wmv;*.avi;*.*)", 1)
    If @error Then
        MsgBox(4096,"","No File chosen ...")
        Return
    Else
        Sleep(100)
        _StartPlay($File)
    EndIf
EndFunc

Func _StartPlay($hFile)
    With $oVLC
        ;.AddTarget ($hFile, Default, $VLCPlayListInsert, 0)
        .MRL = $hFile
        .AutoLoop = 0 ;False
        .AutoPlay = 0 ;False
        .Visible = 1 ;True
        .Play ()
        .Volume = 50
    EndWith
EndFunc


Func GUIeventClose()
    Exit
EndFunc ;==>GUIeventClose

;This is custom error handler
Func MyErrFunc()
$HexNumber=hex($oMyError.number,8)
Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _
             "err.description is: " & @TAB & $oMyError.description & @CRLF & _
             "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: " & @TAB & $HexNumber & @CRLF & _
             "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
             "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
             "err.source is: " & @TAB & $oMyError.source & @CRLF & _
             "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
             "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
            )
SetError(1) ; to check for after this function returns
Endfunc

The only way to get it run without crashing is NOT to use the "GUICtrlCreateObj".

The VLC Player creates some kind of own GUI and Control when calling the Object.

This make it hard of course to attach the Control to the parent window.

Some Movie

flexdrainwit.zip

Enjoy !!

Regards,

ptrex

Edited by ptrex
Posted

I got an error saying "The procedure point VLC_Play could not be located in the dll libvlc.dll

I have VLC 0.98a installed.

err.number # 8007007f

err.lastdllerror 127

err.scriptline 20

Posted

im getting no video when i run your example. i get audio in the background. when thw app starts i get the following error:

errnumber is FFFFFFFF

err.lastdllerror is 0

err.scriptline is 41

Posted (edited)

Working well and strong for me.

This is awesome.

Would be nice to see some control features like play pause stop volume or something.

EDIT:

Started to write it into a UDF for my own use

#include-once

Local Const $VLCPlayListInsert = 1
Local Const $VLCPlayListReplace = 2
Local Const $VLCPlayListAppend = 4
Local Const $VLCPlayListGo = 8
Local Const $VLCPlayListInsertAndGo = 9
Local Const $VLCPlayListReplaceAndGo = 10
Local Const $VLCPlayListAppendAndGo = 12
Local Const $VLCPlayListCheckInsert = 16

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
$oVLC = ObjCreate("VideoLAN.VLCPlugin.1")

_VLC_Startup()

$tFile = FileOpenDialog ("Select media", "", "All files (*.*)")
If $tFile <> "" Then
    _VLC_OpenFile($tFile)
Else
    Exit
EndIf

;//Demo
_VLC_Play()
Sleep (5000)
_VLC_Pause()
Sleep (3000)
_VLC_Play()
_VLC_SetVolume(5)
Sleep (5000)
_VLC_SetVolume(100)
Sleep (2500)
_VLC_SetVolume()
Sleep (2500)
_VLC_Stop()

Func _VLC_Startup($_VLC_AutoLoop=0, $_VLC_AutoPlay=0, $_VLC_Visible=1, $_VLC_Volume=50)
    With $oVLC
        .AutoLoop        =   $_VLC_AutoLoop
        .AutoPlay        =   $_VLC_AutoPlay
        .Visible         =   $_VLC_Visible
        .Volume          =   $_VLC_Volume
    EndWith
EndFunc

Func _VLC_OpenFile($_VLC_File)
    
    If not FileExists ($_VLC_File) Then
        SetError(1)
        Return -1
    Else
        $oVLC.MRL       =   $_VLC_File
        Return 1
    EndIf
    
EndFunc

Func _VLC_Play()
    
    $oVLC.Play()
    
EndFunc

Func _VLC_Pause()
    
    $oVLC.Pause()
    
EndFunc

Func _VLC_Stop()
    
    $oVLC.Stop()
    
EndFunc

Func _VLC_SetVolume($_VLC_SetVolume=50)
    
    $oVLC.Volume        =   $_VLC_SetVolume
    
EndFunc

Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
            )
  SetError(1)  ; to check for after this function returns
Endfunc

Also, is there anyway to make this start full screen by default?

Edited by Dampe
  • 3 weeks later...
Posted

I think the com support was taken out of VLC 0.9xx can anyone else confirm?

This should work with the older 0.8xx versions

  • 5 years later...
Posted

Hi Ptrex, I know it is quite an old thread but by the way, is it possible to capture a video stream? 

thanks a lot and regards.

  • 3 years later...
Posted
On 8/3/2014 at 1:09 PM, jcpetu said:

Hi Ptrex, I know it is quite an old thread but by the way, is it possible to capture a video stream? 

thanks a lot and regards.

Even older thread now, but I'm extremely interested in capturing video with autoit. I've had some luck with ffmpeg.

Jceptu, what did you end up doing?

Regards

George

Posted

I have not been using VLC for ages now, so I can't tell if they are still having COM support at the moment ?

But as mentioned in the internet in many examples you can easily use the commandline interface ...

See here : https://www.computing.net/answers/programming/looking-for-a-vbscript-to-stream-record-using-videolan/30512.html

In combination with :

Run(@WindowsDir & "\VLC.exe", "", @SW_MAXIMIZE)

 

 

 

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
  • Recently Browsing   0 members

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