Jump to content

My 1st Autoit Script - A Media Player


ronriel
 Share

Recommended Posts

I started making a video udf from your sound.au3 RazorM..

But it definately needs more added for it to be stand alone udf.., atm I'm using bad coding practices until I write the rest of the udf :whistle:

Here's what I started..(maybe it can help ronriel to with what he's doing) vid_ex_sound.au3

#include <Sound.au3>
;===============================================================================
;
; 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   ;==>_VidPlayoÝ÷ Ø*îuç±jjezî²)àÖ®¶­sb6æ6ÇVFRfÇC´uT6öç7FçG2æS2fwC°¢6æ6ÇVFRgV÷C·fEöW÷6÷VæBæS2gV÷C° ¤÷D¶W6WBb33²b333·´TåDU'Òb33²Âb33´gVÆÅ67&VVâb33² ¤÷BgV÷C´wVöäWfVçDÖöFRgV÷C²Ã ¤vÆö&Âb33c·dBÂb33cµ7FFP ¢b33c´uTÒuT7&VFRgV÷CµfFVò6öçG&öÂgV÷C²ÂÂcÂÓÂÓÂb33cµu5ôõdU$ÄTEtäDõr²b33cµu5ô4Ä4ÄE$Tâ ¢b33cµÆÒuT7G&Ä7&VFT'WGFöâgV÷CµÆgV÷C²ÂRÂSsÂCÂ#R¤uT7G&Å6WDöäWfVçBÓÂgV÷CµfFVô6öçG&öÂgV÷C²¤wV7G&Å6WE7FFRÓÂb33c´uTôD4$ÄR ¢b33cµ7F÷ÒuT7G&Ä7&VFT'WGFöâgV÷Cµ7F÷gV÷C²ÂSÂSsÂCÂ#R¤uT7G&Å6WDöäWfVçBÓÂgV÷CµfFVô6öçG&öÂgV÷C²¤wV7G&Å6WE7FFRÓÂb33c´uTôD4$ÄR ¢b33c´÷VâÒuT7G&Ä7&VFT'WGFöâgV÷C´ÆöBgV÷C²ÂRÂSsÂCÂ#R¤uT7G&Å6WDöäWfVçBÓÂgV÷CµfFVô6öçG&öÂgV÷C² ¢b33c´Ö÷fRÒuT7G&Ä7&VFT'WGFöâgV÷C´VçFW'FâÖRb333²gV÷C²ÂCÂSsÂ#Â#R¤wV7G&Å6WE7FFRÓÂb33c´uTôD4$ÄR¤uT7G&Å6WDöäWfVçBÓÂgV÷CµfFVô6öçG&öÂgV÷C² ¤uT6WDöäWfVçBb33c´uTôUdTåEô4Äõ4RÂgV÷C´6Æ÷6RgV÷C²¤wV6WE7FFR5uõ4õrÂb33c´uT ¥vÆR 6ÆVW¥tVæ@ ¤gVæ2fFVô6öçG&ö 6VÆV7@ 66RuTô7G&ÄBÒb33cµÆ bõ6÷VæE7FGW2b33c·dBÒgV÷C·ÆærgV÷C²FVâ õ6÷VæEW6Rb33c·dB uT7G&Å6WDFFb33cµÆÂb33µÆb33² wV7G&Å6WE7FFRb33c´Ö÷fRÂb33c´uTôD4$ÄR¢VÇ6Tbõ6÷VæE7FGW2b33c·dBÒgV÷C·W6VBgV÷C²FVâ õ6÷VæE&W7VÖRb33c·dB uT7G&Å6WDFFb33cµÆÂb33µW6Rb33² wV7G&Å6WE7FFRb33c´Ö÷fRÂb33c´uTôTä$ÄR VÇ6Tbõ6÷VæE7FGW2b33c·dBÒgV÷C·7F÷VBgV÷C²FVâ õfEÆb33c·dB uT7G&Å6WDFFb33cµÆÂb33µW6Rb33² wV7G&Å6WE7FFRb33c´Ö÷fRÂb33c´uTôTä$ÄR VæD` 66RuTô7G&ÄBÒb33cµ7F÷ bõ6÷VæE7FGW2b33c·dBÒgV÷C·ÆærgV÷C²FVà õ6÷VæE7F÷b33c·dB uT7G&Å6WDFFb33cµÆÂb33µÆb33² wV7G&Å6WE7FFRb33c´Ö÷fRÂb33c´uTôD4$ÄR VæD` 66RuTô7G&ÄBÒb33c´÷Và b33c¶fÆRÒfÆT÷VäFÆörgV÷C´õTâgV÷C²ÂgV÷C²gV÷C²ÂgV÷CµfFVò¢æ×3²¢æf²¢æ×s²¢çvc²¢æ6F²¢çvÖ²¢æ×C²¢æÓ'bgV÷C²¢bW'&÷"fÇC²fwC²FVà bõ6÷VæE7FGW2b33c·dBfÇC²fwC²gV÷C²gV÷C²FVâ õ6÷VæD6Æ÷6Rb33c·dB uT7G&Å6WDFFb33cµÆÂb33µÆb33² VæD` b33c·dBÒõfD÷Vâb33c¶fÆRÂgV÷C²gV÷C²Âb33c´uTÂÂÂCÂ3 bb33c·dBfÇC²fwC²gV÷C²gV÷C²FVà õfEÆb33c·dB uT7G&Å6WDFFb33cµÆÂb33µW6Rb33² wV7G&Å6WE7FFRb33cµÆÂb33c´uTôTä$ÄR wV7G&Å6WE7FFRb33cµ7F÷Âb33c´uTôTä$ÄR wV7G&Å6WE7FFRb33c´Ö÷fRÂb33c´uTôTä$ÄR VæD` VæD` 66RuTô7G&ÄBÒb33c´Ö÷fP wV7G&Å6WE7FFRb33cµÆÂb33c´uTôD4$ÄR wV7G&Å6WE7FFRb33cµ7F÷Âb33c´uTôD4$ÄR wV7G&Å6WE7FFRb33c¶÷VâÂb33c´uTôD4$ÄR wV7G&Å6WE7FFRb33c´Ö÷fRÂb33c´uTôD4$ÄR f÷"b33c¶ÒFòC7FW  buTô7G&ÄBÒb33cµ7F÷FVâ&WGW&à 6öçG&öÄÖ÷fRb33c´uTÂgV÷C²gV÷C²Â6öçG&öÄvWDæFÆRb33c´uTÂgV÷C²gV÷C²ÂgV÷Cµ´4Ä53¥fFVõ&VæFW&W#²å5Dä4S£ÒgV÷C²Âb33c¶Âb33c¶ 6ÆVW#R bb33c¶ÒCFVâ f÷"b33c¶¢ÒFòC7FW  6öçG&öÄÖ÷fRb33c´uTÂgV÷C²gV÷C²Â6öçG&öÄvWDæFÆRb33c´uTÂgV÷C²gV÷C²ÂgV÷Cµ´4Ä53¥fFVõ&VæFW&W#²å5Dä4S£ÒgV÷C²Âb33c¶Âb33c¶Òb33c¶¢ 6ÆVW# bb33c¶¢ÒCFVà f÷"b33c¶²ÒFòC7FW  6öçG&öÄÖ÷fRb33c´uTÂgV÷C²gV÷C²Â6öçG&öÄvWDæFÆRb33c´uTÂgV÷C²gV÷C²ÂgV÷Cµ´4Ä53¥fFVõ&VæFW&W#²å5Dä4S£ÒgV÷C²Âb33c¶Òb33c¶²Âb33c¶Òb33c¶¢²b33c¶² 6ÆVW# bb33c¶²ÒCFVà¢f÷"b33c¶ÂÒFòC7FW  6öçG&öÄÖ÷fRb33c´uTÂgV÷C²gV÷C²Â6öçG&öÄvWDæFÆRb33c´uTÂgV÷C²gV÷C²ÂgV÷Cµ´4Ä53¥fFVõ&VæFW&W#²å5Dä4S£ÒgV÷C²Âb33c¶Òb33c¶²Âb33c¶Òb33c¶¢²b33c¶²Òb33c¶Â 6ÆVW# æW@ VæD` æW@ VæD` æW@  VæD` æW@ gVÆÅ67&VVâ 6ÆVW# f÷"b33c¶ÒFòC7FW@ buTô7G&ÄBÒb33cµ7F÷FVâ&WGW&à 6öçG&öÄÖ÷fRb33c´uTÂgV÷C²gV÷C²Â6öçG&öÄvWDæFÆRb33c´uTÂgV÷C²gV÷C²ÂgV÷Cµ´4Ä53¥fFVõ&VæFW&W#²å5Dä4S£ÒgV÷C²Âb33c¶Âb33c¶ 6ÆVW# bb33c¶ÒCFVâ f÷"b33c¶¢ÒFòC7FW@ 6öçG&öÄÖ÷fRb33c´uTÂgV÷C²gV÷C²Â6öçG&öÄvWDæFÆRb33c´uTÂgV÷C²gV÷C²ÂgV÷Cµ´4Ä53¥fFVõ&VæFW&W#²å5Dä4S£ÒgV÷C²Âb33c¶Âb33c¶Òb33c¶¢ 6ÆVW# bb33c¶¢ÒCFVà f÷"b33c¶²ÒFòC7FW@ 6öçG&öÄÖ÷fRb33c´uTÂgV÷C²gV÷C²Â6öçG&öÄvWDæFÆRb33c´uTÂgV÷C²gV÷C²ÂgV÷Cµ´4Ä53¥fFVõ&VæFW&W#²å5Dä4S£ÒgV÷C²Âb33c¶Òb33c¶²Âb33c¶Òb33c¶¢²b33c¶² 6ÆVW# bb33c¶²ÒCFVà¢f÷"b33c¶ÂÒFòC7FW@ 6öçG&öÄÖ÷fRb33c´uTÂgV÷C²gV÷C²Â6öçG&öÄvWDæFÆRb33c´uTÂgV÷C²gV÷C²ÂgV÷Cµ´4Ä53¥fFVõ&VæFW&W#²å5Dä4S£ÒgV÷C²Âb33c¶Òb33c¶²Âb33c¶Òb33c¶¢²b33c¶²Òb33c¶Â 6ÆVW# æW@ VæD` æW@ VæD` æW@  VæD` æW@ 6ÆVW# gVÆÅ67&VVâ b33c´Ô"Ò×6t&÷BÂb33²b33²Âb33µvW&R÷RVçFW'FæVCòb33² bb33c´Ô"ÒrFVâ6Æ÷6R wV7G&Å6WE7FFRb33cµÆÂb33c´uTôTä$ÄR wV7G&Å6WE7FFRb33cµ7F÷Âb33c´uTôTä$ÄR wV7G&Å6WE7FFRb33c¶÷VâÂb33c´uTôTä$ÄR wV7G&Å6WE7FFRb33c´Ö÷fRÂb33c´uTôTä$ÄR  VæE6VÆV7@¤VæDgVæ0 ¤gVæ2gVÆÅ67&VVâ bb33cµ7FFRÒFVà õfEÆb33c·fB b33cµ7FFRÒ VÇ6Tbb33cµ7FFRÒFVà õfEÆb33c·fB b33cµ7FFRÒ VæD`¤VæDgVæ0  ¤gVæ26Æ÷6R õ6÷VæD6Æ÷6Rb33c·dB W@¤VæDgVæ

