Mediaplayer der mehrere Formate abspielen kann

  • HI ,
    Ich wollte mit einem Freund einen Mediaplayer erstellen...
    ... der .mp1-4 ; .mpeg4 ; .3gp ; .avi ; .flv abspielt...
    Wisst ihr vllt. wie ich da verschiedene codecs oder so was ähnliches benutzen kann??

  • ja darauf bin ich auch schon gekommen nur find ich nix O.o
    ich hab versucht von real player und vlc player die codecs zu klauen :D aber in den dll's da sind nur immer wieder die gleichen func's und die heißen alle iwie plugin O.o
    dll's sind nicht mein Ding O.o

  • Es gibt da glaub ich noch die LibVLC.dll die sich einfach ansteuern lassen sollte.

    mit einfachen dll-funktionen wie: VLC_Play, VLC_Pause, VLC_Stop ...

    Kann grad nicht nachsehen, ob die bei der "normalen" Version schon dabei ist...

    Das muß ich mir demnächst mal genauer ansehen, wenn ich mal wieder etwas Zeit hab...


    lgE

  • ^^ An sowas sitze ich auch gerade ^^


    Aber wie kann ich nun festlegen wo das Video in der Gui erscheinen soll?

    Mit VLC_PositionSet ?^^
    Oder ist das etwas anderes ?


    Lg

    Lenny


    PS: Ja sie ist dabei.

    Jaja, Moo does the Cow!

  • In diesem Beispiel wird der Dll ein Array übergeben - Geht das überhaupt mit AutoIt?!?

    Man kann jedoch die Funktion auch so aufrufen:
    VLC_Init(1,0,Nil)
    (erster Parameter ist die Instanz von VLC, zweiter Parameter die Größe des Arrays, 3 Parameter ist das Array)
    also: 2 Param=0 und 3 Param=Nil - Funktioniert anscheinent in Delphi, aber wie kriegt man Nil in Autoit zustande? (Nil= Nichts oder None)
    hab schon "" , 0 , Chr(0) und was weiß ich probiert...

    Also:
    1) Weiß jemand, wie man in Autoit mit DllCall ein Array als Parameter übergeben kann?
    2) Wie Übergibt man den Delphiparameter "Nil"?

    *Daumenhaltdaßunsdajemandhelfenkann*

    ;)E

    //Edit: Das Array des 3 Parameters kann die normalen Commandlineparameter von VLC enthalten; Ein 1-Dimensionales Array mit "dvd://F:" würde z.b. eine DVD im Laufwerk F: abspielen usw...

  • So, geht das als String-Array durch?

    Spoiler anzeigen
    [autoit]

    Func _STRStruct($str)
    Local $struct = DllStructCreate("char[" & StringLen($str) + 1 & "]")
    DllStructSetData($struct, 1, $str)
    Return $struct
    EndFunc ;==>_TDL_WSTR

    [/autoit] [autoit][/autoit] [autoit]

    $array = DllStructCreate("ptr[6]") ; PTR_Array mit 6 Einträgen :)
    Dim $Strings[6]
    $Strings[0] = _STRStruct("testvlcconsole.exe"); //your application name
    $Strings[1] = _STRStruct("dshow://";
    $Strings[0] = _STRStruct(":dshow-vdev=Logitech QuickCam Pro 3000 (08B0)");
    $Strings[0] = _STRStruct(":dshow-adev=");
    $Strings[0] = _STRStruct(":dshow-size=176x144");
    $Strings[0] = _STRStruct(":sout=#transcode{vcodec=h264,vb=1024,scale=1}:duplicate{dst=rtp{mux=ts,dst=192.168.0.155,port=1234}}");

    [/autoit] [autoit][/autoit] [autoit]

    DllStructSetData($array,1,DllStructGetPtr($Strings[0]))
    DllStructSetData($array,2,DllStructGetPtr($Strings[1]))
    DllStructSetData($array,3,DllStructGetPtr($Strings[2]))
    DllStructSetData($array,4,DllStructGetPtr($Strings[3]))
    DllStructSetData($array,5,DllStructGetPtr($Strings[4]))
    DllStructSetData($array,6,DllStructGetPtr($Strings[5]))

    [/autoit]


    //Edit: Vllt. könnte man da eine UDF draus machen :)

  • Danke für diesen Ansatz, leider klappt das nicht!

    Hab zum testen eine Pascal-Dll geschrieben, welcher ich dann das Array übergebe;
    Autoit endet direkt beim DllCall mit:

    Code
    AutoIT3.exe ended.rc:-1073741819

    Edit: Blödsinn, meine TestDll funktioniert nicht, weil es ein Void_Pointer sein soll und kein Array of PChar!

    mit Vlc geht es leider auch nicht, da kommt "der Befehl "written" konnte auf dem Speicher nicht durchgeführt werden"!

    werd mal weiter probieren..

    lgE

  • Andererseits bin ich mit der Lösung aus dem englischen Forum ganz zufrieden;)
    Das reicht für meine Zwecke, und vielleicht auch für den Thread-Starter?

    Example

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <SliderConstants.au3>
    #include <Constants.au3>
    #include "MCI_Video.au3"

    [/autoit] [autoit][/autoit] [autoit]

    Global $sVideoFile, $vID
    Global $ApW = 350, $ApH = 350
    Global $Hotkey, $FullScreen, $Vol = 100, $Paused

    [/autoit] [autoit][/autoit] [autoit]

    $hGui = GUICreate("My Video Player", $ApW, $ApH, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_CLIPCHILDREN))
    GUISetBkColor(0x000000, $hGui)

    [/autoit] [autoit][/autoit] [autoit]

    $FileMenu = GUICtrlCreateMenu("&File")
    $FileOpen = GUICtrlCreateMenuItem("&Open" & @TAB & "Ctrl+O", $FileMenu)
    $FileClose = GUICtrlCreateMenuItem("&Close" & @TAB & "Ctrl+C", $FileMenu)
    GUICtrlCreateMenuItem("", $FileMenu)
    $FileExit = GUICtrlCreateMenuItem("E&xit" & @TAB & "Esc", $FileMenu)

    [/autoit] [autoit][/autoit] [autoit]

    $ViewMenu = GUICtrlCreateMenu("&View")
    $ViewFullScreen = GUICtrlCreateMenuItem("Full Screen" & @TAB & "Alt+Enter", $ViewMenu)
    $ViewTopMost = GUICtrlCreateMenuItem("Topmost" & @TAB & "Alt+T", $ViewMenu)

    [/autoit] [autoit][/autoit] [autoit]

    $PlayMenu = GUICtrlCreateMenu("&Play")
    $PlayPause = GUICtrlCreateMenuItem("&Play/Pause" & @TAB & "Space", $PlayMenu)
    $PlayStop = GUICtrlCreateMenuItem("&Stop" & @TAB & "Period", $PlayMenu)
    GUICtrlCreateMenuItem("", $PlayMenu)
    $PlaySNS = GUICtrlCreateMenuItem("Slide &N Seek" & @TAB & "Ctrl+N", $PlayMenu)
    GUICtrlCreateMenuItem("", $PlayMenu)
    $PlayMute = GUICtrlCreateMenuItem("&Mute" & @TAB & "Ctrl+M", $PlayMenu)
    $Seek = GUICtrlCreateSlider(0, $ApH - 69, $ApW, 27, BitOR($TBS_NOTICKS, $TBS_BOTH))
    GUICtrlSetLimit(-1, 200, 0)
    GUICtrlSetResizing(-1, 576)
    GUICtrlSetBkColor(-1, 0x000000)
    GUICtrlSetState(-1, $GUI_DISABLE)
    $LableSeek = GUICtrlCreateLabel("Time: 00:00:00 / 00:00:00", 8, $ApH - 39, $ApW - 166, 16)
    GUICtrlSetFont(-1, 9, 700)
    GUICtrlSetResizing(-1, 834)
    GUICtrlSetColor(-1, 0x00ff00)

    [/autoit] [autoit][/autoit] [autoit]

    $LableVol = GUICtrlCreateLabel(" Volume: 100", $ApW - 156, $ApH - 39, 74, 16)
    GUICtrlSetFont(-1, 9, 700)
    GUICtrlSetResizing(-1, 836)
    GUICtrlSetColor(-1, 0x00ff00)
    $Volume = GUICtrlCreateSlider($ApW - 81, $ApH - 41, 80, 20, BitOR($TBS_NOTICKS, $TBS_BOTH))
    GUICtrlSetLimit(-1, 100, 0)
    GUICtrlSetData(-1, $Vol)
    GUICtrlSetResizing(-1, 832)
    GUICtrlSetBkColor(-1, 0x000000)

    [/autoit] [autoit][/autoit] [autoit]

    GUISetState(@SW_SHOW, $hGui)

    [/autoit] [autoit][/autoit] [autoit]

    $WGP = WinGetPos($hGui)
    $ApW = $WGP[2]
    $ApH = $WGP[3]

    [/autoit] [autoit][/autoit] [autoit]

    AdlibEnable("CheckEvents", 250)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $msg = GUIGetMsg()
    Switch $msg
    Case $GUI_EVENT_CLOSE, $FileExit
    Quit()
    Case $FileOpen
    OpenFile()
    Case $FileClose
    CloseFile()
    Case $ViewFullScreen
    ToggleFullScreen()
    Case $ViewTopMost
    ToggleTopmost()
    Case $PlayPause
    TogglePause()
    Case $PlayStop
    Stop()
    Case $PlaySNS
    SlideNSeek()
    Case $PlayMute
    Mute()
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func CheckEvents()
    ;Set and Unset hotkeys
    If WinActive($hGui) And Not $Hotkey Then
    SetHotkeys()
    ElseIf Not WinActive($hGui) And $Hotkey Then
    SetHotkeys()
    EndIf

    ;Set Volume
    If $Vol <> GUICtrlRead($Volume) Then
    $Vol = GUICtrlRead($Volume)
    GUICtrlSetData($LableVol, " Volume: " & $Vol)
    _Video_Volume($vID, $Vol)
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    ;Set seeking
    Local $GGCI = GUIGetCursorInfo($hGui)
    If IsArray($GGCI) And Not $GGCI[2] And $vID <> "" Then
    GUICtrlSetData($LableSeek, "Time: " & _Video_TimePos($vID) & " / " & _Video_Length($vID))
    GUICtrlSetData($Seek, (200 / _Video_Length($vID, 1)) * _Video_TimePos($vID, 1))
    EndIf
    If IsArray($GGCI) And $GGCI[4] = $Seek And $GGCI[2] And $vID <> "" Then
    Local $SeekPos
    While $GGCI[2]
    $GGCI = GUIGetCursorInfo($hGui)
    $SeekPos = Round((_Video_Length($vID, 1) * GUICtrlRead($Seek)) / 200)
    If BitAND(GUICtrlRead($PlaySNS), $GUI_CHECKED) Then
    _Video_Seek($vID, $SeekPos)
    GUICtrlSetData($LableSeek, "Time: " & _Video_TimePos($vID) & " / " & _Video_Length($vID))
    Else
    GUICtrlSetData($LableSeek, "Time: " & _MSToHMS($SeekPos) & " / " & _Video_Length($vID))
    EndIf
    Sleep(10)
    WEnd
    If BitAND(GUICtrlRead($PlaySNS), $GUI_UNCHECKED) Then _Video_Seek($vID, $SeekPos)
    If Not $Paused Then TogglePause()
    EndIf
    EndFunc ;==>CheckEvents

    [/autoit] [autoit][/autoit] [autoit]

    Func Stop()
    _Video_Stop($vID)
    EndFunc ;==>Stop

    [/autoit] [autoit][/autoit] [autoit]

    Func SetHotkeys()
    If $Hotkey Then
    $Hotkey = 0
    HotKeySet("^c")
    HotKeySet("^m")
    HotKeySet("^n")
    HotKeySet("^o")
    HotKeySet("^.")
    HotKeySet("!t")
    HotKeySet("{SPACE}")
    Else
    $Hotkey = 1
    HotKeySet("^c", "CloseFile")
    HotKeySet("^m", "Mute")
    HotKeySet("^n", "SlideNSeek")
    HotKeySet("^o", "OpenFile")
    HotKeySet(".", "Stop")
    HotKeySet("!{ENTER}", 'ToggleFullScreen')
    HotKeySet("!t", 'HkTopmost')
    HotKeySet("{SPACE}", "TogglePause")
    EndIf
    EndFunc ;==>SetHotkeys

    [/autoit] [autoit][/autoit] [autoit]

    Func OpenFile()
    Local $FOD = FileOpenDialog("Select a video to play.", "", "Video (*.avi;*.mpg;*.mpg;*.wmv)", 3)
    If Not @error Then
    If _Video_Status($vID) <> "" Then _Video_Close($vID)
    $sVideoFile = $FOD
    Local $aWH = _Video_Dimension($sVideoFile), $iX, $iY
    $vID = _Video_Open($sVideoFile, $hGui, 0, 0, $aWH[0], $aWH[1], "MPEGVideo")
    $iX = (@DesktopWidth / 2) - ($aWH[0] / 2)
    $iY = ((@DesktopHeight / 2) - ($aWH[1] / 2)) - 50
    SetWindowPos($hGui, 0, $iX, $iY, $aWH[0], $aWH[1] + 100, 0x64)
    _Video_Volume($vID, $Vol)
    _Video_Play($vID)
    GUICtrlSetState($Seek, $GUI_ENABLE)
    EndIf
    EndFunc ;==>OpenFile

    [/autoit] [autoit][/autoit] [autoit]

    Func CloseFile()
    _Video_Close($vID)
    $sVideoFile = ""
    GUICtrlSetState($Seek, $GUI_DISABLE)
    GUICtrlSetData($LableSeek, "Time: 00:00:00 / 00:00:00")
    WinMove($hGui, "", (@DesktopWidth / 2) - ($ApW / 2), ((@DesktopHeight / 2) - ($ApH / 2)), $ApW, $ApH)
    EndFunc ;==>CloseFile

    [/autoit] [autoit][/autoit] [autoit]

    Func ToggleFullScreen()
    If $FullScreen Then
    $FullScreen = 0
    _Video_Play($vID)
    SetWindowPos($hGui, ToggleTopmost(1), 0, 0, 0, 0, 0x63)
    Else
    $FullScreen = 1
    SetWindowPos($hGui, -1, 0, 0, 0, 0, 0x43)
    _Video_Play($vID, 1)
    EndIf
    EndFunc ;==>ToggleFullScreen

    [/autoit] [autoit][/autoit] [autoit]

    Func HkTopmost()
    ToggleTopmost()
    EndFunc ;==>HkTopmost

    [/autoit] [autoit][/autoit] [autoit]

    Func ToggleTopmost($iState = 0)
    If BitAND(GUICtrlRead($ViewTopMost), $GUI_CHECKED) Then
    If Not $iState Then
    SetWindowPos($hGui, -2, 0, 0, 0, 0, 0x43)
    GUICtrlSetState($ViewTopMost, $GUI_UNCHECKED)
    Else
    Return -1
    EndIf
    Else
    If Not $iState Then
    SetWindowPos($hGui, -1, 0, 0, 0, 0, 0x43)
    GUICtrlSetState($ViewTopMost, $GUI_CHECKED)
    Else
    Return -2
    EndIf
    EndIf
    EndFunc ;==>ToggleTopmost

    [/autoit] [autoit][/autoit] [autoit]

    Func TogglePause()
    Switch _Video_Status($vID)
    Case "playing"
    _Video_Pause($vID)
    $Paused = 1
    Case "paused"
    _Video_Resume($vID)
    $Paused = 0
    Case "stopped"
    _Video_Play($vID)
    $Paused = 0
    EndSwitch
    EndFunc ;==>TogglePause

    [/autoit] [autoit][/autoit] [autoit]

    Func SlideNSeek()
    If BitAND(GUICtrlRead($PlaySNS), $GUI_CHECKED) Then
    GUICtrlSetState($PlaySNS, $GUI_UNCHECKED)
    Else
    GUICtrlSetState($PlaySNS, $GUI_CHECKED)
    EndIf
    EndFunc ;==>SlideNSeek

    [/autoit] [autoit][/autoit] [autoit]

    Func Mute()
    Switch _Video_Status($vID, "audio")
    Case "off"
    _Video_Mute($vID)
    Case "on"
    _Video_Mute($vID, 1)
    EndSwitch
    EndFunc ;==>Mute

    [/autoit] [autoit][/autoit] [autoit]

    Func Quit()
    _Video_Close($vID)
    Exit
    EndFunc ;==>Quit

    [/autoit] [autoit][/autoit] [autoit]

    Func SetWindowPos($hWnd, $hAfter, $iX, $iY, $iCX, $iCY, $iFlags)
    DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", $hAfter, _
    "int", $iX, "int", $iY, "int", $iCX, "int", $iCY, "int", $iFlags)
    EndFunc ;==>SetWindowPos

    [/autoit]

    UDF:

    Spoiler anzeigen
    [autoit]

    #include-once

    [/autoit] [autoit][/autoit] [autoit]

    ; #CURRENT# ===============================================================================================
    ; _Video_Close
    ; _Video_Dimension
    ; _Video_FrameRate
    ; _Video_Length
    ; _Video_Mute
    ; _Video_Open
    ; _Video_Pause
    ; _Video_Play
    ; _Video_Resume
    ; _Video_Seek
    ; _Video_Status
    ; _Video_Step
    ; _Video_Stop
    ; _Video_TimePos
    ; _Video_Volume
    ; _RandomStr
    ; _MSToHMS
    ; _mciDeviceExists
    ; _mciListDevices
    ; _mciSendString
    ;==========================================================================================================

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _Video_Close
    ; Description....: Close a video.
    ; Syntax.........: _Video_Close($sAlias)
    ; Parameters ....: $sAlias - Alias name returned by _Video_Open.
    ; Return values .: Success - Return 1 and sets Alias name to "".
    ; Failure - Return 0 and @error 1~2
    ; @error 1 = Invalid Alias
    ; @error 2 = MCI failed to close video
    ; Author ........: smashly
    ; =========================================================================================================
    Func _Video_Close(ByRef $sAlias)
    If $sAlias = "" Or StringRegExp($sAlias, "\W|_", 0) Then Return SetError(1, 0, 0)
    If _mciSendString("close " & $sAlias) = 0 Then
    $sAlias = ""
    Return SetError(0, 0, 1)
    Else
    Return SetError(2, 0, 0)
    EndIf
    EndFunc ;==>_Video_Close

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _Video_Dimension
    ; Description....: Retrieves the Width and Height of the source video.
    ; Syntax.........: _Video_Dimension($sFile)
    ; Parameters ....: $sFile - The full path to video file.
    ; Return values .: Success - Returns an array. array[0] = Width, array[1] = Height
    ; Failure - Return 0 and @error 1~3
    ; @error 1 = File doesn't exist.
    ; @error 2 = MCI failed to open the video file.
    ; @error 3 = MCI failed to get the source video dimensions.
    ; Author ........: smashly
    ; =========================================================================================================
    Func _Video_Dimension($sFile)
    Local $iRet, $sVID, $aTmp
    If Not FileExists($sFile) Then Return SetError(1, 0, 0)
    $sVID = _RandomStr()
    $iRet = _mciSendString("open " & FileGetShortName($sFile) & " alias " & $sVID)
    If $iRet <> 0 Then Return SetError(2, 0, 0)
    $iRet = _mciSendString("where " & $sVID & " source", 255)
    If $iRet = "" Then
    _mciSendString("close " & $sVID)
    Return SetError(3, 0, 0)
    EndIf
    _mciSendString("close " & $sVID)
    $aTmp = StringSplit($iRet, Chr(32))
    $aTmp[1] = $aTmp[$aTmp[0]]
    $aTmp[0] = $aTmp[$aTmp[0] - 1]
    ReDim $aTmp[2]
    Return $aTmp
    EndFunc ;==>_Video_Dimension

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _Video_FrameRate
    ; Description....: Close a video.
    ; Syntax.........: _Video_FrameRate($sAlias)
    ; Parameters ....: $sAlias - Alias name returned by _Video_Open.
    ; Return values .: Success - Returns the Frames Per Second of the video.
    ; Failure - Return 0 and @error 1
    ; @error 1 = Invalid Alias
    ; Author ........: smashly
    ; =========================================================================================================
    Func _Video_FrameRate($sAlias)
    If $sAlias = "" Or StringRegExp($sAlias, "\W|_", 0) Then Return SetError(1, 0, 0)
    Return _mciSendString("status " & $sAlias & " nominal frame rate", 255) / 1000
    EndFunc ;==>_Video_FrameRate

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _Video_Length
    ; Description....: Get the time length of a video in Milliseconds or Hours, Minutes, Seconds (HH:MM:SS)
    ; Syntax.........: _Video_Length($sAlias[, $iTime = 0])
    ; Parameters ....: $sAlias - Alias name returned by _Video_Open
    ; $iTime - 0 Return time lenth in Hours, Minutes, Seconds (HH:MM:SS)
    ; - 1 Return time lenth in Milliseconds.
    ; Return values .: Success - Return time length in Milliseconds or Hours, Minutes, Seconds (HH:MM:SS)
    ; Failure - Return 0 and @error 1
    ; @error 1 = Invalid Alias
    ; Author ........: smashly
    ; =========================================================================================================
    Func _Video_Length($sAlias, $iTime = 0)
    Local $iMS
    If $sAlias = "" Or StringRegExp($sAlias, "\W|_", 0) Then Return SetError(1, 0, 0)
    _mciSendString("set " & $sAlias & " time format ms")
    $iMS = _mciSendString("status " & $sAlias & " length", 255)
    If Not $iTime Then Return _MSToHMS($iMS)
    If $iTime Then Return $iMS
    EndFunc ;==>_Video_Length

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _Video_Mute
    ; Description....: Turn off/on the audio in a video.
    ; Syntax.........: _Video_Mute($sAlias[, $iMute = 0])
    ; Parameters ....: $sAlias - Alias name returned by _Video_Open.
    ; $iAudio - 0 = Audio On, 1 = Audio Off
    ; Return values .: Success - Return 1 and @error 0
    ; Failure - Return 0 and @error 1~2
    ; @error 1 = Invalid Alias
    ; @error 2 = MCI failed to turn the video audio off/on
    ; Author ........: smashly
    ; =========================================================================================================
    Func _Video_Mute($sAlias, $iMute = 0)
    Local $iRet, $iAM = "on"
    If $sAlias = "" Or StringRegExp($sAlias, "\W|_", 0) Then Return SetError(1, 0, 0)
    If $iMute Then $iAM = "off"
    $iRet = _mciSendString("set " & $sAlias & " audio all " & $iAM)
    If $iRet = 0 Then
    Return SetError(0, 0, 1)
    Else
    Return SetError(2, 0, 0)
    EndIf
    EndFunc ;==>_Video_Mute

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _Video_Open
    ; Description ...: Opens a Video file ready for use with other _Video_xxxx functions.
    ; Syntax.........: _Video_Open($sFile, $hWnd, $iX, $iY, $iW, $iH[, $sDevice = ""])
    ; Parameters ....: $sFile - The full path to video file.
    ; $hWnd - Handle to a window or control that the video will be displayed on
    ; $iX - Left position of the video.
    ; $iY - Top position of the video.
    ; $iW - Width of the video.
    ; $iH - Height of the video.
    ; $sDevice - MCI Device type to play video with. (See Remarks for more info)
    ; Return values .: Success - Return an Alias name for use with other _Video_xxxx functions.
    ; Failure - Return an empty String "" and @error 1~5
    ; @error 1 = File doesn't exist
    ; @error 2 = Window or Control handle not valid.
    ; @error 3 = Invalid MCI Device type specified.
    ; @error 4 = MCI failed to open video file
    ; @error 5 = MCI failed window for video.
    ; @error 5 = MCI failed to put video at the deignated location.
    ; Author ........: smashly
    ; Remarks .......: If your having trouble with avi playback (eg; playing fast, slow, choppy or no audio)
    ; or a video won't play but it plays fine in any other player ...
    ; Then set the $sDevice parameter to "MPEGVideo"
    ; If the $sDevice parameter is left blank then windows will decide which MCI Device type
    ; to use.
    ; Most current day avi/wmv/mp4 formats dont play properly or at all when windows selects
    ; the mci device type to use.
    ; Windows would default use "AVIVideo" MCI Device type to play avi with mci.
    ; When you specify "MPEGVideo" for an avi and mci fails it then uses the windows native
    ; chain of codecs that would be used by any other player not using mci ;)
    ; Because of this behaviour you can usually play almost any type of video that normally
    ; fails when using mci just by specifying "MPEGVideo" mci device type.
    ; For playing video on an autoit gui then be sure to add the $WS_CLIPCHILDREN style
    ; to your Gui. This will keep the Video dislpayed on your Gui all the time.
    ; =========================================================================================================
    Func _Video_Open($sFile, $hWnd, $iX, $iY, $iH, $iW, $sDevice = "")
    Local $sVID, $gId, $iRet, $sDT = ""
    If Not FileExists($sFile) Then Return SetError(1, 0, "")
    If Not IsHWnd($hWnd) Then Return SetError(2, 0, "")
    If $sDevice <> "" Then
    If Not _mciDeviceExists($sDevice) Then Return SetError(3, 0, "")
    $sDT = " type " & $sDevice
    EndIf
    $gId = Dec(StringTrimLeft($hWnd, 2))
    $sVID = _RandomStr()
    $iRet = _mciSendString("open " & FileGetShortName($sFile) & " alias " & $sVID & $sDT)
    If $iRet <> 0 Then Return SetError(4, 0, "")
    $iRet = _mciSendString("window " & $sVID & " handle " & $gId)
    If $iRet <> 0 Then
    _mciSendString("close " & $sVID)
    Return SetError(5, 0, "")
    EndIf
    $iRet = _mciSendString("put " & $sVID & " destination at " & $iX & " " & $iY & " " & $iH & " " & $iW)
    If $iRet <> 0 Then
    _mciSendString("close " & $sVID)
    Return SetError(6, 0, "")
    EndIf
    Return SetError(0, 0, $sVID)
    EndFunc ;==>_Video_Open

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _Video_Pause
    ; Description....: Pause a Video at the current playing position.
    ; Syntax.........: _Video_Pause($sAlias)
    ; Parameters ....: $sAlias - Alias name returned by _Video_Open.
    ; Return values .: Success - Return 1 and @error 0
    ; Failure - Return 0 and @error 1~2
    ; @error 1 = Invalid Alias
    ; @error 2 = Failed to pause video.
    ; Author ........: smashly
    ; =========================================================================================================
    Func _Video_Pause($sAlias)
    Local $iRet
    If $sAlias = "" Or StringRegExp($sAlias, "\W|_", 0) Then Return SetError(1, 0, 0)
    $iRet = _mciSendString("pause " & $sAlias)
    If $iRet = 0 Then
    Return SetError(0, 0, 1)
    Else
    Return SetError(2, 0, 0)
    EndIf
    EndFunc ;==>_Video_Pause

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _Video_Play
    ; Description....: Plays a Video from the current position.
    ; Syntax.........: _Video_Play($sAlias[, $iMode = 0])
    ; Parameters ....: $sAlias - Alias name returned by _Video_Open.
    ; $iMode - 0 play video on the window or control as specified in _Video_Open
    ; - 1 play video in Fullscreen mode.
    ; Return values .: Success - Return 1 and @error 0
    ; Failure - Return 0 and @error 1~2
    ; @error 1 = Invalid Alias
    ; @error 2 = MCI failed to play video.
    ; Author ........: smashly
    ; =========================================================================================================
    Func _Video_Play($sAlias, $iMode = 0)
    Local $iRet
    If $sAlias = "" Or StringRegExp($sAlias, "\W|_", 0) Then Return SetError(1, 0, 0)
    If _Video_TimePos($sAlias, 1) = _Video_Length($sAlias, 1) Then _Video_Seek($sAlias, "start")
    If $iMode Then
    $vRet = _mciSendString("play " & $sAlias & " fullscreen")
    Else
    $iRet = _mciSendString("play " & $sAlias)
    EndIf
    If $iRet = 0 Then
    Return SetError(0, 0, 1)
    Else
    Return SetError(1, 0, 0)
    EndIf
    EndFunc ;==>_Video_Play

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _Video_Resume
    ; Description....: Resume playing a video after pausing.
    ; Syntax.........: _Video_Resume($sAlias)
    ; Parameters ....: $sAlias - Alias name returned by _Video_Open.
    ; Return values .: Success - Return 1 and @error 0
    ; Failure - Return 0 and @error 1~2
    ; @error 1 = Invalid Alias
    ; @error 2 = MCI failed to resume video.
    ; Author ........: smashly
    ; =========================================================================================================
    Func _Video_Resume($sAlias)
    Local $iRet
    If $sAlias = "" Or StringRegExp($sAlias, "\W|_", 0) Then Return SetError(1, 0, 0)
    $iRet = _mciSendString("resume " & $sAlias)
    If $iRet = 0 Then
    Return SetError(0, 0, 1)
    Else
    Return SetError(2, 0, 0)
    EndIf
    EndFunc ;==>_Video_Resume

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _Video_Seek
    ; Description....: Seek a video to the specified time position.
    ; Syntax.........: _Video_Seek($sAlias, $iTime)
    ; Parameters ....: $sAlias - Alias name returned by _Video_Open.
    ; $iTime - Time to Seek. Can be Millisecons or HH:MM:SS or "start" or "end"
    ; Return values .: Success - Return 1 and @error 0
    ; Failure - Return 0 and @error 1~3
    ; @error 1 = Invalid Alias
    ; @error 2 = Invalid time format.
    ; @error 3 = MCI Seek error
    ; Author ........: smashly
    ; =========================================================================================================
    Func _Video_Seek($sAlias, $iTime)
    Local $iMS, $aTime, $iRet
    If $sAlias = "" Or StringRegExp($sAlias, "\W|_", 0) Then Return SetError(1, 0, 0)
    If StringInStr($iTime, ":") Then
    $aTime = StringSplit($iTime, ":")
    If $aTime[0] <> 3 Then Return SetError(2, 0, 0)
    $iMS = 1000 * ((3600 * $aTime[1]) + (60 * $aTime[2]) + $aTime[3])
    ElseIf StringIsInt($iTime) Or $iTime = "start" Or $iTime = "end" Then
    $iMS = $iTime
    Else
    Return SetError(2, 0, 0)
    EndIf
    _mciSendString("set " & $sAlias & " time format ms")
    $iRet = _mciSendString("seek " & $sAlias & " to " & $iMS)
    If $iRet = 0 Then
    Return SetError(0, 0, 1)
    Else
    Return SetError(3, 0, 0)
    EndIf
    EndFunc ;==>_Video_Seek

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _Video_Status
    ; Description....: Get a status status message from a video device.
    ; Syntax.........: _Video_Status($sAlias[, $sQuery = "mode"])
    ; Parameters ....: $sAlias - Alias name returned by _Video_Open
    ; $sQuery - What to get the status of:
    ; "audio" - returns the "on" or "off"
    ; "mode" - returns "paused", "playing" and "stopped"
    ; Return values .: Success - Returns a Status message from the video device.
    ; Failure - Return 0 and @error 1
    ; @error 1 = Invalid Alias
    ; @error 2 = Invalid query (To be implemented)
    ; Author ........: smashly
    ; =========================================================================================================
    Func _Video_Status($sAlias, $sQuery = "mode")
    If $sAlias = "" Or StringRegExp($sAlias, "\W|_", 0) Then Return SetError(1, 0, 0)
    ;; error check for the $sQuery goes here
    Return _mciSendString("status " & $sAlias & " " & $sQuery, 255)
    EndFunc ;==>_Video_Status

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _Video_Step
    ; Description....: Step a video forwards or backwards by a number of frames.
    ; Syntax.........: _Video_Step($sAlias, $iFrames)
    ; Parameters ....: $sAlias - Alias name returned by _Video_Open
    ; $iFrames - The number of frames to step, use negative numbers to step backwards.
    ; Return values .: Success - Returns 1 and @error 0
    ; Failure - Return 0 and @error 1~3
    ; @error 1 = Invalid Alias
    ; @error 2 = Invalid frames
    ; @error 3 = MCI Step error
    ; Author ........: smashly
    ; =========================================================================================================
    Func _Video_Step($sAlias, $iFrames)
    Local $iRet
    If $sAlias = "" Or StringRegExp($sAlias, "\W|_", 0) Then Return SetError(1, 0, 0)
    If StringRegExp(StringReplace($iFrames, "-", ""), '\D', 0) Then Return SetError(2, 0, 0)
    $iRet = _mciSendString("step " & $sAlias & " by " & $iFrames)
    If $iRet = 0 Then
    Return SetError(0, 0, 1)
    Else
    Return SetError(3, 0, 0)
    EndIf
    EndFunc ;==>_Video_Step

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _Video_Stop
    ; Description....: Stop a Video playing. (seeks video to start)
    ; Syntax.........: _Video_Stop($sAlias)
    ; Parameters ....: $sAlias - Alias name returned by _Video_Open.
    ; Return values .: Success - Return 1 and @error 0
    ; Failure - Return 0 and @error 1~2
    ; @error 1 = Invalid Alias
    ; @error 2 = Failed to stop or seek
    ; Author ........: smashly
    ;==========================================================================================================
    Func _Video_Stop($sAlias)
    Local $iRet, $iRet2
    If $sAlias = "" Or StringRegExp($sAlias, "\W|_", 0) Then Return SetError(1, 0, 0)
    $iRet = _Video_Seek($sAlias, "start")
    $iRet2 = _mciSendString("stop " & $sAlias)
    If $iRet = 0 And $iRet2 = 0 Then
    Return SetError(0, 0, 1)
    Else
    Return SetError(2, 0, 0)
    EndIf
    EndFunc ;==>_Video_Stop

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _Video_TimePos
    ; Description....: Get the time poition of a video in Milliseconds or Hours, Minutes, Seconds (HH:MM:SS)
    ; Syntax.........: _Video_TimePos($sAlias[, $iTime = 0])
    ; Parameters ....: $sAlias - Alias name returned by _Video_Open.
    ; $iTime - 0 Return time lenth in Hours, Minutes, Seconds (HH:MM:SS)
    ; - 1 Return time lenth in Milliseconds.
    ; Return values .: Success - Return time position in Milliseconds or Hours, Minutes, Seconds (HH:MM:SS)
    ; Failure - Return 0 and @error 1
    ; @error 1 = Invalid Alias
    ; Author ........: smashly
    ; =========================================================================================================
    Func _Video_TimePos($sAlias, $iTime = 0)
    Local $iMS
    If $sAlias = "" Or StringRegExp($sAlias, "\W|_", 0) Then Return SetError(1, 0, 0)
    _mciSendString("set " & $sAlias & " time format ms")
    $iMS = _mciSendString("status " & $sAlias & " position", 255)
    If Not $iTime Then Return _MSToHMS($iMS)
    If $iTime Then Return $iMS
    EndFunc ;==>_Video_TimePos

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _Video_Volume
    ; Description....: Turn the video audio volume up or down.
    ; Syntax.........: _Video_AudioVolume($sAlias[, $iVolume = 100])
    ; Parameters ....: $sAlias - Alias name returned by _Video_Open.
    ; $iVolume - 0 = Min, 100 = Max
    ; Return values .: Success - Return 1 and @error 0
    ; Failure - Return 0 and @error 1~2
    ; @error 1 = Invalid Alias
    ; @error 2 = Invalid Volume
    ; @error 3 = MCI failed to set volume
    ; Author ........: smashly
    ; =========================================================================================================
    Func _Video_Volume($sAlias, $iVolume = 100)
    Local $iRet, $iVol
    If $sAlias = "" Or StringRegExp($sAlias, "\W|_", 0) Then Return SetError(1, 0, 0)
    If StringRegExp($iVolume, '\D', 0) Then Return SetError(2, 0, 0)
    If $iVolume >= 100 Then
    $iVol = 1000
    ElseIf $iVolume <= 0 Then
    $iVol = 0
    ElseIf $iVolume > 0 And $iVolume < 100 Then
    $iVol = $iVolume * 10
    EndIf
    $iRet = _mciSendString("setaudio " & $sAlias & " volume to " & $iVol)
    If $iRet = 0 Then
    Return SetError(0, 0, 1)
    Else
    Return SetError(3, 0, 0)
    EndIf
    EndFunc ;==>_Video_Volume

    [/autoit] [autoit][/autoit] [autoit]

    ;==========================================================================================================
    ; Internal use functions beyond this point
    ;==========================================================================================================

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _MSToHMS
    ; Description....: Converts Milliseconds to Hours, Minutes, Seconds
    ; Syntax.........: _MSToHMS($iMS)
    ; Parameters ....: $iMS - Milliseconds to convert
    ; Return values .: Success - Returns Hours, Minutes, Seconds (HH:MM:SS)
    ; Author ........: smashly
    ; =========================================================================================================
    Func _MSToHMS($iMS)
    Local $iHours = 0, $iMins = 0, $iSecs = 0
    If Number($iMS) > 0 Then
    $iMS = Round($iMS / 1000)
    $iHours = Int($iMS / 3600)
    $iTicks = Mod($iMS, 3600)
    $iMins = Int($iTicks / 60)
    $iSecs = Round(Mod($iMS, 60))
    Return StringFormat("%02i:%02i:%02i", $iHours, $iMins, $iSecs)
    EndIf
    Return StringFormat("%02i:%02i:%02i", $iHours, $iMins, $iSecs)
    EndFunc ;==>_MSToHMS

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _RandomStr
    ; Description....: Creates a random string
    ; Syntax.........: _RandomStr([$iLen = 10])
    ; Parameters ....: $iLen - Length of string to return
    ; Return values .: Success - Returns a string of random letters (a~z)
    ; Author ........: RazerM
    ; =========================================================================================================
    Func _RandomStr($iLen = 10)
    Local $sTmp = ''
    For $i = 1 To $iLen
    $sTmp &= Chr(Random(97, 122, 1))
    Next
    Return $sTmp
    EndFunc ;==>_RandomStr

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _mciDeviceExists
    ; Description....: Check if a MCI Device type exists
    ; Syntax.........: _mciDeviceExists($sDevice)
    ; Parameters ....: $sDevice - Name of MCI Device type to check for
    ; Return values .: Success - Return 1 if MCI Device type exists and @error 0
    ; Failure - Return 0 if MCI Device type does not exist and @error 1~2
    ; @error 1 = No matching MCI Device type found.
    ; @error 2 = Failed to list any MCI Device types
    ; Author ........: smashly
    ; =========================================================================================================
    Func _mciDeviceExists($sDevice)
    Local $aDT = _mciListDevices()
    If @error Then Return SetError(2, 0, 0)
    For $idx = 1 To $aDT[0]
    If $sDevice = $aDT[$idx] Then Return SetError(0, 0, 1)
    Next
    Return SetError(1, 0, 0)
    EndFunc ;==>_mciDeviceExists

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _mciListDevices
    ; Description....: List all found MCI Device types in an array
    ; Syntax.........: _mciListDevices()
    ; Parameters ....: None
    ; Return values .: Success - Return 1D array of found MCI Device types and @error 0
    ; array[0] Number of MCI Device types found
    ; array[n] MCI Device type name
    ; Failure - Return empty 1D array and @error 1
    ; Author ........: smashly
    ; =========================================================================================================
    Func _mciListDevices()
    Local $iMD, $sTmp
    $iMD = _mciSendString("sysinfo all quantity", 255)
    If StringIsInt($iMD) Then
    For $idx = 1 To $iMD
    $sTmp &= _mciSendString("sysinfo all name " & $idx, 255) & Chr(0)
    Next
    Return SetError(0, 0, StringSplit(StringTrimRight($sTmp, 1), Chr(0)))
    EndIf
    Return SetError(1, 0, StringSplit($sTmp, Chr(0)))
    EndFunc ;==>_mciListDevices

    [/autoit] [autoit][/autoit] [autoit]

    ; #FUNCTION# ==============================================================================================
    ; Name...........: _mciSendString
    ; Description....:
    ; Syntax.........: _mciSendString($string[, $iLen = 0])
    ; Parameters ....: $string
    ; $iLen
    ; Return values .:
    ; Author ........: RazerM
    ; =========================================================================================================
    Func _mciSendString($string, $iLen = 0)
    Local $iRet
    $iRet = DllCall("winmm.dll", "int", "mciSendStringA", "str", $string, "str", "", "long", $iLen, "long", 0)
    If Not @error Then Return $iRet[2]
    EndFunc ;==>_mciSendString

    [/autoit]

    Original:
    http://www.autoitscript.com/forum/index.php?showtopic=79637

    lgE