nrkno / sofie-atem-connection

Sofie ATEM Connection: A Part of the Sofie TV Studio Automation System
https://github.com/nrkno/Sofie-TV-automation/
MIT License
129 stars 36 forks source link

setTime(), requestTime() #127

Closed bevand10 closed 2 years ago

bevand10 commented 2 years ago

Do you have any worked examples of these two methods?

I'm attempting to requestTime from an Atem Mini Extreme ISO and getting nothing of value in response other than 'undefined'. Other commands such as state enquiry/update events, running macros, switching main and preview sources, starting and stopping recording, stopping streaming etc are working fine.

Env: Node 16 (non TS) on Ubuntu 20.04.

Julusian commented 2 years ago

You don't get anything back in that promise, because the atem doesn't respond in a way we can reliably match up with the request.

You can do this to do something every time the atem sends you the time, which I have a feeling it does at other times by itself too.

client.on('stateChanged', (newState, changedPaths) => {
    if (changedPaths.includes('info.lastTime')) {
        console.log(`New time: ${newState.info.lastTime}`)
    }
})

Soon after you make a call to client.requestTime(), that handler should get an updated state with an updated time