Sign in to follow this  
Followers 0
DirtDBaK

Streaming Media Play and Video objects

5 posts in this topic

Ok theres two things i need to know:

1.How do make autoit play streaming muisc?

If i can pass a parameter that tell it the URL could a function play streaming music??

2.How do I make a video play in a Gui?

Not like an AVI control, something like a mpg video??

- Thanks so much -


[center][/center]

Share this post


Link to post
Share on other sites



Hi,

1) you can use WMMedia.au3 to play streaming music from urls..

2) have a look at sound.au3 and msdn on how to use mci send string.. can play any video in your gui.

Cheers

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Great Ill take a look into it but im not too sure how well the mcisendstring will go, i may need an example, ill give it a try though...

Thanks Sadly... this leaves me in the dark......

------------------------------------------------------------------------------------------ http://msdn2.microsoft.com/en-us/library/ms713261.aspx

Edited by DBak

[center][/center]

Share this post


Link to post
Share on other sites

I don't know if this will make it any easier for you in regaurds to the video playback..

Here's a couple of functions to play video.. to use these functions you will need to use Sound.au3 as an include in your script..

;===============================================================================
;
; 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 = Number($guID)
    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

;===============================================================================
;
; Function Name:   _VidStop($vID, $sStart)
; Description::    Stops the video
; Parameter(s):    $vID - Video alias ID returned by _VidOpen,
;                  $sStart[Optional] - 0 = Stop, 1 = Seek to start then Stop
;                  (If $sStart value is omitted then 1 will be used)
; Requirement(s):  AutoIt 3.2 ++
; Return Value(s): 1 - Success, 0 and @error = 1 - Failure,
;                  @error = 2 - invalid $sStart value
; Author(s):       smashly (modified RazorM sound udf for video stop)
;
;===============================================================================
;
Func _VidStop($vID, $sStart = 1)
    ;Declare variables
    Local $vRet, $vRet2
    ;validate $sStart
    If $sStart <> 0 And $sStart <> 1 Then Return SetError(2, 0, 0)
    If $sStart = 0 Then
        ;stop
        $vRet2 = mciSendString("stop " & $vID)
        ;return
        If $vRet2 = 0 Then Return 1
    ElseIf $sStart = 1 Then
        ;seek to start
        $vRet = mciSendString("seek " & $vID & " to start")
        ;stop
        $vRet2 = mciSendString("stop " & $vID)
        ;return
        If $vRet = 0 And $vRet2 = 0 Then Return 1
    Else
        Return SetError(1, 0, 0)
    EndIf
EndFunc   ;==>_VidStop

Cheers

Share this post


Link to post
Share on other sites

Ill try this when i get home and see how it works. Thanks!


[center][/center]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

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

Create an account

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


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0