essential-actions

Clone or download

[OBS] - Added Toggle Source Visibility and Toggle Source Filter Visibility

Modified Files

M build.bat
+8 −0
--- '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
M build.sh
+7 −0
--- '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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>com.stream-pi</groupId>
+ <artifactId>obssuite_togglesourcefiltervisibility</artifactId>
+ <version>2.0.1</version>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.1.0</version>
+ <executions>
+ <execution>
+ <id>test-jar</id>
+ <phase>package</phase>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.1</version>
+ <configuration>
+ <release>11</release>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <properties>
+ <ActionAPIVersion>1.0.0-SNAPSHOT</ActionAPIVersion>
+ <OBSSuiteMotherVersion>2.0.1</OBSSuiteMotherVersion>
+
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compiler.source>11</maven.compiler.source>
+ <maven.compiler.target>11</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.stream-pi</groupId>
+ <artifactId>action-api</artifactId>
+ <version>${ActionAPIVersion}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.stream-pi</groupId>
+ <artifactId>obssuite_motheraction</artifactId>
+ <version>${OBSSuiteMotherVersion}</version>
+ </dependency>
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>sonatype-snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
+ </repository>
+ </repositories>
+</project>
--- /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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>com.stream-pi</groupId>
+ <artifactId>obssuite_togglesourcevisibility</artifactId>
+ <version>2.0.1</version>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.1.0</version>
+ <executions>
+ <execution>
+ <id>test-jar</id>
+ <phase>package</phase>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.1</version>
+ <configuration>
+ <release>11</release>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <properties>
+ <ActionAPIVersion>1.0.0-SNAPSHOT</ActionAPIVersion>
+ <OBSSuiteMotherVersion>2.0.1</OBSSuiteMotherVersion>
+
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.compiler.source>11</maven.compiler.source>
+ <maven.compiler.target>11</maven.compiler.target>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.stream-pi</groupId>
+ <artifactId>action-api</artifactId>
+ <version>${ActionAPIVersion}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.stream-pi</groupId>
+ <artifactId>obssuite_motheraction</artifactId>
+ <version>${OBSSuiteMotherVersion}</version>
+ </dependency>
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>sonatype-snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
+ </repository>
+ </repositories>
+</project>
--- /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();
+ }
+ });
+
+ }
+}