From: Debayan Sutradhar Date: Thu, 24 Jun 2021 20:22:28 +0530 Subject: [OBS] - Added Toggle Source Visibility and Toggle Source Filter Visibility --- [OBS] - Added Toggle Source Visibility and Toggle Source Filter Visibility --- --- 'a/build.bat' +++ b/build.bat @@ -89,6 +89,14 @@ cd ..\togglestudiomode CALL mvn clean -Dmaven.test.skip package move target\obssuite_togglestudiomodeaction-*.jar ..\..\%FOLD%\obssuite_togglestudiomodeaction.jar +cd ..\togglesourcevisibility +CALL mvn clean -Dmaven.test.skip package +move target\obssuite_togglesourcevisibility-*.jar ..\..\%FOLD%\obssuite_togglesourcevisibility.jar + +cd ..\togglesourcefiltervisibility +CALL mvn clean -Dmaven.test.skip package +move target\obssuite_togglesourcefiltervisibility-*.jar ..\..\%FOLD%\obssuite_togglesourcefiltervisibility.jar + cd ..\setvolume CALL mvn clean -Dmaven.test.skip package move target\obssuite_setvolumeaction-*.jar ..\..\%FOLD%\obssuite_setvolumeaction.jar --- 'a/build.sh' +++ b/build.sh @@ -54,6 +54,13 @@ obssuite() { cd ../setvolume && mvn clean -Dmaven.test.skip package mv target/obssuite_setvolumeaction-*.jar ../../$FOLD/obssuite_setvolumeaction.jar + + cd ../togglesourcevisibility && mvn clean -Dmaven.test.skip package + mv target/obssuite_togglesourcevisibility-*.jar ../../$FOLD/obssuite_togglesourcevisibility.jar + + cd ../togglesourcefiltervisibility && mvn clean -Dmaven.test.skip package + mv target/obssuite_togglesourcefiltervisibility-*.jar ../../$FOLD/obssuite_togglesourcefiltervisibility.jar + popd || exit } --- /dev/null +++ b/obssuite/togglesourcefiltervisibility/pom.xml @@ -0,0 +1,68 @@ + + + 4.0.0 + + com.stream-pi + obssuite_togglesourcefiltervisibility + 2.0.1 + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.1.0 + + + test-jar + package + + test-jar + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + + + + + + + 1.0.0-SNAPSHOT + 2.0.1 + + UTF-8 + 11 + 11 + + + + + com.stream-pi + action-api + ${ActionAPIVersion} + + + + com.stream-pi + obssuite_motheraction + ${OBSSuiteMotherVersion} + + + + + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + + + --- /dev/null +++ b/obssuite/togglesourcefiltervisibility/src/main/java/module-info.java @@ -0,0 +1,12 @@ +import togglevisibility.ToggleVisibility; + +module com.stream_pi.obssuite.togglesourcefiltervisibility +{ + requires com.stream_pi.action_api; + requires com.stream_pi.util; + + requires obs.websocket.java; + requires com.stream_pi.obssuite.motheraction; + + provides com.stream_pi.action_api.externalplugin.ExternalPlugin with ToggleVisibility; +} --- /dev/null +++ b/obssuite/togglesourcefiltervisibility/src/main/java/togglevisibility/ToggleVisibility.java @@ -0,0 +1,99 @@ +package togglevisibility; + +import com.stream_pi.action_api.actionproperty.property.Property; +import com.stream_pi.action_api.actionproperty.property.Type; +import com.stream_pi.action_api.externalplugin.ToggleAction; +import com.stream_pi.util.alert.StreamPiAlert; +import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.exception.MinorException; +import mother.motherconnection.MotherConnection; + +public class ToggleVisibility extends ToggleAction +{ + public ToggleVisibility() + { + setName("Toggle Source Filter Visibility"); + setCategory("OBS"); + setVisibilityInServerSettingsPane(false); + setAuthor("rnayabed"); + setVersion(MotherConnection.VERSION); + } + + @Override + public void onToggleOn() throws MinorException + { + onClicked(true); + } + + @Override + public void onToggleOff() throws MinorException + { + onClicked(false); + } + + @Override + public void initProperties() throws MinorException + { + Property sourceProperty = new Property("source", Type.STRING); + sourceProperty.setDisplayName("Source"); + + Property filterProperty = new Property("filter", Type.STRING); + filterProperty.setDisplayName("Filter"); + + Property autoConnectProperty = new Property("auto_connect", Type.BOOLEAN); + autoConnectProperty.setDefaultValueBoolean(true); + autoConnectProperty.setDisplayName("Auto Connect if not connected"); + + addClientProperties(sourceProperty, filterProperty, autoConnectProperty); + } + + public void onClicked(boolean visible) throws MinorException + { + String source = getClientProperties().getSingleProperty("source").getStringValue(); + String filter = getClientProperties().getSingleProperty("filter").getStringValue(); + + if(source.isBlank()) + { + throw new MinorException("Blank Source Name","No Source specified"); + } + + if(filter.isBlank()) + { + throw new MinorException("Blank Filter Name","No Source specified"); + } + + if (MotherConnection.getRemoteController() == null) + { + boolean autoConnect = getClientProperties().getSingleProperty( + "auto_connect" + ).getBoolValue(); + + if(autoConnect) + { + MotherConnection.connect(()->setVisibility(source, filter, visible)); + } + else + { + MotherConnection.showOBSNotRunningError(); + } + } + else + { + setVisibility(source, filter, visible); + } + } + + public void setVisibility(String source, String filter, boolean visible) + { + MotherConnection.getRemoteController().setSourceFilterVisibility(source, filter, visible, setVisibilityResponse -> { + String status = setVisibilityResponse.getStatus(); + String error = setVisibilityResponse.getError(); + + if(status.equals("error")) + { + new StreamPiAlert("OBS",error, StreamPiAlertType.ERROR).show(); + } + }); + + } +} --- /dev/null +++ b/obssuite/togglesourcevisibility/pom.xml @@ -0,0 +1,68 @@ + + + 4.0.0 + + com.stream-pi + obssuite_togglesourcevisibility + 2.0.1 + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.1.0 + + + test-jar + package + + test-jar + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + + + + + + + 1.0.0-SNAPSHOT + 2.0.1 + + UTF-8 + 11 + 11 + + + + + com.stream-pi + action-api + ${ActionAPIVersion} + + + + com.stream-pi + obssuite_motheraction + ${OBSSuiteMotherVersion} + + + + + + sonatype-snapshots + https://oss.sonatype.org/content/repositories/snapshots/ + + + --- /dev/null +++ b/obssuite/togglesourcevisibility/src/main/java/module-info.java @@ -0,0 +1,12 @@ +import togglevisibility.ToggleVisibility; + +module com.stream_pi.obssuite.togglesourcevisibility +{ + requires com.stream_pi.action_api; + requires com.stream_pi.util; + + requires obs.websocket.java; + requires com.stream_pi.obssuite.motheraction; + + provides com.stream_pi.action_api.externalplugin.ExternalPlugin with ToggleVisibility; +} --- /dev/null +++ b/obssuite/togglesourcevisibility/src/main/java/togglevisibility/ToggleVisibility.java @@ -0,0 +1,99 @@ +package togglevisibility; + +import com.stream_pi.action_api.actionproperty.property.Property; +import com.stream_pi.action_api.actionproperty.property.Type; +import com.stream_pi.action_api.externalplugin.ToggleAction; +import com.stream_pi.util.alert.StreamPiAlert; +import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.exception.MinorException; +import mother.motherconnection.MotherConnection; + +public class ToggleVisibility extends ToggleAction +{ + public ToggleVisibility() + { + setName("Toggle Source Visibility"); + setCategory("OBS"); + setVisibilityInServerSettingsPane(false); + setAuthor("rnayabed"); + setVersion(MotherConnection.VERSION); + } + + @Override + public void onToggleOn() throws MinorException + { + onClicked(true); + } + + @Override + public void onToggleOff() throws MinorException + { + onClicked(false); + } + + @Override + public void initProperties() throws MinorException + { + Property sceneProperty = new Property("scene", Type.STRING); + sceneProperty.setDisplayName("Scene"); + + Property sourceProperty = new Property("source", Type.STRING); + sourceProperty.setDisplayName("Source"); + + Property autoConnectProperty = new Property("auto_connect", Type.BOOLEAN); + autoConnectProperty.setDefaultValueBoolean(true); + autoConnectProperty.setDisplayName("Auto Connect if not connected"); + + addClientProperties(sceneProperty, sourceProperty, autoConnectProperty); + } + + public void onClicked(boolean visible) throws MinorException + { + String source = getClientProperties().getSingleProperty("source").getStringValue(); + String scene = getClientProperties().getSingleProperty("scene").getStringValue(); + + if(source.isBlank()) + { + throw new MinorException("Blank Source Name","No Source specified"); + } + + if(scene.isBlank()) + { + throw new MinorException("Blank Scene Name","No Source specified"); + } + + if (MotherConnection.getRemoteController() == null) + { + boolean autoConnect = getClientProperties().getSingleProperty( + "auto_connect" + ).getBoolValue(); + + if(autoConnect) + { + MotherConnection.connect(()->setVisibility(scene, source, visible)); + } + else + { + MotherConnection.showOBSNotRunningError(); + } + } + else + { + setVisibility(scene, source, visible); + } + } + + public void setVisibility(String scene, String source, boolean visible) + { + MotherConnection.getRemoteController().setSourceVisibility(scene, source, visible, setVisibilityResponse -> { + String status = setVisibilityResponse.getStatus(); + String error = setVisibilityResponse.getError(); + + if(status.equals("error")) + { + new StreamPiAlert("OBS",error, StreamPiAlertType.ERROR).show(); + } + }); + + } +}