import { useState } from 'react' import fetch from 'isomorphic-unfetch' import {useSocket} from '../hooks/useSocket' import Layout from '../components/Layout' const mixerLabels = { mock: "Built-In Mock for testing", atem: "ATEM by Blackmagic Design", vmix: "vMix", "null": "Off", } const Config = props => { const allowedMixers = props.allowedMixers const [currentMixerId, setCurrentMixerId] = useState(props.currentMixerId) const [atemIp, setAtemIp] = useState(props.atem.ip) const [atemPort, setAtemPort] = useState(props.atem.port) const [vmixIp, setVmixIp] = useState(props.vmix.ip) const [vmixPort, setVmixPort] = useState(props.vmix.port) const [mockTickTime, setMockTickTime] = useState(props.mock.tickTime) const [mockChannelCount, setMockChannelCount] = useState(props.mock.channelCount) const [mockChannelNames, setMockChannelNames] = useState(props.mock.channelNames) const socket = useSocket('config', config => { setCurrentMixerId(config.currentMixerId) setAtemIp(config.atem.ip) setAtemPort(config.atem.port) setVmixIp(config.vmix.ip) setVmixPort(config.vmix.port) setMockTickTime(config.mock.tickTime) setMockChannelCount(config.mock.channelCount) setMockChannelNames(config.mock.channelNames) }) const handleSubmit = e => { socket.emit('config.changeRequest', currentMixerId, atemIp, atemPort, vmixIp, vmixPort, mockTickTime, mockChannelCount, mockChannelNames) e.preventDefault() } const addMixerOption = function(id) { const label = mixerLabels[id] return ( {label} ) } return ( Video Mixer Select a Video Mixer to use. setCurrentMixerId(e.target.value)}> {allowedMixers.map(addMixerOption)} {currentMixerId === "mock" ? ( Mock Configuration This simulates a Video Mixer by changing the channels randomly at a fixed time interval. It is intended for development, when you do not have a video mixer at hand, but serves no purpose in productive environments. Change program every ms setMockTickTime(e.target.value)} /> Number of Channels setMockChannelCount(e.target.value)} /> Channel Names setMockChannelNames(e.target.value)} /> ): ""} {currentMixerId === "atem" ? ( ATEM Configuration Connects to any ATEM device over network. ATEM IP setAtemIp(e.target.value)} /> ATEM Port setAtemPort(e.target.value)} /> ) : ""} {currentMixerId === "vmix" ? ( vMix Configuration Connects to any vMix over network. vMix IP setVmixIp(e.target.value)} /> vMix Port setVmixPort(e.target.value)} /> ) : ""} {currentMixerId === "null" ? ( This cuts the connection to any video mixer. ) : ""} Save ) } Config.getInitialProps = async (context) => { const baseUrl = context && context.req ? `${context.req.protocol}://${context.req.get('Host')}` : ''; const response = await fetch(baseUrl + '/atem') const info = await response.json() return info } export default Config;
Select a Video Mixer to use.
This simulates a Video Mixer by changing the channels randomly at a fixed time interval. It is intended for development, when you do not have a video mixer at hand, but serves no purpose in productive environments.
Connects to any ATEM device over network.
Connects to any vMix over network.
This cuts the connection to any video mixer.