Hopefully more to come soon...

Cheers

Edited by smashly
Link to comment
Share on other sites

  • 3 weeks later...
  • Replies 46
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

maybe it can help ronriel to with what he's doing

Thank you... Haven't noticed the post until now.

It's been long since I last visited the forum. Anyway here's an update. See my first post. :whistle:

[font="Comic Sans MS"]-ronriel[/font][topic="48542"]r4r media player[/topic][topic="80836"]OCR & Paste[/topic]

Link to comment
Share on other sites

Here it is:

#include <GUIConstants.au3>

$hVideo = GUICreate("Test Video Player :: RazerM", 340, 280)
$hPlay = GUICtrlCreateButton("Play", 10, 255, 60, 20)
$hPause = GUICtrlCreateButton("Pause", 75, 255, 60, 20)
$hLoad = GUICtrlCreateButton("Load", 140, 255, 60, 20)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            mciSendString("close Test_Video") ;free device memory
            Exit
        Case $hPlay
            mciSendString("set Test_Video time format milliseconds")
            If mciSendString("status Test_Video position") = mciSendString("status Test_Video length") Then mciSendString("seek Test_Video to 0")
            mciSendString("play Test_Video")
        Case $hPause
            mciSendString("pause Test_Video")
        Case $hLoad
            $sFile = FileOpenDialog("Open", @DesktopDir, "All Files (*.*)", 1)
            mciSendString("close Test_Video") ;free device memory
            If Not @error Then
                mciSendString("open " & FileGetShortName($sFile) & " alias Test_Video")
                mciSendString("window Test_Video handle " & Number($hVideo)) ;assign video to our GUI
                mciSendString("put Test_Video destination at 10 10 320 240") ;set top left width height
            EndIf
    EndSwitch
