Jump to content
Belini

UDF para rodar vídeos

Recommended Posts

Encontrei uma UDF feita pelo jscript que deve servir, ela usa o media player imbutido mas não tive como testar ela pois não consegui fechar o video que abri antes e assim a cada vez que coloco um video prá tocar ele toca o atual e os anteriores, alguém sabe como posso fechar o video antes de abrir outro e se posso colocar uma imagem no mesmo lugar do vídeo quando não encontrar arquivo de vídeo para tocar?

 

CODIGO DO JSCRIPT:

#include <guiconstantsex.au3>
#include <windowsconstants.au3>
#include <ButtonConstants.au3>
#include <WinAPI.au3>
#include <IE.au3>

_Example(@ScriptDir & "\teste.mp4") ; File name of media!

; example
Func _Example($sFileName)
    Local $hForm, $aiCliSize, $iCtrlID

    ;$hForm = GUICreate("MediaPlayer_Embedded!", 640, 480, -1, -1, BitOR($WS_POPUP, $WS_SIZEBOX), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
    ;$aiCliSize = WinGetClientSize($hForm)
    ;$iCtrlID = _MediaPlayerEmbeded($sFileName, -2, -2, 640, 490)
    ;GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
    ; Or
    $hForm = GUICreate("MediaPlayer_Embedded!", 640, 480, -1, -1, $WS_POPUP)
    $aiCliSize = WinGetClientSize($hForm)

    $iCtrlID = _MediaPlayerEmbeded($sFileName, 1, 1, $aiCliSize[0], $aiCliSize[1])


    GUISetState()

    ;Sleep(2000)
    ;GUICtrlSetState($iCtrlID, $GUI_HIDE)
    ;Sleep(2000)
    ;GUICtrlSetState($iCtrlID, $GUI_SHOW)

    ; Run the GUI until the dialog is closed
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
        EndSwitch
    WEnd
EndFunc ;==>_Example

; #FUNCTION# ====================================================================================================================
; Name ..........: _MediaPlayerEmbeded
; Description ...:
; Syntax ........: _MediaPlayerEmbeded( $sFileName, $iLeft, $iTop, $iWidth, $iHeight )
; Parameters ....: $sFileName - A string value.
; $iLeft - An integer value.
; $iTop - An integer value.
; $iWidth - An integer value.
; $iHeight - An integer value.
; Return values .: None
; Author ........: JScript
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: _MediaPlayerEmbeded($sFileName, $iLeft, $iTop, $iWidth, $iHeight)
; ===============================================================================================================================
Func _MediaPlayerEmbeded($sFileName, $iLeft, $iTop, $iWidth, $iHeight)
    Local $oShell, $sInnerHTML, $iCtrlID

    $sInnerHTML = '<object id="player" height="100%" width="100%" align="middle" ' & _
            'classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"> ' & _
            ' <param name="URL" value="' & $sFileName & '">' & _
            ' <param name="uiMode" value="none"> ' & _
            ' <param name="fullScreen" value="false"> ' & _
            ' <param name="ShowControls" value="true"> ' & _
            ' <param name="ShowStatusBar" value="true"> ' & _
            ' <param name="ShowDisplay" value="true"> ' & _
            ' <embed type="application/x-mplayer2" ' & _
            ' pluginspage = "http://www.microsoft.com/Windows/MediaPlayer/" ' & _
            ' SRC="' & $sFileName & '"' & _
            '</embed></object>'

    $oShell = ObjCreate("Shell.Explorer")
    $iCtrlID = GUICtrlCreateObj($oShell, $iLeft, $iTop, $iWidth, $iHeight)

    $oShell.navigate("about:blank")
    While $oShell.Busy()
        Sleep(10)
    WEnd
    With $oShell.document
        .write('<HEAD><TITLE></TITLE><script language="javascript"></script></HEAD>')
        .write('<body onselectstart="return false" oncontextmenu="return false" onclick="return false" ondragstart="return false" ondragover="return false">')
        .body.innerHTML = $sInnerHTML
        .body.topmargin = 0
        .body.leftmargin = 0
        .body.scroll = "no"
        .body.bgcolor = 0x000000
        .body.style.borderWidth = 0
    EndWith

    Return $iCtrlID
EndFunc ;==>_MediaPlayerEmbeded

Func WM_NCHITTEST($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam

    Local $iDef = _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam)

    Switch $iDef
        Case $HTSYSMENU, $HTBOTTOM, $HTBOTTOMLEFT, $HTBOTTOMRIGHT, $HTLEFT, $HTRIGHT, $HTTOP, $HTTOPLEFT, $HTTOPRIGHT
            Return $HTCAPTION; -1 to not moving!
    EndSwitch

    Return $iDef
EndFunc ;==>WM_NCHITTEST
Edited by Belini

Share this post


Link to post
Share on other sites

@Belini Eu vi um post seu em um forum gringo que você recomenda essa UDF do smashly para rodar vídeos. A do Jscript é melhor? Tem alguns exemplos? Aparentemente o do Jscript vai ter que fazer uma Gui e depois deleta-la com GUICtrlDelete sempre que for tocar um mp4 novo. Esse que você postou em um forum gringo tem tudo! até a posição do frame desejada, só que eu não consegui fazer ela funcionar. Eu queria rodar videos sem a necessidade de instalar outro programa de codec's.

 

O ultimo udf de baixo foi o melhor que achei. Bem completo mesmo. E ele fecha se abrir um outro video, imagem, audio por cima. Muito bom mesmo.

 

Essa eu não consegui fazer funcionar.

#include-once

; #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
;==========================================================================================================

; #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

; #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

; #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

; #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

; #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

; #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

; #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

; #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

; #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

; #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

; #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

; #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

; #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

; #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

; #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

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

; #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($iMS / 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

; #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

; #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

; #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

; #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



Outro exemplo que achei no forum gringo: Ainda não testei.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Sound.au3>

HotKeySet('!{ENTER}', 'FullScreen') ; Alt + Enter toggles fullscreen

Opt("GuiOnEventMode",1)

Global $vID, $Fullscreen

$GUI = GUICreate("Video Control", 400, 335 , -1, -1, BitOr($WS_OVERLAPPEDWINDOW,$WS_CLIPCHILDREN))
GUISetOnEvent($GUI_EVENT_CLOSE , "Event")

$Play = GUICtrlCreateButton("Play", 5, 305, 40, 25)
GUICtrlSetOnEvent(-1 , "Event")
GuiCtrlSetState(-1, $GUI_DISABLE)

$Stop = GUICtrlCreateButton("Stop", 50, 305, 40, 25)
GUICtrlSetOnEvent(-1 , "Event")
GuiCtrlSetState(-1, $GUI_DISABLE)

$Open = GUICtrlCreateButton("Load", 95, 305, 40, 25)
GUICtrlSetOnEvent(-1 , "Event")

GuiSetState(@SW_SHOW, $GUI)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            _SoundClose($vID)
            Exit            
        Case $Play
            If _SoundStatus($vID) = "playing" Then 
                _SoundPause($vID)
               GUICtrlSetData($Play, 'Play')
            ElseIf _SoundStatus($vID) = "paused" Then 
                _SoundResume($vID)
                GUICtrlSetData($Play, 'Pause')
            ElseIf _SoundStatus($vID) = "stopped" Then 
                _VidPlay($vID, 0)
                GUICtrlSetData($Play, 'Pause')
            EndIf
        Case $Stop
            If _SoundStatus($vID) = "playing" Then
                _SoundStop($vID)
                GUICtrlSetData($Play, 'Play')
            EndIf
        Case $Open
            $file = FileOpenDialog("OPEN","","Video (*.avi;*.mpg)")
            If @error <> 1 Then
                If _SoundStatus($vID) <> "" Then 
                    _SoundClose($vID)
                    GUICtrlSetData($Play, 'Play')
                EndIf   
                $vID = _VidOpen($file, "", $GUI, 0, 0, 400, 300)
                If $vID <> "" Then
                    _VidPlay($vID, 0)
                    GUICtrlSetData($Play, 'Pause')
                    GuiCtrlSetState($Play, $GUI_ENABLE)
                    GuiCtrlSetState($Stop, $GUI_ENABLE)
                EndIf   
            EndIf
    EndSwitch       
EndFunc 

Func FullScreen()
    If $Fullscreen = 0 Then
        _VidPlay($vid, 1)
        $Fullscreen = 1
    ElseIf $Fullscreen = 1 Then
        _VidPlay($vid, 0)
        $Fullscreen = 0
    EndIf
EndFunc

;===============================================================================
;
; Function Name:   _VidOpen($vFile, $vAlias, $guID, $vX1, $vY1, $vX2, $vY2)
; Description::    Opens a Video file as a control in a gui for use with other _Vid/_Sound functions
; Parameter(s):    $vFile - The full path to video file (spaces in path/file name is fine) 
;                  $vAlias - a name such as sound1 (must contain no spaces), use "" and it is randomly generated
;                  $guID - The GUI handle that the video control will be displayed in
;                  $vX1 - Left position in the GUI (set as 0 for left edge of GUI)
;                  $vY1 - Top position in the GUI (set as 0 for Top edge of GUI, flush to Title bar if one exists)
;                  $vX2 - Width of the video 
;                  $vY2 - Height of the video
; Requirement(s):  AutoIt 3.2 ++
; Return Value(s): string(the alias video id for use in other _Vid/_Sound functions) - Success 
;                  0 - Failure
;                  @extended <> 0 - open failed 
;                  @error = 2 - File doesn't exist
;                  @error = 3 - alias contains whitespace
;                  @error = 4 - GUI handle is not valid
;                  @error = 5 - Failed to render video to GUI
;                  @error = 6 - Failed to place video at the deignated location in GUI
; Author(s):       smashly (modified from RazorM sound udf for video open)
; 
;
;===============================================================================
;
Func _VidOpen($vFile, $vAlias, $guID, $vX1, $vY1, $vX2, $vY2)
    ;Declare variables
    Local $vID, $iCurrentPos, $gId, $vRet, $vWin, $vLoc
    ;check for file
    If Not FileExists($vFile) Then Return SetError(2, 0, 0)
    ;search for whitespace by character
    For $iCurrentPos = 1 To StringLen($vAlias)
        If StringIsSpace(StringMid($vAlias, $iCurrentPos, 1)) Then Return SetError(3, 0, 0)
    Next
    ;create random alias if one is not supplied
    If $vAlias = "" Then
        $vID = RandomStr(10)
    Else
        $vID = $vAlias
    EndIf
    ;check and translate the GUI handle into a ASCII numeric equivalent
    If StringLeft($guID, 2) = '0x' And StringIsXDigit(StringTrimLeft($guID, 2)) = 1 Then
        $gId = Dec(StringTrimLeft($guID,2))
    Else
        Return SetError(4, 0, 0)
    EndIf   
    ;open video file in the GUI at desired location and size 
    $vRet = mciSendString("open " & FileGetShortName($vFile) & " alias " & $vID)
    $vWin = mciSendString("window " & $vID & " handle " & $gId)
    If $vWin <> 0 Then 
        mciSendString("close " & $vID)
        Return SetError(5, 0, 0)
    EndIf   
    $vLoc = mciSendString("put " & $vID & " destination at " & $vX1 & " " & $vY1 & " " & $vX2 & " " & $vY2)
    If $vLoc <> 0 Then 
        mciSendString("close " & $vID)
        Return SetError(6, 0, 0)
    EndIf   
    Return SetError(0, $vRet, $vID)
EndFunc   ;==>_VidOpen

;===============================================================================
;
; Function Name:   _VidPlay($vID, $fScreen)
; Description::    Plays a Video from the current position (beginning is the default)
; Parameter(s):    $vID - Video ID returned by _VidOpen
;                  $fScreen [Optional] - If set to 1 the will be played in FullScreen (no Gui or Controls displayed)
;                                      - If set to 0 the video will play in the GUI as specified in _VidOpen
;                                      - If omitted then 0 will be used (play in the GUI as specified in _VidOpen)
; Requirement(s):  AutoIt 3.2 ++
; Return Value(s): 1 - Success, 0 - Failure
;                  @error = 1 - play failed
; Author(s):       smashly (modified from RazorM sound udf for video play)
;
;===============================================================================
;
Func _VidPlay($vID, $fScreen = 0)
    ;Declare variables
    Local $vRet
    ;if sound has finished, seek to start
    If _SoundPos($vID, 2) = _SoundLength($vID, 2) Then mciSendString("seek " & $vID & " to start")
    If $fScreen = 1 Then
        $vRet = mciSendString("play " & $vID & " fullscreen")
    Else
        $vRet = mciSendString("play " & $vID)
    EndIf
    ;return
    If $vRet = 0 Then
        Return 1
    Else
        Return SetError(1, 0, 0)
    EndIf
EndFunc   ;==>_VidPlay

Passei a noite procurando UDF's para gerenciar o video e o que eu mais gostei foi esse aqui. Ele é bem completo e explicativo no código. Só não achei onde fechar, mas se eu executar outro video, imagem ou audio, o video que está aberto fecha sozinho. Gostei muito desse aqui. Bem completa mesmo. Eu precisaria colocar o video no frame 1, mas não consegui. Sabe alguma UDF melhor?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

Global $width = 800
Global $height = 450
Global $IEControl; = null;
Global $MyGUI = GUICreate("WMPlayer Control", $width,$height,(@DesktopWidth-$width)/2,(@DesktopHeight-$height)/2, $WS_OVERLAPPEDWINDOW)

Global $oIE = _GUICtrl_CreateWMPlayer("about:blank", 0, 0, $width, $height)
GUISetState (@SW_SHOW, $MyGUI)
GUIRegisterMsg($WM_SIZE, "WM_SIZE")

Global $playerOBJ = _IEGetObjById($oIE, "objWMPlayer")
if NOT IsObj($playerOBJ) Then
    MsgBox(0, "Error", "WMP failed to be created.");
    Exit;
EndIf
$FileOpen = "C:\SCRIPTS AUTOIT\FONT END WARLOCK\_GUIResourcePic.mp4";
;$FileOpen = FileOpenDialog("Open Videos", @UserProfileDir, "Movies (*.3gp;*.mp4;*.avi;*.wmv;*.flv)")
If Not @error Then
    _wmpvalue($playerOBJ, "nocontrols")
    _wmploadmedia($playerOBJ,$FileOpen)
    $mediaName = _wmpvalue($playerOBJ, "getname");
    WinSetTitle($MyGUI, "", "Playing video: " & $mediaName)
Else
    Exit;
EndIf

While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit;
    EndSwitch
WEnd

Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam, $ilParam
    Local $xClient, $yClient
    $xClient = BitAND($ilParam, 0x0000FFFF)
    $yClient = BitShift($ilParam, 16)
    GUICtrlSetPos($IEControl, 0, 0, $xClient, $yClient)
    if NOT @error Then
        if IsObj($playerOBJ) Then $playerOBJ.width = $xClient;
        if IsObj($playerOBJ) Then $playerOBJ.height = $yClient;
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

;===============================================
;===============================================
;===============================================

#cs
_wmploadmedia( $object, $URL )
$object:    Object returned from the $playerOBJ = _IEGetObjById($oIE, "objWMPlayer")
$URL:       Path or URL of the media
Return: None
#ce
Func _wmploadmedia( $object, $URL)
    $object.URL = $URL
    While Not $object.controls.isAvailable("play")
        Sleep(1)
    WEnd
    $object.controls.play()
EndFunc


; Function: _GUICtrl_CreateWMPlayer
; Purpose: Embed Windows Media Player and play one file or one playlist only.
; Notes: PARAM NAME="url" is ReadOnly
; Authors: squirrely1
; borderless IE embed example: GaryFrost
; Kudos - Kare Johansson, CFire
; References:
; http://msdn2.microsoft.com/en-us/library/ms930698.aspx
; http://www.w3schools.com/media/media_playerref.asp
; clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6 - wmplayer latest installed version
; clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95 - wmp 6.4
;===============================================
Func _GUICtrl_CreateWMPlayer($movieURL, $playerLeft, $playerTop, $playerWidth, $playerHeight, _
    $insetBorders = 0, $fullscreenMode = False, $showControls = True, $enableContextMenu = True, _
    $LoopMode = false, $playCount = 1, $playVolume = 100, $playBalance = 0, $enableFullScreenControls = True)

    If $fullscreenMode Then
        $fullscreenMode = "true"
    Else
        $fullscreenMode = "false"
    EndIf
    If $showControls Then
        $showControls = "true"
    Else
        $showControls = "false"
    EndIf
    If $enableContextMenu Then
        $enableContextMenu = "true"
    Else
        $enableContextMenu = "false"
    EndIf
    If $LoopMode Then
        $playCount = 999
    EndIf
    If $enableFullScreenControls Then
        $enableFullScreenControls = "true"
    Else
        $enableFullScreenControls = "false"
    EndIf

    Local $myIE_Obj = _IECreateEmbedded ()
    $IEControl = GUICtrlCreateObj($myIE_Obj, $playerLeft, $playerTop, $playerWidth, $playerHeight)
    _IENavigate($myIE_Obj, "about:blank")
    Local $htmlWMP
    $htmlWMP = '' _
                & @CR & '<body style="margin:0;padding:0" >' _
                & @CR & '<OBJECT' _
                & @CR & 'ID="objWMPlayer"' _
                & @CR & 'STYLE="margin:0;padding:0"' _
                & @CR & 'HSPACE="0"' _
                & @CR & 'VSPACE="0"' _
                & @CR & 'BORDER="0"' _
                & @CR & 'WIDTH="' & $playerWidth & '"' _
                & @CR & 'HEIGHT="' & $playerHeight & '"' _
                & @CR & 'CLASSID="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6"' _
                & @CR & 'STANDBY="Loading Windows Media Player components..."' _
                & @CR & 'TYPE="application/x-ms-wmp">' _
                & @CR & '<PARAM NAME="allowHideControls" VALUE="true">' _
                & @CR & '<PARAM NAME="autoStart" VALUE="false">' _
                & @CR & '<PARAM NAME="audioStream" VALUE="false">' _
                & @CR & '<PARAM NAME="autoSize" VALUE="false">' _
                & @CR & '<PARAM NAME="balance" VALUE="' & $playBalance & '"><!-- -100 to 100 -->' _
                & @CR & '<!-- <PARAM NAME="bufferingTime" VALUE="5"><!-- seconds -->' _
                & @CR & '<PARAM NAME="clickToPlay" VALUE="false"><!-- has no effect -->' _
                & @CR & '<PARAM NAME="currentPosition" VALUE="0"><!-- start position within video, in seconds -->' _
                & @CR & '<PARAM NAME="enableContextMenu" VALUE="' & $enableContextMenu & '">' _
                & @CR & '<PARAM NAME="enableFullScreenControls" VALUE="' & $enableFullScreenControls & '">' _
                & @CR & '<PARAM NAME="enabled" VALUE="true"><!-- whether controls are enabled -->' _
                & @CR & '<PARAM NAME="fullScreen" VALUE="' & $fullscreenMode & '">' _
                & @CR & '<PARAM NAME="mute" VALUE="false">' _
                & @CR & '<PARAM NAME="playCount" VALUE="' & $playCount & '">' _
                & @CR & '<!-- <PARAM NAME="previewMode" VALUE="true"> -->' _
                & @CR & '<PARAM NAME="rate" VALUE="1"><!-- play speed of -.5 to 2 increments of .1 -->' _
                & @CR & '<PARAM NAME="sendPlayStateChangeEvents" VALUE="false">' _
                & @CR & '<PARAM NAME="showCaptioning" VALUE="false">' _
                & @CR & '<PARAM NAME="showControls" VALUE="' & $showControls & '">' _
                & @CR & '<PARAM NAME="showGotoBar" VALUE="false">' _
                & @CR & '<PARAM NAME="showPositionControls" VALUE="true"><!-- uiMode must = "full" -->' _
                & @CR & '<PARAM NAME="showStatusBar" VALUE="false"><!-- has no effect -->' _
                & @CR & '<PARAM NAME="showDisplay" VALUE="true"><!-- has no effect - reportedly shows filename -->' _
                & @CR & '<PARAM NAME="stretchToFit" VALUE="true">' _
                & @CR & '<PARAM NAME="uiMode" VALUE="full"><!-- invisible, none, mini, full -->' _
                & @CR & '<!-- <PARAM NAME="videoBorderWidth" VALUE="0"> -->' _
                & @CR & '<PARAM NAME="volume" VALUE="' & $playVolume & '"><!-- volume percent setting of wmplayer.exe -->' _
                & @CR & '<PARAM NAME="windowlessVideo" VALUE="false"><!-- must be the default (false) for function to work in wmp 9.0, otherwise might renders video directly in the client area -->' _
                & @CR & '</OBJECT>' _
                & @CR & '</body>'
    _IEDocWriteHTML ($myIE_Obj, $htmlWMP)
    _IEAction ($myIE_Obj, "refresh")
    $myIE_Obj.document.body.scroll = "no"
    $myIE_Obj.document.body.style.border = $insetBorders
    Return $myIE_Obj
EndFunc ;==>_GUICtrl_CreateWMPlayer

Func _wmpvalue( $object, $setting, $para=1 )
    Switch $setting
        Case "play"
            If $object.controls.isAvailable("play") Then $object.controls.play()
        case "stop"
            If $object.controls.isAvailable("stop") Then $object.controls.stop()
        case "pause"
            If $object.controls.isAvailable("pause") Then $object.controls.pause()
        case "invisible"
            $object.uiMode = "invisible"
        case "controls"
            $object.uiMode = "full"
        case "nocontrols"
            $object.uiMode = "none"
        case "fullscreen"
            $object.fullscreen = "True"
        Case "step"
            If $object.controls.isAvailable("step") Then $object.controls.step($para)
        Case "fastForward"
            If $object.controls.isAvailable("fastForward") Then $object.controls.fastForward()
        Case "fastReverse"
            If $object.controls.isAvailable("fastReverse") Then $object.controls.fastReverse()
        Case "volume"
            $object.settings.volume = $para
        Case "rate"
            $object.settings.rate = $para
        Case "playcount"
            $object.settings.playCount = $para
        Case "setposition"
            $object.controls.currentPosition = $para
        Case "getposition"
            Return $object.controls.currentPosition
        Case "getpositionstring"
            Return $object.controls.currentPositionString
        Case "getduration"
            Return $object.currentMedia.duration
        Case "getname"
            Return $object.currentMedia.name
    EndSwitch
EndFunc
Edited by Pedro Pinheiro

Share this post


Link to post
Share on other sites

 

@Belini Eu vi um post seu em um forum gringo que você recomenda essa UDF do smashly para rodar vídeos. A do Jscript é melhor?

 

Não porque a do @jscript eu não consegui fechar o video anterior para poder rodar o pr´ximo, esta do Smashly é excelente e uso ela no meu programa de jukebox pois roda tudo só que no jukebox abre um video e depois abre outro depois de ums 3 minutos já no frontend abre um seguido do outro e é aí que bug de piscar fica bem nítido, se não fosse isto a do smashly seria perfeita prá usar no frontend também, vou testar esta que vc falou que funcionou e vou postar um exemplo desta do smashly prá vc também!

Share this post


Link to post
Share on other sites

Não porque a do @jscript eu não consegui fechar o video anterior para poder rodar o pr´ximo, esta do Smashly é excelente e uso ela no meu programa de jukebox pois roda tudo só que no jukebox abre um video e depois abre outro depois de ums 3 minutos já no frontend abre um seguido do outro e é aí que bug de piscar fica bem nítido, se não fosse isto a do smashly seria perfeita prá usar no frontend também, vou testar esta que vc falou que funcionou e vou postar um exemplo desta do smashly prá vc também!

 

O bug de piscar me pegou. Estou usando esse ultimo que mandei e quando eu executo um novo video, ele da uma piscada com background branco, ficaria perfeito se o background do video ficasse preto.

 

 

EDIT:

Você já tentou pegar um parametro de uma udf e colocar na outra? A dll usada é a mesma e o parâmetro também.

Edited by Pedro Pinheiro

Share this post


Link to post
Share on other sites

Você já tentou pegar um parametro de uma udf e colocar na outra? A dll usada é a mesma e o parâmetro também.

Não testei mas acho pouco provável de funcionar, a única que não piscou até agora foi a do @jscript que usa o media player imbutido mas com ela não consigo fechar o video antes de executar outro!

Share this post


Link to post
Share on other sites

@pedro pinheiro fui ver esta que vc indicou e ví que era uma que já testei mas não serviu porque abre os controles do media player antes de executar o video, no segundo código está faltando 2 funções, coloquei elas e funcionou depois vou testar prá ver se não dá bug:

 

FUNCÕES QUE FALTARAM:

; #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

; #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); procurar na pasta system32
        If Not @error Then Return $iRet[2]
EndFunc   ;==>_mciSendString
Edited by Belini

Share this post


Link to post
Share on other sites

@Belini a UDF gringa que o Pedro postou tem muitos recursos dentro da função _wmpvalue() no Switch cases, e aceita vários formatos.

 

Achei parecida com a do Jscript, o link do mega com a UDF + Exemplo não está funcionando, por acaso é o mesmo que o Alexandre postou nos Vídeo dele?

Share this post


Link to post
Share on other sites

@Belini a UDF gringa que o Pedro postou tem muitos recursos dentro da função _wmpvalue() no Switch cases, e aceita vários formatos.

 

Só que aparece os controles do media player antes de tocar o video, quanto a ao link não sei te dizer!

@Pedro pinheiro editei meu post anterior e coloquei nele as funções que falatram prá rodar o segundo código que vc postou!

 

EDITADO: Consegui colocar o segundo código prá rodar .mp4 também mas acho que vai dá na mesma da que o smashly fex pois as funções são muito parecidas e as que faltaram eu tirei foi de la´!


    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <Sound.au3>

    HotKeySet('!{ENTER}', 'FullScreen') ; Alt + Enter toggles fullscreen

    Opt("GuiOnEventMode",1)

    Global $vID, $Fullscreen

    $GUI = GUICreate("Video Control", 400, 335 , -1, -1, BitOr($WS_OVERLAPPEDWINDOW,$WS_CLIPCHILDREN))
    GUISetOnEvent($GUI_EVENT_CLOSE , "Event")

    $Play = GUICtrlCreateButton("Play", 5, 305, 40, 25)
    GUICtrlSetOnEvent(-1 , "Event")
    GuiCtrlSetState(-1, $GUI_DISABLE)

    $Stop = GUICtrlCreateButton("Stop", 50, 305, 40, 25)
    GUICtrlSetOnEvent(-1 , "Event")
    GuiCtrlSetState(-1, $GUI_DISABLE)

    $Open = GUICtrlCreateButton("Load", 95, 305, 40, 25)
    GUICtrlSetOnEvent(-1 , "Event")

    GuiSetState(@SW_SHOW, $GUI)

    While 1
        Sleep(100)
    WEnd

    Func Event()
        Switch @GUI_CtrlId
            Case $GUI_EVENT_CLOSE
                _SoundClose($vID)
                Exit
            Case $Play
                If _SoundStatus($vID) = "playing" Then
                    _SoundPause($vID)
                   GUICtrlSetData($Play, 'Play')
                ElseIf _SoundStatus($vID) = "paused" Then
                    _SoundResume($vID)
                    GUICtrlSetData($Play, 'Pause')
                ElseIf _SoundStatus($vID) = "stopped" Then
                    _VidPlay($vID, 0)
                    GUICtrlSetData($Play, 'Pause')
                EndIf
            Case $Stop
                If _SoundStatus($vID) = "playing" Then
                    _SoundStop($vID)
                    GUICtrlSetData($Play, 'Play')
                EndIf
            Case $Open
                $file = FileOpenDialog("OPEN",@ScriptDir,"Video (*.avi;*.mpg;*.mp4)")
                If @error <> 1 Then
                    If _SoundStatus($vID) <> "" Then
                        _SoundClose($vID)
                        GUICtrlSetData($Play, 'Play')
                    EndIf
                    $vID = _VidOpen($file, $GUI, 0, 0, 400, 300, "MPEGVideo")
                    If $vID <> "" Then
                        _VidPlay($vID, 0)
                        GUICtrlSetData($Play, 'Pause')
                        GuiCtrlSetState($Play, $GUI_ENABLE)
                        GuiCtrlSetState($Stop, $GUI_ENABLE)
                    EndIf
                EndIf
        EndSwitch
    EndFunc

    Func FullScreen()
        If $Fullscreen = 0 Then
            _VidPlay($vid, 1)
            $Fullscreen = 1
        ElseIf $Fullscreen = 1 Then
            _VidPlay($vid, 0)
            $Fullscreen = 0
        EndIf
    EndFunc

    ;===============================================================================
    ;
    ; Function Name:   _VidOpen($vFile, $vAlias, $guID, $vX1, $vY1, $vX2, $vY2)
    ; Description::    Opens a Video file as a control in a gui for use with other _Vid/_Sound functions
    ; Parameter(s):    $vFile - The full path to video file (spaces in path/file name is fine)
    ;                  $vAlias - a name such as sound1 (must contain no spaces), use "" and it is randomly generated
    ;                  $guID - The GUI handle that the video control will be displayed in
    ;                  $vX1 - Left position in the GUI (set as 0 for left edge of GUI)
    ;                  $vY1 - Top position in the GUI (set as 0 for Top edge of GUI, flush to Title bar if one exists)
    ;                  $vX2 - Width of the video
    ;                  $vY2 - Height of the video
    ; Requirement(s):  AutoIt 3.2 ++
    ; Return Value(s): string(the alias video id for use in other _Vid/_Sound functions) - Success
    ;                  0 - Failure
    ;                  @extended <> 0 - open failed
    ;                  @error = 2 - File doesn't exist
    ;                  @error = 3 - alias contains whitespace
    ;                  @error = 4 - GUI handle is not valid
    ;                  @error = 5 - Failed to render video to GUI
    ;                  @error = 6 - Failed to place video at the deignated location in GUI
    ; Author(s):       smashly (modified from RazorM sound udf for video open)
    ;
    ;
    ;===============================================================================
    ;
Func _VidOpen($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

    ;===============================================================================
    ;
    ; Function Name:   _VidPlay($vID, $fScreen)
    ; Description::    Plays a Video from the current position (beginning is the default)
    ; Parameter(s):    $vID - Video ID returned by _VidOpen
    ;                  $fScreen [Optional] - If set to 1 the will be played in FullScreen (no Gui or Controls displayed)
    ;                                      - If set to 0 the video will play in the GUI as specified in _VidOpen
    ;                                      - If omitted then 0 will be used (play in the GUI as specified in _VidOpen)
    ; Requirement(s):  AutoIt 3.2 ++
    ; Return Value(s): 1 - Success, 0 - Failure
    ;                  @error = 1 - play failed
    ; Author(s):       smashly (modified from RazorM sound udf for video play)
    ;
    ;===============================================================================
    ;
    Func _VidPlay($vID, $fScreen = 0)
        ;Declare variables
        Local $vRet
        ;if sound has finished, seek to start
        If _SoundPos($vID, 2) = _SoundLength($vID, 2) Then mciSendString("seek " & $vID & " to start")
        If $fScreen = 1 Then
            $vRet = mciSendString("play " & $vID & " fullscreen")
        Else
            $vRet = mciSendString("play " & $vID)
        EndIf
        ;return
        If $vRet = 0 Then
            Return 1
        Else
            Return SetError(1, 0, 0)
        EndIf
    EndFunc   ;==>_VidPlay

; #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

; #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); procurar na pasta system32
        If Not @error Then Return $iRet[2]
	EndFunc   ;==>_mciSendString

; #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

; #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


Edited by Belini

Share this post


Link to post
Share on other sites

Será que essa piscada tem haver com a pagina da web "about:blank" que abre sempre? Não funcionou o exemplo que você postou, estou usando windows 10, talvez tenha algo haver com o sistema. Usar pagina da web para criar um player fica estranho, o modo mais rápido e pratico seria usar o sistema da dll direto, mas aqui no meu pc não rodou mesmo.

Edited by Pedro Pinheiro

Share this post


Link to post
Share on other sites

Será que essa piscada tem haver com a pagina da web "about:blank" que abre sempre? Não funcionou o exemplo que você postou, estou usando windows 10, talvez tenha algo haver com o sistema. Usar pagina da web para criar um player fica estranho

que página da web? Estou abrindo o video direto do hd!

Share this post


Link to post
Share on other sites

que página da web? Estou abrindo o video direto do hd!

 

É que se eu não me engano no UDF do Jscript é aberto em uma pagina da web, ele cria uma pagina "about:blank"..pagina vazia e depois coloca o player lá e executa o vídeo (Talvez se você criar uma pagina .html com background preto e trocar o valor "about:blank" pela pagina que vc criou a piscada some, mas isso vira uma gambiarra louca. Não olhei o UDF completamente, então não posso dar certezas. Consegui fazer essa outra que você mandou funcionar só agora, tive que instalar codec's no meu pc, achei que fosse algo do windows 10.

Edited by Pedro Pinheiro

Share this post


Link to post
Share on other sites

 

É que se eu não me engano no UDF do Jscript é aberto em uma pagina da web, ele cria uma pagina "about:blank"..pagina vazia e depois coloca o player lá e executa o vídeo.

Não cheguei a ver como o código funciona pois estava testando mais coisas e sem tempo prá olhar isto, depois vou ver!

Share this post


Link to post
Share on other sites

 

Só que aparece os controles do media player antes de tocar o video, quanto a ao link não sei te dizer!

 

Abrindo o video direto não aparece do jeito que o pedro testou.

 

;~ $FileOpen = "C:\SCRIPTS AUTOIT\FONT END WARLOCK\_GUIResourcePic.mp4";

Share this post


Link to post
Share on other sites

Não cheguei a ver como o código funciona pois estava testando mais coisas e sem tempo prá olhar isto, depois vou ver!

 

É. Vou ficar com a primeira opção mesmo. Ficou perfeito, o único problema é a dependência de codec's no sistema operacional, vou procurar uma solução para isso. Acho que se eu pegar a dll especifica de mp4 e manter na pasta do programa...Vou testar isso depois.

 

 

 

Abrindo o video direto não aparece do jeito que o pedro testou.

 

;~ $FileOpen = "C:\SCRIPTS AUTOIT\FONT END WARLOCK\_GUIResourcePic.mp4";

 

Tive que instalar codec's no sistema para funcionar de boa. Isso na UDF que executa pela dll (1ª opção que mandei). Nas outras udf's não precisou. A 3ª UDF que mandei é uma versão quase idêntica ao do Jscript, só que tem muito mais funções.

 

http://www.baixaki.com.br/download/k-lite-mega-codec-pack.htm

Edited by Pedro Pinheiro

Share this post


Link to post
Share on other sites

Mas está aí é a que eu uso e que pisca, vc conseguiu fazer parar de piscar? A terceira que vc postou aparece a janela com os controles do média player, conseguiu resolver istor

Edited by Belini

Share this post


Link to post
Share on other sites

Mas está aí é a que eu uso e que pisca, vc conseguiu fazer parar de piscar? A terceira que vc postou aparece a janela com os controles do média player, conseguiu resolver istor

 

Estou usando e não está piscando, então devo culpar o Windows 10 de novo.

Share this post


Link to post
Share on other sites

deve ser isto então pois uso no xp!

 

Não sei se estou certo, mas acho que a udf do Jscript da uma manipulada na pagina da web antes de colocar o video. Ai ele joga um background preto e fica de boa.

 

.document.body.bgcolor = 0x000000

 

Eu meio que buguei aq fazendo umas 5 coisas ao mesmo tempo, daqui a pouco eu mexo nas UDF's.

Edited by Pedro Pinheiro

Share this post


Link to post
Share on other sites

Mas está aí é a que eu uso e que pisca, vc conseguiu fazer parar de piscar? A terceira que vc postou aparece a janela com os controles do média player, conseguiu resolver isto?

 

@Belini é só colocar essa linha..

 

_wmpvalue($playerOBJ, "nocontrols") ; Retira os controles .

 

Repare que já tem ela ai, estou fazendo testes agora com a 3ª UDF, tô gostando dela, tirei o dia de folga hoje pra Programar :600866:.

Por enquanto vou ficar com a 3º mesmo , :ILA2: ela é sensacional.

Edited by Fábio iGames

Share this post


Link to post
Share on other sites

@Fabio iGames nem tinha me tocado que quando caregava o video era esta linha que removia os controles, alterei prá não mostrar a borda também e agora ficou assim:

Global $MyGUI = GUICreate("WMPlayer Control", $width,$height,(@DesktopWidth-$width)/2,(@DesktopHeight-$height)/2, $WS_POPUP)

Global $oIE = _GUICtrl_CreateWMPlayer("about:blank", 0, 0, $width, $height)
GUISetState (@SW_SHOW, $MyGUI)
GUIRegisterMsg($WM_SIZE, "WM_SIZE")

Global $playerOBJ = _IEGetObjById($oIE, "objWMPlayer")
if NOT IsObj($playerOBJ) Then
MsgBox(0, "Error", "WMP failed to be created.");
Exit;
    else
    _wmpvalue($playerOBJ, "nocontrols")
EndIf

EDITADO: O problema dos controles aparecerem foi resolvido mas preciso mostrar imagens no mesmo lugar que o vídeo aparece e não consegui ocultar o campo do vídeo para mostrar a imagem quando eu quero!

Edited by Belini

Share this post


Link to post
Share on other sites

Voltei. ée depois de 2 dias sem dormir kkkk...Alterei a UDF e removi o background branco. Aqui no windows 10 não deu bug aparentemente. Testa ai no XP.

 

http://imgur.com/VQGUYk4

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

Global $width = 800
Global $height = 450
Global $IEControl; = null;
;Global $MyGUI = GUICreate("WMPlayer Control", $width,$height,(@DesktopWidth-$width)/2,(@DesktopHeight-$height)/2, $WS_OVERLAPPEDWINDOW)

;Global $oIE = _GUICtrl_CreateWMPlayer("about:blank", 0, 0, $width, $height)

;GUISetState (@SW_SHOW, $MyGUI)
;GUIRegisterMsg($WM_SIZE, "WM_SIZE")

;Global $playerOBJ = _IEGetObjById($oIE, "objWMPlayer")
;if NOT IsObj($playerOBJ) Then
 ;   MsgBox(0, "Error", "WMP failed to be created.");
  ;  Exit;
;EndIf


;$FileOpen = FileOpenDialog("Open Videos", @UserProfileDir, "Movies (*.3gp;*.mp4;*.avi;*.wmv;*.flv)")
;$FileOpen = "C:\SCRIPTS AUTOIT\FONT END WARLOCK\snap\Metal slug 3.mp4";
;If Not @error Then
 ;   _wmpvalue($playerOBJ, "nocontrols")
  ;  _wmploadmedia($playerOBJ,$FileOpen)
  ;  $mediaName = _wmpvalue($playerOBJ, "getname");
  ;  WinSetTitle($MyGUI, "", "Playing video: " & $mediaName)
;Else
 ;   Exit;
;EndIf

;While 1
 ;   $iMsg = GUIGetMsg()
  ;  Switch $iMsg
   ;     Case $GUI_EVENT_CLOSE
    ;        Exit;
    ;EndSwitch
;WEnd
#cs

Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam, $ilParam
    Local $xClient, $yClient
    $xClient = BitAND($ilParam, 0x0000FFFF)
    $yClient = BitShift($ilParam, 16)
    GUICtrlSetPos($IEControl, 0, 0, $xClient, $yClient)
    if NOT @error Then
        if IsObj($playerOBJ) Then $playerOBJ.width = $xClient;
        if IsObj($playerOBJ) Then $playerOBJ.height = $yClient;
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc

;===============================================
;===============================================
;===============================================


_wmploadmedia( $object, $URL )
$object:    Object returned from the $playerOBJ = _IEGetObjById($oIE, "objWMPlayer")
$URL:       Path or URL of the media
Return: None
#ce
Func _wmploadmedia( $object, $URL)
    $object.URL = $URL
    While Not $object.controls.isAvailable("play")
        Sleep(1)
    WEnd
    $object.controls.play()
EndFunc


; Function: _GUICtrl_CreateWMPlayer
; Purpose: Embed Windows Media Player and play one file or one playlist only.
; Notes: PARAM NAME="url" is ReadOnly
; Authors: squirrely1
; borderless IE embed example: GaryFrost
; Kudos - Kare Johansson, CFire
; References:
; http://msdn2.microsoft.com/en-us/library/ms930698.aspx
; http://www.w3schools.com/media/media_playerref.asp
; clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6 - wmplayer latest installed version
; clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95 - wmp 6.4
;===============================================
Func _GUICtrl_CreateWMPlayer($movieURL, $playerLeft, $playerTop, $playerWidth, $playerHeight, _
    $insetBorders = 0, $fullscreenMode = False, $showControls = False, $enableContextMenu = False, _
    $LoopMode = false, $playCount = 1, $playVolume = 100, $playBalance = 0, $enableFullScreenControls = True)

    If $fullscreenMode Then
        $fullscreenMode = "true"
    Else
        $fullscreenMode = "false"
    EndIf
    If $showControls Then
        $showControls = "true"
    Else
        $showControls = "false"
    EndIf
    If $enableContextMenu Then
        $enableContextMenu = "true"
    Else
        $enableContextMenu = "false"
    EndIf
    If $LoopMode Then
        $playCount = 999
    EndIf
    If $enableFullScreenControls Then
        $enableFullScreenControls = "true"
    Else
        $enableFullScreenControls = "false"
    EndIf

    Local $myIE_Obj = _IECreateEmbedded ()
    $IEControl = GUICtrlCreateObj($myIE_Obj, $playerLeft, $playerTop, $playerWidth, $playerHeight)
    _IENavigate($myIE_Obj, "about:blank")
    Local $htmlWMP
    $htmlWMP = '' _
                & @CR & '<body style="margin:0;padding:0";bgcolor=#000000>' _
                & @CR & '<OBJECT' _
                & @CR & 'ID="objWMPlayer"' _
                & @CR & 'STYLE="margin:0;padding:0"' _
                & @CR & 'HSPACE="0"' _
                & @CR & 'VSPACE="0"' _
                & @CR & 'BORDER="0"' _
                & @CR & 'WIDTH="' & $playerWidth & '"' _
                & @CR & 'HEIGHT="' & $playerHeight & '"' _
                & @CR & 'CLASSID="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6"' _
                & @CR & 'STANDBY="Loading Windows Media Player components..."' _
                & @CR & 'TYPE="application/x-ms-wmp">' _
                & @CR & '<PARAM NAME="allowHideControls" VALUE="true">' _
                & @CR & '<PARAM NAME="autoStart" VALUE="false">' _
                & @CR & '<PARAM NAME="audioStream" VALUE="false">' _
                & @CR & '<PARAM NAME="autoSize" VALUE="false">' _
                & @CR & '<PARAM NAME="balance" VALUE="' & $playBalance & '"><!-- -100 to 100 -->' _
                & @CR & '<!-- <PARAM NAME="bufferingTime" VALUE="5"><!-- seconds -->' _
                & @CR & '<PARAM NAME="clickToPlay" VALUE="false"><!-- has no effect -->' _
                & @CR & '<PARAM NAME="currentPosition" VALUE="0"><!-- start position within video, in seconds -->' _
                & @CR & '<PARAM NAME="enableContextMenu" VALUE="' & $enableContextMenu & '">' _
                & @CR & '<PARAM NAME="enableFullScreenControls" VALUE="' & $enableFullScreenControls & '">' _
                & @CR & '<PARAM NAME="enabled" VALUE="true"><!-- whether controls are enabled -->' _
                & @CR & '<PARAM NAME="fullScreen" VALUE="' & $fullscreenMode & '">' _
                & @CR & '<PARAM NAME="mute" VALUE="false">' _
                & @CR & '<PARAM NAME="playCount" VALUE="' & $playCount & '">' _
                & @CR & '<!-- <PARAM NAME="previewMode" VALUE="false"> -->' _
                & @CR & '<PARAM NAME="rate" VALUE="1"><!-- play speed of -.5 to 2 increments of .1 -->' _
                & @CR & '<PARAM NAME="sendPlayStateChangeEvents" VALUE="false">' _
                & @CR & '<PARAM NAME="showCaptioning" VALUE="false">' _
                & @CR & '<PARAM NAME="showControls" VALUE="' & $showControls & '">' _
                & @CR & '<PARAM NAME="showGotoBar" VALUE="false">' _
                & @CR & '<PARAM NAME="showPositionControls" VALUE="true"><!-- uiMode must = "full" -->' _
                & @CR & '<PARAM NAME="showStatusBar" VALUE="false"><!-- has no effect -->' _
                & @CR & '<PARAM NAME="showDisplay" VALUE="true"><!-- has no effect - reportedly shows filename -->' _
                & @CR & '<PARAM NAME="stretchToFit" VALUE="true">' _
                & @CR & '<PARAM NAME="uiMode" VALUE="none"><!-- invisible, none, mini, full -->' _
                & @CR & '<!-- <PARAM NAME="videoBorderWidth" VALUE="0"> -->' _
                & @CR & '<PARAM NAME="volume" VALUE="' & $playVolume & '"><!-- volume percent setting of wmplayer.exe -->' _
                & @CR & '<PARAM NAME="windowlessVideo" VALUE="false"><!-- must be the default (false) for function to work in wmp 9.0, otherwise might renders video directly in the client area -->' _
                & @CR & '</OBJECT>' _
                & @CR & '</body>'
    _IEDocWriteHTML ($myIE_Obj, $htmlWMP)
    _IEAction ($myIE_Obj, "refresh")
    $myIE_Obj.document.body.scroll = "no"
	$myIE_Obj.document.body.bgcolor = 0x000000
    $myIE_Obj.document.body.style.border = $insetBorders
    Return $myIE_Obj
EndFunc ;==>_GUICtrl_CreateWMPlayer

Func _wmpvalue( $object, $setting, $para=1 )
    Switch $setting
        Case "play"
            If $object.controls.isAvailable("play") Then $object.controls.play()
        case "stop"
            If $object.controls.isAvailable("stop") Then $object.controls.stop()
        case "pause"
            If $object.controls.isAvailable("pause") Then $object.controls.pause()
        case "invisible"
            $object.uiMode = "invisible"
        case "controls"
            $object.uiMode = "full"
        case "nocontrols"
            $object.uiMode = "none"
        case "fullscreen"
            $object.fullscreen = "True"
        Case "step"
            If $object.controls.isAvailable("step") Then $object.controls.step($para)
        Case "fastForward"
            If $object.controls.isAvailable("fastForward") Then $object.controls.fastForward()
        Case "fastReverse"
            If $object.controls.isAvailable("fastReverse") Then $object.controls.fastReverse()
        Case "volume"
            $object.settings.volume = $para
        Case "rate"
            $object.settings.rate = $para
        Case "playcount"
            $object.settings.playCount = $para
        Case "setposition"
            $object.controls.currentPosition = $para
        Case "getposition"
            Return $object.controls.currentPosition
        Case "getpositionstring"
            Return $object.controls.currentPositionString
        Case "getduration"
            Return $object.currentMedia.duration
        Case "getname"
            Return $object.currentMedia.name
    EndSwitch
EndFunc

Exemplo:

 

Isso abre a pagina da Web. Então você só vai usar uma vez isso. A primeira piscada é de graça.

Global $oIE = _GUICtrl_CreateWMPlayer("about:blank", 407, 118, 352, 271)
Global $playerOBJ = _IEGetObjById($oIE, "objWMPlayer")

ai quando você quiser trocar de vídeo use só o código abaixo. A pagina da web sempre ficará aberta, então não a necessidade criar outra pagina.

$FileOpen = "C:\SCRIPTS AUTOIT\FONT END WARLOCK\snap\Metal Slug 1.mp4";
_wmpvalue($playerOBJ, "nocontrols")
_wmploadmedia($playerOBJ,$FileOpen)

Edited by Pedro Pinheiro

Share this post


Link to post
Share on other sites

Voltei. ée depois de 2 dias sem dormir kkkk...Alterei a UDF e removi o background branco. Aqui no windows 10 não deu bug aparentemente. Testa ai no XP.

 

Exemplo:

 

Isso abre a pagina da Web. Então você só vai usar uma vez isso. A primeira piscada é de graça.

Global $oIE = _GUICtrl_CreateWMPlayer("about:blank", 407, 118, 352, 271)
Global $playerOBJ = _IEGetObjById($oIE, "objWMPlayer")

ai quando você quiser trocar de vídeo use só o código abaixo. A pagina da web sempre ficará aberta, então não a necessidade criar outra pagina.

$FileOpen = "C:\SCRIPTS AUTOIT\FONT END WARLOCK\snap\Metal Slug 1.mp4";
_wmpvalue($playerOBJ, "nocontrols")
_wmploadmedia($playerOBJ,$FileOpen)

 

Isso ai eu fiz igualzinho à você, essa UDF é Bem fácil de assimilar. :like_icon:

 

Fim de Semana espero postar um gif o video de como está ficando, está bem parecido com ADVMenu mesmo só que coloquei umas frescuras tipo HS.

 

Hoje não posso ficar programando :o vou trabalhar na rua e em uns equipamentos.

Edited by Fábio iGames

Share this post


Link to post
Share on other sites

Voltei. ée depois de 2 dias sem dormir kkkk...Alterei a UDF e removi o background branco. Aqui no windows 10 não deu bug aparentemente. Testa ai no XP.

 

Com a outra já não estava piscando mas o problema agora é mostrar imagens no mesmo lugar que é video aparece pois quando o vídeo não é encontrado mostra ima imagem no lugar dele!

Share this post


Link to post
Share on other sites

Com a outra já não estava piscando mas o problema agora é mostrar imagens no mesmo lugar que é video aparece pois quando o vídeo não é encontrado mostra ima imagem no lugar dele!

 

Já tentou executar a imagem com o player do video? ou usar _wmpvalue($playerOBJ, "invisible")? Ou manter o label da imagem acima de "Global $oIE = _GUICtrl_CreateWMPlayer("about:blank", 0, 0, $width, $height)"?

 

Não sei se pode funcionar, mas...O navegador abre imagem também.

_GUICtrl_CreateWMPlayer("C:\SCRIPTS AUTOIT\FRONT END WARLOCK\images\select.gif", 0, 0, $width, $height) ;Se abrir provavelmente vai dar um click de navegador.

_wmpvalue($playerOBJ, "invisible")

 

Minha dúvida é...Como fazer para o vídeo quando chegar na ultimo frame ele ficar pausado no frame 1 e ao executar um vídeo em cima do outro ele só fecha um depois de conseguir abrir o outro (esse eu acho meio impossivel de se resolver).

 

Não sei se ta certo esse script, mas fiz rapidinho.

#include <GUIConstants.au3>
#include <File.au3>
#include <GDIPlus.au3>
#include "MediaPlayer.au3"

$X=407
$Y=118
$W=352
$H=271


Global $gui=GUICreate("Test Frontend", 800, 600, -1, -1,BitOR ($WS_POPUP,$WS_BORDER),$WS_EX_COMPOSITED)
;Nas cordenadas do video
Global $pic=GUICtrlCreatePic("", $X, $Y, $W,$H)
Global $oIE = _GUICtrl_CreateWMPlayer("about:blank",$X ,$Y ,$W,$H)
Global $playerOBJ = _IEGetObjById($oIE, "objWMPlayer")

GUISetState  (@SW_SHOW, $gui)
While 1
	WEnd
Func _Mostra_video()
$FileOpenVideo = @ScriptDir & "\snap\Metal Slug 1.mp4"
$FileOpenImagem= @ScriptDir & "\snap\Metal Slug 1.jpg"
$FileOpenSemImagem="Sem_foto.jpg"

if FileExists($FileOpenVideo) then
	GUICtrlSetImage($pic, "")
    _wmpvalue($playerOBJ, "nocontrols")
    _wmploadmedia($playerOBJ,$FileOpenVideo)
elseif FileExists($FileOpenImagem) and not FileExists ($FileOpenVideo) then
	_wmpvalue($playerOBJ, "invisible")
	GUICtrlSetImage($pic, $FileOpenImagem)
else
	GUICtrlSetImage($pic, $FileOpenImagem)
EndIf
EndFunc

Edited by Pedro Pinheiro

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


×