essential-actions
Clone or download
Modified Files
.idea/
.idea/
target/
target/
*.iml
.classpath
.classpath
.factorypath
.factorypath
.project
.project
.settings/
.settings/
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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">
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>
<modelVersion>4.0.0</modelVersion>
<groupId>com.stream-pi</groupId>
<groupId>com.stream-pi</groupId>
<artifactId>obssuite_togglerecordingaction</artifactId>
<artifactId>obssuite_togglerecordingaction</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<build>
<build>
<plugins>
<plugins>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<version>3.1.0</version>
<executions>
<executions>
<execution>
<execution>
<id>test-jar</id>
<id>test-jar</id>
<phase>package</phase>
<phase>package</phase>
<goals>
<goals>
<goal>test-jar</goal>
<goal>test-jar</goal>
</goals>
</goals>
</execution>
</execution>
</executions>
</executions>
</plugin>
</plugin>
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.8.1</version>
<configuration>
<configuration>
<release>11</release>
<release>11</release>
</configuration>
</configuration>
</plugin>
</plugin>
</plugins>
</plugins>
</build>
</build>
<properties>
<properties>
<ActionAPIVersion>1.0.0-SNAPSHOT</ActionAPIVersion>
<ActionAPIVersion>1.0.0-SNAPSHOT</ActionAPIVersion>
<UtilVersion>1.0.0-SNAPSHOT</UtilVersion>
<UtilVersion>1.0.0-SNAPSHOT</UtilVersion>
<OBSSuiteMotherVersion>2.0.0</OBSSuiteMotherVersion>
<OBSSuiteMotherVersion>2.0.1</OBSSuiteMotherVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.target>11</maven.compiler.target>
</properties>
</properties>
<dependencies>
<dependencies>
<dependency>
<dependency>
<groupId>com.stream-pi</groupId>
<groupId>com.stream-pi</groupId>
<artifactId>util</artifactId>
<artifactId>util</artifactId>
<version>${UtilVersion}</version>
<version>${UtilVersion}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>com.stream-pi</groupId>
<groupId>com.stream-pi</groupId>
<artifactId>action-api</artifactId>
<artifactId>action-api</artifactId>
<version>${ActionAPIVersion}</version>
<version>${ActionAPIVersion}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>com.stream-pi</groupId>
<groupId>com.stream-pi</groupId>
<artifactId>obssuite_motheraction</artifactId>
<artifactId>obssuite_motheraction</artifactId>
<version>${OBSSuiteMotherVersion}</version>
<version>${OBSSuiteMotherVersion}</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
package togglerecording;
package togglerecording;
import com.stream_pi.action_api.actionproperty.property.Property;
import com.stream_pi.action_api.actionproperty.property.Property;
import com.stream_pi.action_api.actionproperty.property.Type;
import com.stream_pi.action_api.actionproperty.property.Type;
import com.stream_pi.action_api.externalplugin.ToggleAction;
import com.stream_pi.action_api.externalplugin.ToggleAction;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.exception.MinorException;
import com.stream_pi.util.exception.MinorException;
import mother.motherconnection.MotherConnection;
import mother.motherconnection.MotherConnection;
public class ToggleRecording extends ToggleAction
public class ToggleRecording extends ToggleAction
{
{
public ToggleRecording()
public ToggleRecording()
{
{
setName("Toggle Recording");
setName("Toggle Recording");
setCategory("OBS");
setCategory("OBS");
setVisibilityInServerSettingsPane(false);
setVisibilityInServerSettingsPane(false);
setAuthor("rnayabed");
setAuthor("rnayabed");
setVersion(MotherConnection.VERSION);
setVersion(MotherConnection.VERSION);
}
}
@Override
@Override
public void onToggleOn() throws Exception
public void onToggleOn() throws MinorException
{
{
onClicked(true);
onClicked(true);
}
}
@Override
@Override
public void onToggleOff() throws Exception
public void onToggleOff() throws MinorException
{
{
onClicked(false);
onClicked(false);
}
}
@Override
@Override
public void initProperties() throws Exception
public void initProperties() throws MinorException
{
{
Property autoConnectProperty = new Property("auto_connect", Type.BOOLEAN);
Property autoConnectProperty = new Property("auto_connect", Type.BOOLEAN);
autoConnectProperty.setDefaultValueBoolean(true);
autoConnectProperty.setDefaultValueBoolean(true);
autoConnectProperty.setDisplayName("Auto Connect if not connected");
autoConnectProperty.setDisplayName("Auto Connect if not connected");
addClientProperties(autoConnectProperty);
addClientProperties(autoConnectProperty);
}
}
public void onClicked(boolean record) throws MinorException
public void onClicked(boolean record) throws MinorException
{
{
if (MotherConnection.getRemoteController() == null)
if (MotherConnection.getRemoteController() == null)
{
{
boolean autoConnect = getClientProperties().getSingleProperty(
boolean autoConnect = getClientProperties().getSingleProperty(
"auto_connect"
"auto_connect"
).getBoolValue();
).getBoolValue();
if(autoConnect)
if(autoConnect)
{
{
MotherConnection.connect(()->setRecording(record));
MotherConnection.connect(()->setRecording(record));
}
}
else
else
{
{
MotherConnection.showOBSNotRunningError();
MotherConnection.showOBSNotRunningError();
}
}
}
}
else
else
{
{
setRecording(record);
setRecording(record);
}
}
}
}
public void setRecording(boolean recording)
public void setRecording(boolean recording)
{
{
if(recording)
if(recording)
{
{
MotherConnection.getRemoteController().startRecording(setRecordingResponse -> {
MotherConnection.getRemoteController().startRecording(setRecordingResponse -> {
String status = setRecordingResponse.getStatus();
String status = setRecordingResponse.getStatus();
String error = setRecordingResponse.getError();
String error = setRecordingResponse.getError();
errorHandler(status, error);
errorHandler(status, error);
});
});
}
}
else
else
{
{
MotherConnection.getRemoteController().stopRecording(setRecordingResponse -> {
MotherConnection.getRemoteController().stopRecording(setRecordingResponse -> {
String status = setRecordingResponse.getStatus();
String status = setRecordingResponse.getStatus();
String error = setRecordingResponse.getError();
String error = setRecordingResponse.getError();
errorHandler(status, error);
errorHandler(status, error);
});
});
}
}
}
}
private void errorHandler(String status, String error)
private void errorHandler(String status, String error)
{
{
if(status.equals("error"))
if(status.equals("error"))
{
{
new StreamPiAlert("OBS",error, StreamPiAlertType.ERROR).show();
new StreamPiAlert("OBS",error, StreamPiAlertType.ERROR).show();
}
}
}
}
}
}