WEnd

Func mciSendString($string)
    Local $iRet
    $iRet = DllCall("winmm.dll", "int", "mciSendStringA", "str", $string, "str", "", "int", 65534, "hwnd", 0)
    If Not @error Then Return $iRet[2]
EndFunc   ;==>mciSendString
This gives an error: Video not available, cannot find 'vids:DVSD' decompressor.
Link to comment
Share on other sites

This gives an error: Video not available, cannot find 'vids:DVSD' decompressor.

This is a problem with you pc configuration of mci devices and or codecs not an error of the player itself..

more info from you is required to give a resolve/work around..

eg:

the file extension of the file you opened (.avi , .mp4, .mpg, .mkv... etc)?

Do you have the codec installed to play back the format you are opening?

(DVSD codec from reading tells me your playing pack a DV Camera video file format.)

Does the file play on your pc with any other video players (wmp , mpc... etc) ?

If your opening a DV file that has an .avi file extension and you have the video codec installed and it play fine in other players then you could try associating the .avi extension with the mpegvideo mci device in the windows registry.

I know it sounds odd, but when the mci device can't open the avi with the default device (avi is associated by default with AVIVideo mci device) it will use windows default codec chain.

Cheers

Edited by smashly
Link to comment
Share on other sites

Hey ronriel,

