Jump to content
Sign in to follow this  
cramaboule

Open and Play Movie with MPC Driven by AutoIt

Recommended Posts

cramaboule

Hello All,

Here is one of my program.

I use AutoIt to choose a movie file and then I can Play it with MPC (Media Player Classic) link which is OpenSource and has some command lines...

I Use this program to play video on a beamer

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>


GUICreate("Play vidéo", 300, 130)
$ButtonO = GUICtrlCreateButton("Open movie", 5, 5, 135, 25)
$ButtonP = GUICtrlCreateButton("Play movie", 155, 5, 135, 25)
$Label = GUICtrlCreateLabel("", 5, 95, 290, 35)
$Group1 = GUICtrlCreateGroup("Which screen ?", 5, 35, 285, 50)
$Radio1 = GUICtrlCreateRadio("Main Screen", 15, 60, 115, 20)

If  _Monitor()= "monitor 2" Then $Radio2 = GUICtrlCreateRadio("Secondary Screen", 160, 60, 115, 20)
GUICtrlSetState( -1, $GUI_CHECKED)

GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)


While 1
$msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $ButtonO
            $Open=FileOpenDialog("Open movie", @WorkingDir, "All (*.*)")
            GUICtrlSetData ( $Label, $Open)
        Case $msg = $ButtonP
            If GUICtrlRead($Radio1) = $GUI_CHECKED Then
                $Mon = 1
            Else
                $Mon = 2
            EndIf
            ShellExecute(_SearchPath(),Chr(34)&$Open&Chr(34)&" "&"/play /fullscreen /close /"&_Monitor($Mon))
    EndSelect
WEnd

Func _SearchPath()
    $PathExe = StringTrimLeft(StringTrimRight(RegRead("HKEY_CLASSES_ROOT\Applications\mplayerc.exe\shell\Open\Command\",""),6),1)
    If $PathExe = "" Then
        MsgBox (0, "Error:", "mplayerc.exe (MPC) is not installed in your PC")
        Exit
    Else
        Return $PathExe
    EndIf
EndFunc

Func _Monitor($flag=0)
    Local $i = 0, $Out, $MaxMon
    While 1
        $aDevice = _WinAPI_EnumDisplayDevices("", $i)
        If Not $aDevice[0] Or  Not StringRegExp ( $aDevice[1], "DISPLAY[12]" , 0 ) Then ExitLoop
        If BitAND($aDevice[3], 2) = 2 And BitAND($aDevice[3], 1) = 1 Then
            $MaxMon = "monitor "&StringRight($aDevice[1],1)
            If $flag = 1 then 
                $Out = $MaxMon
                ExitLoop
            EndIf
        ElseIf BitAND($aDevice[3], 1) = 1 Then
            $MaxMon= "monitor "&StringRight($aDevice[1],1)
            If $flag = 2 then 
                $Out = $MaxMon
            EndIf
        Else
            $Out = $MaxMon
        EndIf
        $i += 1
    WEnd
        If $flag = 0 Then $Out = $MaxMon
    Return $Out
EndFunc

Cram

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  

×