Skip to content

Instantly share code, notes, and snippets.

@imorrish
Created October 14, 2018 07:24
Show Gist options
  • Select an option

  • Save imorrish/0eac59207b95dbe7187ef57e358b2ef5 to your computer and use it in GitHub Desktop.

Select an option

Save imorrish/0eac59207b95dbe7187ef57e358b2ef5 to your computer and use it in GitHub Desktop.

Revisions

  1. imorrish created this gist Oct 14, 2018.
    41 changes: 41 additions & 0 deletions MonitorForPlayback.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    $monitor=3 #ATEM input to trigger play and stop
    function ConnectToATEM()
    {
    Try{
    $ATEMipAddress = (Get-ItemProperty -path 'HKCU:\Software\Blackmagic Design\ATEM Software Control').ipAddress
    $DocumentsPath = [Environment]::GetFolderPath("MyDocuments") + '\windowspowershell\SwitcherLib.dll'
    add-type -path $DocumentsPath

    $Global:atem = New-Object SwitcherLib.Switcher($ATEMipAddress)
    $atem.Connect()
    }
    catch{
    write-host "Can't connect to ATEM on $($ATEMipAddrss)."
    Write-Host "ATEM controle software must be installed and have connected to switcher at least one time"
    exit
    }
    }
    ConnectToATEM
    $me=$atem.GetMEs()
    $Global:me1=$me[0]
    $Global:Program = $me1.program
    do{
    [Int32]$CurrentProgram = $Global:me1.Program # | get-member
    if($Global:Program -ne $CurrentProgram){

    if($CurrentProgram -eq $monitor){
    #Play
    write-host "Play"
    }
    elseif($Global:Program -eq $monitor){
    #Stop
    write-host "Stop"
    }


    $Global:Program = $CurrentProgram

    }
    start-sleep -Milliseconds 10

    }while($true)