I found this when looking about for a way to make a slider look different. Thought you might be interested for the skins side of your script.

http://www.autoitscript.com/forum/index.ph...hl=slider+image

My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator

Link to comment
Share on other sites

Hey ronriel,

I found this when looking about for a way to make a slider look different. Thought you might be interested for the skins side of your script.

http://www.autoitscript.com/forum/index.ph...hl=slider+image

Like this one?

post-23516-1185453371_thumb.jpg

It's going with the next version. :)

This is how I did it. Well not exactly, but kinda like this:

#include <GuiConstants.au3>
$posL = 50
$posT = 70
$gui = GUICreate("Test",200,100)
$bar = GUICtrlCreatePic(@ScriptDir&"\bar.gif",$posL,$posT,0,0)
$ball = GUICtrlCreatePic(@ScriptDir&"\ball.gif",$posL,$posT,0,0)
GUISetState()

$oShell = ObjCreate("shell.application")
$oDir = $oShell.NameSpace (@ScriptDir)
$oFile = $oDir.Parsename ("bar.gif")
$sW = StringReplace($oDir.GetDetailsOf ($oFile, 27), " pixels", "")

Do
    $msg = GUIGetMsg()
    $CI = GUIGetCursorInfo($gui)
    If $CI[2] = 1 And $CI[4] =  $bar Then
        ToolTip(Round(($CI[0]-$posL)/$sW*100));   "bar.gif" width = 90
        GUICtrlSetPos($ball,$CI[0],$posT)
    EndIf
Until $msg = $GUI_EVENT_CLOSE

ball:

post-23516-1185454420_thumb.gif

bar:

Edited by ronriel

[font="Comic Sans MS"]-ronriel[/font][topic="48542"]r4r media player[/topic][topic="80836"]OCR & Paste[/topic]

Link to comment
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
 Share

  • Recently Browsing   0 members

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