Sign in to follow this  
Followers 0
ptrex

VLC Media Player

14 posts in this topic

#1 ·  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

Share this post


Link to post
Share on other sites



@ptrex

briliant !! Good job :P and useful COM udf

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

@ptrex

Of course, im waiting for this improvements :P

Cheers, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

line 41 is $oVLC_Object = GUICtrlCreateObj ($hGui, 10, 70 , 700 , 460)

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

All this fails to [link snipped] !

Edited by SmOke_N

Share this post


Link to post
Share on other sites

#11 ·  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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0