essential-actions

Clone or download

[OBS] Updated Mother, SetCurrentProfile, SetCurrentScene, SetCurrentTransition, SetMute, SetRecording, SetPreviewScene according to 2.0.0

Modified Files

--- 'a/obssuite/mother/.gitignore'
+++ b/obssuite/mother/.gitignore
@@ -5,3 +5,4 @@ target/
.factorypath
.project
.settings/
+obssuite_motheraction.iml
\ No newline at end of file
--- 'a/obssuite/mother/OBSSuite-MotherAction.iml'
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
- <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_11">
- <output url="file://$MODULE_DIR$/target/classes" />
- <output-test url="file://$MODULE_DIR$/target/test-classes" />
- <content url="file://$MODULE_DIR$">
- <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
- <excludeFolder url="file://$MODULE_DIR$/target" />
- </content>
- <orderEntry type="inheritedJdk" />
- <orderEntry type="sourceFolder" forTests="false" />
- <orderEntry type="library" name="Maven: com.stream-pi:util:1.0.0-SNAPSHOT" level="project" />
- <orderEntry type="library" name="Maven: org.openjfx:javafx-controls:16-ea+7" level="project" />
- <orderEntry type="library" name="Maven: org.openjfx:javafx-controls:linux:16-ea+7" level="project" />
- <orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:16-ea+7" level="project" />
- <orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:linux:16-ea+7" level="project" />
- <orderEntry type="library" name="Maven: org.openjfx:javafx-base:16-ea+7" level="project" />
- <orderEntry type="library" name="Maven: org.openjfx:javafx-base:linux:16-ea+7" level="project" />
- <orderEntry type="library" name="Maven: org.kordamp.ikonli:ikonli-javafx:11.5.0" level="project" />
- <orderEntry type="library" name="Maven: org.kordamp.ikonli:ikonli-core:11.5.0" level="project" />
- <orderEntry type="library" name="Maven: org.kordamp.ikonli:ikonli-fontawesome5-pack:11.5.0" level="project" />
- <orderEntry type="library" name="Maven: com.stream-pi:action-api:1.0.0-SNAPSHOT" level="project" />
- <orderEntry type="library" name="Maven: net.twasi:obs-websocket-java:1.2.0" level="project" />
- <orderEntry type="library" scope="RUNTIME" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" />
- <orderEntry type="library" scope="RUNTIME" name="Maven: org.slf4j:slf4j-simple:1.7.30" level="project" />
- <orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-client:9.4.35.v20201120" level="project" />
- <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-client:9.4.35.v20201120" level="project" />
- <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-http:9.4.35.v20201120" level="project" />
- <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-util:9.4.35.v20201120" level="project" />
- <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-io:9.4.35.v20201120" level="project" />
- <orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-common:9.4.35.v20201120" level="project" />
- <orderEntry type="library" name="Maven: org.eclipse.jetty.websocket:websocket-api:9.4.35.v20201120" level="project" />
- <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.6" level="project" />
- </component>
-</module>
\ No newline at end of file
--- 'a/obssuite/mother/src/main/java/mother/OBSActionConnectionTask.java'
+++ b/obssuite/mother/src/main/java/mother/OBSActionConnectionTask.java
@@ -102,7 +102,7 @@ public class OBSActionConnectionTask ext
}
catch (Exception e)
{
- new StreamPiAlert("Unable to Connect", "Unable to establish connection to WebSocket with provided crendentials", StreamPiAlertType.ERROR).show();
+ MotherConnection.showOBSNotRunningError();
MotherConnection.setRemoteController(null);
e.printStackTrace();
}
--- 'a/obssuite/mother/src/main/java/mother/motherconnection/MotherConnection.java'
+++ b/obssuite/mother/src/main/java/mother/motherconnection/MotherConnection.java
@@ -8,6 +8,7 @@ import javafx.scene.control.Button;
import mother.OBSActionConnectionTask;
import net.twasi.obsremotejava.OBSRemoteController;
import net.twasi.obsremotejava.callbacks.Callback;
+import net.twasi.obsremotejava.requests.ResponseBase;
public class MotherConnection
{
@@ -83,4 +84,11 @@ public class MotherConnection
}
};
}
+
+ public static void showOBSNotRunningError()
+ {
+ new StreamPiAlert("Is OBS Connected?",
+ "It seems there is no connection to OBS, please connect it in Settings", StreamPiAlertType.WARNING)
+ .show();
+ }
}
--- 'a/obssuite/setcurrentprofile/src/main/java/setcurrentprofile/SetCurrentProfile.java'
+++ b/obssuite/setcurrentprofile/src/main/java/setcurrentprofile/SetCurrentProfile.java
@@ -54,9 +54,7 @@ public class SetCurrentProfile extends N
}
else
{
- new StreamPiAlert("Is OBS Connected?",
- "It seems there is no connection to OBS, please connect it in Settings", StreamPiAlertType.WARNING)
- .show();
+ MotherConnection.showOBSNotRunningError();
}
}
else
--- 'a/obssuite/setcurrentscene/pom.xml'
+++ b/obssuite/setcurrentscene/pom.xml
@@ -6,7 +6,7 @@
<groupId>com.stream-pi</groupId>
<artifactId>obssuite_setcurrentsceneaction</artifactId>
- <version>1.0.0</version>
+ <version>2.0.0</version>
<build>
<plugins>
@@ -39,7 +39,7 @@
<properties>
<ActionAPIVersion>1.0.0-SNAPSHOT</ActionAPIVersion>
<UtilVersion>1.0.0-SNAPSHOT</UtilVersion>
- <OBSSuiteMotherVersion>1.1.0</OBSSuiteMotherVersion>
+ <OBSSuiteMotherVersion>2.0.0</OBSSuiteMotherVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
--- 'a/obssuite/setcurrentscene/src/main/java/setcurrentscene/SetCurrentScene.java'
+++ b/obssuite/setcurrentscene/src/main/java/setcurrentscene/SetCurrentScene.java
@@ -5,56 +5,86 @@ import com.stream_pi.action_api.actionpr
import com.stream_pi.action_api.externalplugin.NormalAction;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlertType;
-import com.stream_pi.util.version.Version;
+import com.stream_pi.util.exception.MinorException;
import mother.motherconnection.MotherConnection;
-import net.twasi.obsremotejava.OBSRemoteController;
-public class SetCurrentScene extends NormalAction {
-
- public SetCurrentScene() {
+public class SetCurrentScene extends NormalAction
+{
+ public SetCurrentScene()
+ {
setName("Set Current Scene");
setCategory("OBS");
setVisibilityInServerSettingsPane(false);
setAuthor("rnayabed");
- setVersion(new Version(1, 0, 0));
+ setVersion(MotherConnection.VERSION);
}
@Override
- public void initProperties() throws Exception {
- // TODO Auto-generated method stub
-
- Property currentSceneProperty = new Property("current_scene", Type.STRING);
+ public void initProperties() throws Exception
+ {
+ Property currentSceneProperty = new Property("scene", Type.STRING);
currentSceneProperty.setDisplayName("Scene Name");
-
- addClientProperties(currentSceneProperty);
- }
- @Override
- public void initAction() throws Exception {
- // TODO Auto-generated method stub
+ Property autoConnectProperty = new Property("auto_connect", Type.BOOLEAN);
+ autoConnectProperty.setDefaultValueBoolean(true);
+ autoConnectProperty.setDisplayName("Auto Connect if not connected");
+
+ addClientProperties(currentSceneProperty, autoConnectProperty);
}
@Override
- public void onActionClicked() throws Exception {
- // TODO Auto-generated method stub
-
- OBSRemoteController controller = MotherConnection.getRemoteController();
+ public void onActionClicked() throws Exception
+ {
+ String scene = getClientProperties().getSingleProperty("scene").getStringValue();
+
+ if(scene.isBlank())
+ {
+ throw new MinorException("Blank Scene Name","No Scene Name specified");
+ }
- if (controller == null) {
- new StreamPiAlert("Is OBS Connected?",
- "It seems there is no connection to OBS, please connect it in Settings", StreamPiAlertType.WARNING)
- .show();
- } else {
- controller.setCurrentScene(getClientProperties().getSingleProperty("current_scene").getStringValue(), MotherConnection.getDefaultCallBack(
- "Unable to Set Current Scene","Failed to set current Scene"
- ));
+ if (MotherConnection.getRemoteController() == null)
+ {
+ boolean autoConnect = getClientProperties().getSingleProperty(
+ "auto_connect"
+ ).getBoolValue();
+
+ if(autoConnect)
+ {
+ MotherConnection.connect(()->setScene(scene));
+ }
+ else
+ {
+ MotherConnection.showOBSNotRunningError();
+ }
+ }
+ else
+ {
+ setScene(scene);
}
}
- @Override
- public void onShutDown() throws Exception {
- // TODO Auto-generated method stub
-
+ public void setScene(String scene)
+ {
+ MotherConnection.getRemoteController().setCurrentScene(scene, setCurrentSceneResponse -> {
+ String status = setCurrentSceneResponse.getStatus();
+ String error = setCurrentSceneResponse.getError();
+
+ if(status.equals("error"))
+ {
+ String content;
+
+ if(error.equals("scene does not exist"))
+ {
+ content = "Scene "+scene+" does not exist.";
+ }
+ else
+ {
+ content = error;
+ }
+
+ new StreamPiAlert("OBS",content, StreamPiAlertType.ERROR).show();
+ }
+ });
}
}
--- 'a/obssuite/setcurrenttransition/pom.xml'
+++ b/obssuite/setcurrenttransition/pom.xml
@@ -6,7 +6,7 @@
<groupId>com.stream-pi</groupId>
<artifactId>obssuite_setcurrenttransitionaction</artifactId>
- <version>1.0.0</version>
+ <version>2.0.0</version>
<build>
<plugins>
@@ -39,7 +39,7 @@
<properties>
<ActionAPIVersion>1.0.0-SNAPSHOT</ActionAPIVersion>
<UtilVersion>1.0.0-SNAPSHOT</UtilVersion>
- <OBSSuiteMotherVersion>1.1.0</OBSSuiteMotherVersion>
+ <OBSSuiteMotherVersion>2.0.0</OBSSuiteMotherVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
--- 'a/obssuite/setcurrenttransition/src/main/java/setcurrenttransition/SetCurrentTransition.java'
+++ b/obssuite/setcurrenttransition/src/main/java/setcurrenttransition/SetCurrentTransition.java
@@ -5,6 +5,7 @@ import com.stream_pi.action_api.actionpr
import com.stream_pi.action_api.externalplugin.NormalAction;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlertType;
+import com.stream_pi.util.exception.MinorException;
import com.stream_pi.util.version.Version;
import mother.motherconnection.MotherConnection;
@@ -12,48 +13,82 @@ import net.twasi.obsremotejava.OBSRemote
public class SetCurrentTransition extends NormalAction {
- public SetCurrentTransition() {
+ public SetCurrentTransition()
+ {
setName("Set Current Transition");
setCategory("OBS");
setVisibilityInServerSettingsPane(false);
setAuthor("rnayabed");
- setVersion(new Version(1, 0, 0));
+ setVersion(MotherConnection.VERSION);
}
@Override
- public void initProperties() throws Exception {
- Property currentTransitionProperty = new Property("current_transition", Type.STRING);
+ public void initProperties() throws Exception
+ {
+ Property currentTransitionProperty = new Property("transition", Type.STRING);
currentTransitionProperty.setDisplayName("Transition Name");
-
- addClientProperties(currentTransitionProperty);
- }
- @Override
- public void initAction() throws Exception {
- // TODO Auto-generated method stub
+ Property autoConnectProperty = new Property("auto_connect", Type.BOOLEAN);
+ autoConnectProperty.setDefaultValueBoolean(true);
+ autoConnectProperty.setDisplayName("Auto Connect if not connected");
+
+ addClientProperties(currentTransitionProperty, autoConnectProperty);
}
- @Override
- public void onActionClicked() throws Exception {
- // TODO Auto-generated method stub
- OBSRemoteController controller = MotherConnection.getRemoteController();
+ @Override
+ public void onActionClicked() throws Exception
+ {
+ String transition = getClientProperties().getSingleProperty("transition").getStringValue();
+
+ if(transition.isBlank())
+ {
+ throw new MinorException("Blank Transition Name","No Transition Name specified");
+ }
- if (controller == null) {
- new StreamPiAlert("Is OBS Connected?",
- "It seems there is no connection to OBS, please connect it in Settings", StreamPiAlertType.WARNING)
- .show();
- } else {
- controller.setCurrentTransition(getClientProperties().getSingleProperty("current_transition").getStringValue(), MotherConnection.getDefaultCallBack(
- "Unable to Set Current Transition","Failed to set current Transition"
- ));
+ if (MotherConnection.getRemoteController() == null)
+ {
+ boolean autoConnect = getClientProperties().getSingleProperty(
+ "auto_connect"
+ ).getBoolValue();
+
+ if(autoConnect)
+ {
+ MotherConnection.connect(()->setTransition(transition));
+ }
+ else
+ {
+ MotherConnection.showOBSNotRunningError();
+ }
+ }
+ else
+ {
+ setTransition(transition);
}
}
- @Override
- public void onShutDown() throws Exception {
- // TODO Auto-generated method stub
+ public void setTransition(String transition)
+ {
+ MotherConnection.getRemoteController().setCurrentTransition(transition, setCurrentTransitionResponse -> {
+ String status = setCurrentTransitionResponse.getStatus();
+ String error = setCurrentTransitionResponse.getError();
+
+ if(status.equals("error"))
+ {
+ String content;
+
+ if(error.equals("transition does not exist"))
+ {
+ content = "Transition "+transition+" does not exist.";
+ }
+ else
+ {
+ content = error;
+ }
+
+ new StreamPiAlert("OBS",content, StreamPiAlertType.ERROR).show();
+ }
+ });
}
-
}
--- 'a/obssuite/setmute/pom.xml'
+++ b/obssuite/setmute/pom.xml
@@ -6,7 +6,7 @@
<groupId>com.stream-pi</groupId>
<artifactId>obssuite_setmuteaction</artifactId>
- <version>1.0.0</version>
+ <version>2.0.0</version>
<build>
<plugins>
@@ -39,7 +39,7 @@
<properties>
<ActionAPIVersion>1.0.0-SNAPSHOT</ActionAPIVersion>
<UtilVersion>1.0.0-SNAPSHOT</UtilVersion>
- <OBSSuiteMotherVersion>1.1.0</OBSSuiteMotherVersion>
+ <OBSSuiteMotherVersion>2.0.0</OBSSuiteMotherVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
--- 'a/obssuite/setmute/src/main/java/setmute/SetMute.java'
+++ b/obssuite/setmute/src/main/java/setmute/SetMute.java
@@ -3,60 +3,102 @@ package setmute;
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.NormalAction;
+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 com.stream_pi.util.version.Version;
import mother.motherconnection.MotherConnection;
import net.twasi.obsremotejava.OBSRemoteController;
-public class SetMute extends NormalAction {
-
- public SetMute() {
+public class SetMute extends ToggleAction
+{
+ public SetMute()
+ {
setName("Set Mute");
setCategory("OBS");
setVisibilityInServerSettingsPane(false);
setAuthor("rnayabed");
- setVersion(new Version(1, 0, 0));
+ setVersion(MotherConnection.VERSION);
}
@Override
- public void initProperties() throws Exception {
- Property sourceProperty = new Property("source", Type.STRING);
- sourceProperty.setDisplayName("Source");
-
- Property isMuteProperty = new Property("mute", Type.BOOLEAN);
- isMuteProperty.setDisplayName("Mute");
-
- addClientProperties(sourceProperty,isMuteProperty);
+ public void onToggleOn() throws Exception
+ {
+ onClicked(true);
}
@Override
- public void initAction() throws Exception {
- // TODO Auto-generated method stub
+ public void onToggleOff() throws Exception
+ {
+ onClicked(false);
}
@Override
- public void onActionClicked() throws Exception {
- // TODO Auto-generated method stub
+ public void initProperties() throws Exception
+ {
+ Property sourceProperty = new Property("source", Type.STRING);
+ sourceProperty.setDisplayName("Source");
- OBSRemoteController controller = MotherConnection.getRemoteController();
+ Property autoConnectProperty = new Property("auto_connect", Type.BOOLEAN);
+ autoConnectProperty.setDefaultValueBoolean(true);
+ autoConnectProperty.setDisplayName("Auto Connect if not connected");
- if (controller == null) {
- new StreamPiAlert("Is OBS Connected?",
- "It seems there is no connection to OBS, please connect it in Settings", StreamPiAlertType.WARNING)
- .show();
- } else {
- controller.setMute(getClientProperties().getSingleProperty("source").getStringValue(), getClientProperties().getSingleProperty("mute").getBoolValue(), MotherConnection.getDefaultCallBack(
- "Failed to mute source","Failed to do that"
- ));
- }
+ addClientProperties(sourceProperty, autoConnectProperty);
}
- @Override
- public void onShutDown() throws Exception {
- // TODO Auto-generated method stub
+ public void onClicked(boolean mute) throws MinorException
+ {
+ String source = getClientProperties().getSingleProperty("source").getStringValue();
+
+ if(source.isBlank())
+ {
+ throw new MinorException("Blank Source Name","No Source specified");
+ }
+
+ if (MotherConnection.getRemoteController() == null)
+ {
+ boolean autoConnect = getClientProperties().getSingleProperty(
+ "auto_connect"
+ ).getBoolValue();
+
+ if(autoConnect)
+ {
+ MotherConnection.connect(()->setMute(source, mute));
+ }
+ else
+ {
+ MotherConnection.showOBSNotRunningError();
+ }
+ }
+ else
+ {
+ setMute(source, mute);
+ }
+ }
+ public void setMute(String scene, boolean mute)
+ {
+ MotherConnection.getRemoteController().setMute(scene, mute, setMuteResponse -> {
+ String status = setMuteResponse.getStatus();
+ String error = setMuteResponse.getError();
+
+ if(status.equals("error"))
+ {
+ String content;
+
+ if(error.equals("source does not exist"))
+ {
+ content = "Source "+scene+" does not exist.";
+ }
+ else
+ {
+ content = error;
+ }
+
+ new StreamPiAlert("OBS",content, StreamPiAlertType.ERROR).show();
+ }
+ });
}
-
}
--- 'a/obssuite/setpreviewscene/pom.xml'
+++ b/obssuite/setpreviewscene/pom.xml
@@ -6,7 +6,7 @@
<groupId>com.stream-pi</groupId>
<artifactId>obssuite_setpreviewsceneaction</artifactId>
- <version>1.0.0</version>
+ <version>2.0.0</version>
<build>
<plugins>
@@ -39,7 +39,7 @@
<properties>
<ActionAPIVersion>1.0.0-SNAPSHOT</ActionAPIVersion>
<UtilVersion>1.0.0-SNAPSHOT</UtilVersion>
- <OBSSuiteMotherVersion>1.1.0</OBSSuiteMotherVersion>
+ <OBSSuiteMotherVersion>2.0.0</OBSSuiteMotherVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
--- 'a/obssuite/setpreviewscene/src/main/java/setpreviewscene/SetPreviewScene.java'
+++ b/obssuite/setpreviewscene/src/main/java/setpreviewscene/SetPreviewScene.java
@@ -5,19 +5,21 @@ import com.stream_pi.action_api.actionpr
import com.stream_pi.action_api.externalplugin.NormalAction;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlertType;
+import com.stream_pi.util.exception.MinorException;
import com.stream_pi.util.version.Version;
import mother.motherconnection.MotherConnection;
import net.twasi.obsremotejava.OBSRemoteController;
-public class SetPreviewScene extends NormalAction {
-
- public SetPreviewScene() {
+public class SetPreviewScene extends NormalAction
+{
+ public SetPreviewScene()
+ {
setName("Set Preview Scene");
setCategory("OBS");
setVisibilityInServerSettingsPane(false);
setAuthor("rnayabed");
- setVersion(new Version(1, 0, 0));
+ setVersion(MotherConnection.VERSION);
}
@Override
@@ -25,35 +27,65 @@ public class SetPreviewScene extends Nor
Property previewSceneProperty = new Property("preview_scene", Type.STRING);
previewSceneProperty.setDisplayName("Preview Scene");
- addClientProperties(previewSceneProperty);
- }
+ Property autoConnectProperty = new Property("auto_connect", Type.BOOLEAN);
+ autoConnectProperty.setDefaultValueBoolean(true);
+ autoConnectProperty.setDisplayName("Auto Connect if not connected");
- @Override
- public void initAction() throws Exception {
- // TODO Auto-generated method stub
+ addClientProperties(previewSceneProperty, autoConnectProperty);
}
@Override
- public void onActionClicked() throws Exception {
- // TODO Auto-generated method stub
-
- OBSRemoteController controller = MotherConnection.getRemoteController();
+ public void onActionClicked() throws Exception
+ {
+ String previewScene = getClientProperties().getSingleProperty("preview_scene").getStringValue();
+
+ if(previewScene.isBlank())
+ {
+ throw new MinorException("Blank Preview Scene Name","No Preview Scene Name specified");
+ }
- if (controller == null) {
- new StreamPiAlert("Is OBS Connected?",
- "It seems there is no connection to OBS, please connect it in Settings", StreamPiAlertType.WARNING)
- .show();
- } else {
- controller.setPreviewScene(getClientProperties().getSingleProperty("preview_scene").getStringValue(), MotherConnection.getDefaultCallBack(
- "Failed to set preview scene","Failed to do that"
- ));
+ if (MotherConnection.getRemoteController() == null)
+ {
+ boolean autoConnect = getClientProperties().getSingleProperty(
+ "auto_connect"
+ ).getBoolValue();
+
+ if(autoConnect)
+ {
+ MotherConnection.connect(()->setPreviewScene(previewScene));
+ }
+ else
+ {
+ MotherConnection.showOBSNotRunningError();
+ }
+ }
+ else
+ {
+ setPreviewScene(previewScene);
}
}
- @Override
- public void onShutDown() throws Exception {
- // TODO Auto-generated method stub
-
+ public void setPreviewScene(String previewScene)
+ {
+ MotherConnection.getRemoteController().setPreviewScene(previewScene, setPreviewSceneResponse -> {
+ String status = setPreviewSceneResponse.getStatus();
+ String error = setPreviewSceneResponse.getError();
+
+ if(status.equals("error"))
+ {
+ String content;
+
+ if(error.equals("scene does not exist"))
+ {
+ content = "Preview Scene "+previewScene+" does not exist.";
+ }
+ else
+ {
+ content = error;
+ }
+
+ new StreamPiAlert("OBS",content, StreamPiAlertType.ERROR).show();
+ }
+ });
}
-
}
--- 'a/obssuite/setrecording/pom.xml'
+++ b/obssuite/setrecording/pom.xml
@@ -6,7 +6,7 @@
<groupId>com.stream-pi</groupId>
<artifactId>obssuite_setrecordingaction</artifactId>
- <version>1.0.0</version>
+ <version>2.0.0</version>
<build>
<plugins>
@@ -39,7 +39,7 @@
<properties>
<ActionAPIVersion>1.0.0-SNAPSHOT</ActionAPIVersion>
<UtilVersion>1.0.0-SNAPSHOT</UtilVersion>
- <OBSSuiteMotherVersion>1.1.0</OBSSuiteMotherVersion>
+ <OBSSuiteMotherVersion>2.0.0</OBSSuiteMotherVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
--- 'a/obssuite/setrecording/src/main/java/setrecording/SetRecording.java'
+++ b/obssuite/setrecording/src/main/java/setrecording/SetRecording.java
@@ -5,73 +5,97 @@ import java.util.ArrayList;
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.NormalAction;
+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 com.stream_pi.util.version.Version;
import mother.motherconnection.MotherConnection;
import net.twasi.obsremotejava.OBSRemoteController;
-public class SetRecording extends NormalAction {
-
+public class SetRecording extends ToggleAction
+{
public SetRecording() {
setName("Set Recording");
setCategory("OBS");
setVisibilityInServerSettingsPane(false);
setAuthor("rnayabed");
- setVersion(new Version(1, 0, 0));
-
- states = new ArrayList<>();
- states.add("Start");
- states.add("Stop");
+ setVersion(MotherConnection.VERSION);
}
- private ArrayList<String> states;
-
@Override
- public void initProperties() throws Exception {
-
- Property recordingStatusProperty = new Property("recording_status", Type.LIST);
- recordingStatusProperty.setListValue(states);
- recordingStatusProperty.setDisplayName("Recording State");
-
- addClientProperties(recordingStatusProperty);
+ public void onToggleOn() throws Exception
+ {
+ onClicked(true);
}
@Override
- public void initAction() throws Exception {
- // TODO Auto-generated method stub
+ public void onToggleOff() throws Exception
+ {
+ onClicked(false);
}
@Override
- public void onActionClicked() throws Exception {
- // TODO Auto-generated method stub
+ public void initProperties() throws Exception
+ {
+ Property autoConnectProperty = new Property("auto_connect", Type.BOOLEAN);
+ autoConnectProperty.setDefaultValueBoolean(true);
+ autoConnectProperty.setDisplayName("Auto Connect if not connected");
- OBSRemoteController controller = MotherConnection.getRemoteController();
+ addClientProperties(autoConnectProperty);
+ }
- if (controller == null) {
- new StreamPiAlert("Is OBS Connected?",
- "It seems there is no connection to OBS, please connect it in Settings", StreamPiAlertType.WARNING)
- .show();
- } else {
-
- String state = states.get(getClientProperties().getSingleProperty("recording_status").getSelectedIndex());
+ public void onClicked(boolean record) throws MinorException
+ {
+ if (MotherConnection.getRemoteController() == null)
+ {
+ boolean autoConnect = getClientProperties().getSingleProperty(
+ "auto_connect"
+ ).getBoolValue();
- if(state.equals("Start"))
+ if(autoConnect)
{
- controller.startRecording(MotherConnection.getDefaultCallBack("Failed to Start Recording","Failed to do that"));
+ MotherConnection.connect(()->setRecording(record));
}
- else if(state.equals("Stop"))
+ else
{
- controller.stopRecording(MotherConnection.getDefaultCallBack("Failed to Stop Recording","Failed to do that"));
+ MotherConnection.showOBSNotRunningError();
}
}
+ else
+ {
+ setRecording(record);
+ }
}
- @Override
- public void onShutDown() throws Exception {
- // TODO Auto-generated method stub
+ public void setRecording(boolean recording)
+ {
+ if(recording)
+ {
+ MotherConnection.getRemoteController().startRecording(setRecordingResponse -> {
+ String status = setRecordingResponse.getStatus();
+ String error = setRecordingResponse.getError();
+ errorHandler(status, error);
+ });
+ }
+ else
+ {
+ MotherConnection.getRemoteController().stopRecording(setRecordingResponse -> {
+ String status = setRecordingResponse.getStatus();
+ String error = setRecordingResponse.getError();
+
+ errorHandler(status, error);
+ });
+ }
+ }
+
+ private void errorHandler(String status, String error)
+ {
+ if(status.equals("error"))
+ {
+ new StreamPiAlert("OBS",error, StreamPiAlertType.ERROR).show();
+ }
}
-
}