pan
This commit is contained in:
@@ -2,12 +2,16 @@ package net.eksb.obsdc
|
|||||||
|
|
||||||
import io.obswebsocket.community.client.OBSRemoteController
|
import io.obswebsocket.community.client.OBSRemoteController
|
||||||
import io.obswebsocket.community.client.message.event.ui.StudioModeStateChangedEvent
|
import io.obswebsocket.community.client.message.event.ui.StudioModeStateChangedEvent
|
||||||
|
import io.obswebsocket.community.client.model.SceneItem.Transform
|
||||||
|
import io.obswebsocket.community.client.model.SceneItem.Transform.TransformBuilder
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.util.concurrent.BlockingQueue
|
import java.util.concurrent.BlockingQueue
|
||||||
|
|
||||||
// protocol docs: https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md
|
// protocol docs: https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md
|
||||||
class ObsCommunity(private val q:BlockingQueue<Op>): AutoCloseable {
|
class ObsCommunity(private val q:BlockingQueue<Op>): AutoCloseable {
|
||||||
|
|
||||||
|
private val panAmount = 50F
|
||||||
|
|
||||||
private val controller = OBSRemoteController.builder()
|
private val controller = OBSRemoteController.builder()
|
||||||
.host("localhost")
|
.host("localhost")
|
||||||
.port(4455)
|
.port(4455)
|
||||||
@@ -56,6 +60,10 @@ class ObsCommunity(private val q:BlockingQueue<Op>): AutoCloseable {
|
|||||||
ready()
|
ready()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Op.PAN_UP -> { pan { old -> positionY(old.positionY - panAmount ) } }
|
||||||
|
Op.PAN_DOWN -> { pan { old -> positionY(old.positionY + panAmount ) } }
|
||||||
|
Op.PAN_LEFT -> { pan { old -> positionX(old.positionX - panAmount ) } }
|
||||||
|
Op.PAN_RIGHT -> { pan { old -> positionX(old.positionX + panAmount ) } }
|
||||||
Op.TODO -> {
|
Op.TODO -> {
|
||||||
log.info("OP=TODO")
|
log.info("OP=TODO")
|
||||||
ready()
|
ready()
|
||||||
@@ -63,6 +71,30 @@ class ObsCommunity(private val q:BlockingQueue<Op>): AutoCloseable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun pan(block:TransformBuilder.(Transform)->TransformBuilder) {
|
||||||
|
controller.getCurrentProgramScene { response ->
|
||||||
|
val sceneName = response.currentProgramSceneName
|
||||||
|
log.info("scene name: ${sceneName}")
|
||||||
|
controller.getSceneItemList(sceneName) { response ->
|
||||||
|
val item = response.sceneItems.last()
|
||||||
|
val itemId = item.sceneItemId
|
||||||
|
log.info("last item id: ${itemId}")
|
||||||
|
controller.getSceneItemTransform(sceneName, itemId) { response ->
|
||||||
|
val transform = response.sceneItemTransform
|
||||||
|
log.info("position: ${transform.positionX} x ${transform.positionY}")
|
||||||
|
val newTransform = block(Transform.builder(), transform).build()
|
||||||
|
controller.setSceneItemTransform(sceneName, itemId, newTransform) { response ->
|
||||||
|
log.info("transform successful: ${response.isSuccessful}")
|
||||||
|
// Have to set the current scene to take effect if in studio mode.
|
||||||
|
controller.setCurrentProgramScene(sceneName) { response ->
|
||||||
|
ready()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val log = LoggerFactory.getLogger(ObsCommunity::class.java)
|
private val log = LoggerFactory.getLogger(ObsCommunity::class.java)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ package net.eksb.obsdc
|
|||||||
enum class Op {
|
enum class Op {
|
||||||
STUDIO_TRANSITION,
|
STUDIO_TRANSITION,
|
||||||
SCENE_TEST,
|
SCENE_TEST,
|
||||||
|
PAN_UP,
|
||||||
|
PAN_DOWN,
|
||||||
|
PAN_LEFT,
|
||||||
|
PAN_RIGHT,
|
||||||
TODO,
|
TODO,
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user