essential-actions
Clone or download
Modified Files
<?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_motheraction</artifactId>
<artifactId>obssuite_motheraction</artifactId>
<version>1.1.0</version>
<version>2.0.0</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>
<OBSWebsocketJavaVersion>1.2.0</OBSWebsocketJavaVersion>
<OBSWebsocketJavaVersion>1.2.0</OBSWebsocketJavaVersion>
<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>net.twasi</groupId>
<groupId>net.twasi</groupId>
<artifactId>obs-websocket-java</artifactId>
<artifactId>obs-websocket-java</artifactId>
<version>${OBSWebsocketJavaVersion}</version>
<version>${OBSWebsocketJavaVersion}</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-client</artifactId>
<artifactId>websocket-client</artifactId>
<version>9.4.39.v20210325</version>
<version>9.4.39.v20210325</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
<version>2.8.6</version>
</dependency>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
package mother;
package mother;
import com.stream_pi.action_api.actionproperty.property.ControlType;
import com.stream_pi.action_api.actionproperty.property.ControlType;
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.NormalAction;
import com.stream_pi.action_api.externalplugin.NormalAction;
import com.stream_pi.util.version.Version;
import com.stream_pi.util.version.Version;
import com.stream_pi.util.exception.MinorException;
import com.stream_pi.util.exception.MinorException;
import mother.motherconnection.MotherConnection;
import mother.motherconnection.MotherConnection;
import javafx.scene.control.Button;
import javafx.scene.control.Button;
public class Mother extends NormalAction
public class Mother extends NormalAction
{
{
public Mother()
public Mother()
{
{
setName("OBS Plugin");
setName("OBS Plugin");
setCategory("OBS");
setCategory("OBS");
setVisibilityInPluginsPane(false);
setVisibilityInPluginsPane(false);
setAuthor("rnayabed");
setAuthor("rnayabed");
setHelpLink("https://github.com/Stream-Pi/EssentialActions");
setHelpLink("https://github.com/Stream-Pi/EssentialActions");
setVersion(new Version(1,1,0));
setVersion(MotherConnection.VERSION);
connectDisconnectButton = new Button("Connect");
connectDisconnectButton = new Button("Connect");
setServerSettingsButtonBar(connectDisconnectButton);
setServerSettingsButtonBar(connectDisconnectButton);
}
}
@Override
@Override
public void onActionClicked()
public void onActionClicked()
{
{
}
}
private Button connectDisconnectButton;
private Button connectDisconnectButton;
@Override
@Override
public void initProperties() throws Exception
public void initProperties() throws Exception
{
{
Property urlProperty = new Property("url", Type.STRING);
Property urlProperty = new Property("url", Type.STRING);
urlProperty.setDisplayName("URL");
urlProperty.setDisplayName("URL");
urlProperty.setDefaultValueStr("ws://localhost:4444");
urlProperty.setDefaultValueStr("ws://localhost:4444");
urlProperty.setCanBeBlank(false);
urlProperty.setCanBeBlank(false);
Property passwordProperty = new Property("pass", Type.STRING);
Property passwordProperty = new Property("pass", Type.STRING);
passwordProperty.setControlType(ControlType.TEXT_FIELD_MASKED);
passwordProperty.setControlType(ControlType.TEXT_FIELD_MASKED);
passwordProperty.setDisplayName("Password");
passwordProperty.setDisplayName("Password");
Property connectOnStartupProperty = new Property("connect_on_startup", Type.BOOLEAN);
Property connectOnStartupProperty = new Property("connect_on_startup", Type.BOOLEAN);
connectOnStartupProperty.setDisplayName("Connect On Startup");
connectOnStartupProperty.setDisplayName("Connect On Startup");
connectOnStartupProperty.setDefaultValueBoolean(false);
connectOnStartupProperty.setDefaultValueBoolean(false);
addServerProperties(
addServerProperties(
urlProperty,
urlProperty,
passwordProperty,
passwordProperty,
connectOnStartupProperty
connectOnStartupProperty
);
);
}
}
@Override
@Override
public void initAction() throws Exception {
public void initAction() throws Exception
{
MotherConnection.setPass(getPassword());
MotherConnection.setUrl(getURL());
MotherConnection.setConnectDisconnectButton(connectDisconnectButton);
connectDisconnectButton.setOnAction(action->{
connectDisconnectButton.setOnAction(action->{
try
try
{
{
if(MotherConnection.getRemoteController() == null)
if(MotherConnection.getRemoteController() == null)
{
{
connect(getURL(), getPassword());
connect(getURL(), getPassword());
}
}
else
else
{
{
MotherConnection.getRemoteController().disconnect();
MotherConnection.getRemoteController().disconnect();
}
}
}
}
catch (Exception e)
catch (Exception e)
{
{
e.printStackTrace();
e.printStackTrace();
}
}
});
});
if(isConnectOnStartup() && firstRun)
if(isConnectOnStartup() && firstRun)
{
{
connect(getURL(), getPassword());
connect(getURL(), getPassword());
}
}
firstRun = false;
firstRun = false;
}
}
private boolean firstRun = true;
private boolean firstRun = true;
private String getURL() throws MinorException
private String getURL() throws MinorException
{
{
return getServerProperties().getSingleProperty("url").getStringValue();
return getServerProperties().getSingleProperty("url").getStringValue();
}
}
private String getPassword() throws MinorException
private String getPassword() throws MinorException
{
{
return getServerProperties().getSingleProperty("pass").getStringValue();
return getServerProperties().getSingleProperty("pass").getStringValue();
}
}
private boolean isConnectOnStartup() throws MinorException
private boolean isConnectOnStartup() throws MinorException
{
{
return getServerProperties().getSingleProperty("connect_on_startup").getBoolValue();
return getServerProperties().getSingleProperty("connect_on_startup").getBoolValue();
}
}
private void connect(String url, String pass)
private void connect(String url, String pass)
{
{
MotherConnection.setPass(pass);
MotherConnection.setPass(pass);
MotherConnection.setUrl(url);
MotherConnection.setUrl(url);
new OBSActionConnectionTask(connectDisconnectButton, true);
new OBSActionConnectionTask(true, null, null, null);
}
}
@Override
@Override
public void onShutDown()
public void onShutDown()
{
{
if(MotherConnection.getRemoteController() != null)
if(MotherConnection.getRemoteController() != null)
{
{
MotherConnection.getRemoteController().disconnect();
MotherConnection.getRemoteController().disconnect();
}
}
}
}
}
}
package mother;
package mother;
import mother.motherconnection.MotherConnection;
import mother.motherconnection.MotherConnection;
import javafx.application.Platform;
import javafx.application.Platform;
import javafx.concurrent.Task;
import javafx.concurrent.Task;
import javafx.scene.control.Button;
import javafx.scene.control.Button;
import net.twasi.obsremotejava.OBSRemoteController;
import net.twasi.obsremotejava.OBSRemoteController;
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;
public class OBSActionConnectionTask extends Task<Void>
public class OBSActionConnectionTask extends Task<Void>
{
{
private Runnable onFailToConnectRunnable = null;
private Runnable onConnectRunnable = null;
private Runnable onDisconnectRunnable = null;
String url, pass;
public OBSActionConnectionTask(boolean runAsync, Runnable onFailToConnectRunnable,
Button connectDisconnectButton;
Runnable onConnectRunnable, Runnable onDisconnectRunnable)
public OBSActionConnectionTask(Button connectDisconnectButton,
boolean runAsync)
{
{
this.url = MotherConnection.getUrl();
this.onFailToConnectRunnable = onFailToConnectRunnable;
this.pass = MotherConnection.getPass();
this.onConnectRunnable = onConnectRunnable;
this.connectDisconnectButton = connectDisconnectButton;
this.onDisconnectRunnable = onDisconnectRunnable;
if(runAsync)
if(runAsync)
{
{
new Thread(this).start();
new Thread(this).start();
}
}
else
else
{
{
call();
call();
}
}
}
}
@Override
@Override
protected Void call()
protected Void call()
{
{
try
try
{
{
String url = MotherConnection.getUrl();
String pass = MotherConnection.getPass();
setConnectDisconnectButtonDisable(true);
setConnectDisconnectButtonDisable(true);
if(!url.startsWith("ws://"))
if(!url.startsWith("ws://"))
{
{
new StreamPiAlert("Invalid URL","Please fix URL and try again", StreamPiAlertType.ERROR).show();
new StreamPiAlert("Invalid URL","Please fix URL and try again", StreamPiAlertType.ERROR).show();
return null;
return null;
}
}
if(pass.isEmpty() || pass.isBlank())
if(pass.isEmpty() || pass.isBlank())
pass = null;
pass = null;
OBSRemoteController obsRemoteController = new OBSRemoteController(url, false, pass);
OBSRemoteController obsRemoteController = new OBSRemoteController(url, false, pass);
if(obsRemoteController.isFailed())
if(obsRemoteController.isFailed())
{
{
new StreamPiAlert("Unable to Connect to OBS", "Is it even running? Make sure the websocket plugin is installed. Check Credentials too", StreamPiAlertType.ERROR).show();
new StreamPiAlert("Unable to Connect to OBS", "Is it even running? Make sure the websocket plugin is installed. Check Credentials too", StreamPiAlertType.ERROR).show();
}
}
obsRemoteController.registerConnectionFailedCallback(message->{
obsRemoteController.registerConnectionFailedCallback(message->{
setConnectDisconnectButtonText("Connect");
setConnectDisconnectButtonText("Connect");
new StreamPiAlert("Unable to Connect", "Unable to establish connection to WebSocket with provided crendentials\n\n"+
new StreamPiAlert("Unable to Connect", "Unable to establish connection to WebSocket with provided crendentials\n\n"+
"Detailed Error : "+message, StreamPiAlertType.ERROR).show();
"Detailed Error : "+message, StreamPiAlertType.ERROR).show();
MotherConnection.setRemoteController(null);
MotherConnection.setRemoteController(null);
if(onFailToConnectRunnable != null)
{
onFailToConnectRunnable.run();
onFailToConnectRunnable = null;
}
});
});
obsRemoteController.registerDisconnectCallback(()->{
obsRemoteController.registerDisconnectCallback(()->{
setConnectDisconnectButtonText("Connect");
setConnectDisconnectButtonText("Connect");
MotherConnection.setRemoteController(null);
MotherConnection.setRemoteController(null);
if(onDisconnectRunnable != null)
{
onDisconnectRunnable.run();
onDisconnectRunnable = null;
}
});
});
obsRemoteController.registerConnectCallback(onConnect->{
obsRemoteController.registerConnectCallback(onConnect->{
setConnectDisconnectButtonText("Disconnect");
setConnectDisconnectButtonText("Disconnect");
MotherConnection.setRemoteController(obsRemoteController);
MotherConnection.setRemoteController(obsRemoteController);
if(onConnectRunnable != null)
{
onConnectRunnable.run();
onConnectRunnable = null;
}
});
});
}
}
catch (Exception e)
catch (Exception e)
{
{
new StreamPiAlert("Unable to Connect", "Unable to establish connection to WebSocket with provided crendentials", StreamPiAlertType.ERROR).show();
new StreamPiAlert("Unable to Connect", "Unable to establish connection to WebSocket with provided crendentials", StreamPiAlertType.ERROR).show();
MotherConnection.setRemoteController(null);
MotherConnection.setRemoteController(null);
e.printStackTrace();
e.printStackTrace();
}
}
finally
finally
{
{
setConnectDisconnectButtonDisable(false);
setConnectDisconnectButtonDisable(false);
}
}
return null;
return null;
}
}
private void setConnectDisconnectButtonText(String text)
private void setConnectDisconnectButtonText(String text)
{
{
if(connectDisconnectButton == null)
if(MotherConnection.getConnectDisconnectButton() == null)
return;
return;
Platform.runLater(()-> connectDisconnectButton.setText(text));
Platform.runLater(()-> MotherConnection.getConnectDisconnectButton().setText(text));
}
}
private void setConnectDisconnectButtonDisable(boolean disable)
private void setConnectDisconnectButtonDisable(boolean disable)
{
{
if(connectDisconnectButton == null)
if(MotherConnection.getConnectDisconnectButton() == null)
return;
return;
Platform.runLater(()-> connectDisconnectButton.setDisable(disable));
Platform.runLater(()-> MotherConnection.getConnectDisconnectButton().setDisable(disable));
}
}
}
}
package mother.motherconnection;
package mother.motherconnection;
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.version.Version;
import javafx.scene.control.Button;
import mother.OBSActionConnectionTask;
import mother.OBSActionConnectionTask;
import net.twasi.obsremotejava.OBSRemoteController;
import net.twasi.obsremotejava.OBSRemoteController;
import net.twasi.obsremotejava.callbacks.Callback;
import net.twasi.obsremotejava.callbacks.Callback;
public class MotherConnection
public class MotherConnection
{
{
private static OBSRemoteController obsRemoteController = null;
private static OBSRemoteController obsRemoteController = null;
public static final Version VERSION = new Version(2,0,0);
private static String url = null;
private static String url = null;
private static String pass = null;
private static String pass = null;
private static Button connectDisconnectButton = null;
public static void setConnectDisconnectButton(Button connectDisconnectButton)
{
MotherConnection.connectDisconnectButton = connectDisconnectButton;
}
public static Button getConnectDisconnectButton()
{
return connectDisconnectButton;
}
public static void setUrl(String url) {
public static void setUrl(String url) {
MotherConnection.url = url;
MotherConnection.url = url;
}
}
public static void setPass(String pass) {
public static void setPass(String pass) {
MotherConnection.pass = pass;
MotherConnection.pass = pass;
}
}
public static String getUrl() {
public static String getUrl() {
return url;
return url;
}
}
public static String getPass() {
public static String getPass() {
return pass;
return pass;
}
}
public void connect()
public static void connect()
{
{
connect(true);
connect(true, null, null, null);
}
}
public void connect(boolean runAsync)
public static void connect(Runnable onConnectRunnable)
{
{
new OBSActionConnectionTask( null, runAsync);
connect(true, null, onConnectRunnable, null);
}
}
public static void connect(boolean runAsync, Runnable onFailToConnectRunnable,
Runnable onConnectRunnable, Runnable onDisconnectRunnable)
{
new OBSActionConnectionTask(runAsync, onFailToConnectRunnable,
onConnectRunnable, onDisconnectRunnable);
}
public static OBSRemoteController getRemoteController()
public static OBSRemoteController getRemoteController()
{
{
return obsRemoteController;
return obsRemoteController;
}
}
public static void setRemoteController(OBSRemoteController obsRemoteController)
public static void setRemoteController(OBSRemoteController obsRemoteController)
{
{
MotherConnection.obsRemoteController = obsRemoteController;
MotherConnection.obsRemoteController = obsRemoteController;
}
}
public static Callback getDefaultCallBack(String head, String content)
public static Callback getDefaultCallBack(String head, String content)
{
{
return response ->
return response ->
{
{
if(response.getStatus().equals("error"))
if(response.getStatus().equals("error"))
{
{
new StreamPiAlert(head, content, StreamPiAlertType.ERROR).show();
new StreamPiAlert(head, content, StreamPiAlertType.ERROR).show();
}
}
};
};
}
}
}
}
<?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_setcurrentprofileaction</artifactId>
<artifactId>obssuite_setcurrentprofileaction</artifactId>
<version>1.0.0</version>
<version>2.0.0</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>1.1.0</OBSSuiteMotherVersion>
<OBSSuiteMotherVersion>2.0.0</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 setcurrentprofile;
package setcurrentprofile;
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.NormalAction;
import com.stream_pi.action_api.externalplugin.NormalAction;
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.version.Version;
import com.stream_pi.util.exception.MinorException;
import mother.motherconnection.MotherConnection;
import mother.motherconnection.MotherConnection;
import net.twasi.obsremotejava.OBSRemoteController;
public class SetCurrentProfile extends NormalAction
public class SetCurrentProfile extends NormalAction
{
{
public SetCurrentProfile() {
public SetCurrentProfile() {
setName("Set Current Profile");
setName("Set Current Profile");
setCategory("OBS");
setCategory("OBS");
setVisibilityInServerSettingsPane(false);
setVisibilityInServerSettingsPane(false);
setAuthor("rnayabed");
setAuthor("rnayabed");
setVersion(new Version(1, 0, 0));
setVersion(MotherConnection.VERSION);
}
}
@Override
@Override
public void initProperties() throws Exception {
public void initProperties() throws Exception
// TODO Auto-generated method stub
{
Property currentProfileProperty = new Property("profile", Type.STRING);
Property currentProfileProperty = new Property("current_profile", Type.STRING);
currentProfileProperty.setDisplayName("Profile Name");
currentProfileProperty.setDisplayName("Profile Name");
Property autoConnectProperty = new Property("auto_connect", Type.BOOLEAN);
autoConnectProperty.setDefaultValueBoolean(true);
autoConnectProperty.setDisplayName("Auto Connect if not connected");
addClientProperties(currentProfileProperty);
addClientProperties(currentProfileProperty, autoConnectProperty);
}
}
@Override
@Override
public void initAction() throws Exception {
public void onActionClicked() throws Exception
// TODO Auto-generated method stub
{
}
String profile = getClientProperties().getSingleProperty("profile").getStringValue();
@Override
if(profile.isBlank())
public void onActionClicked() throws Exception {
{
// TODO Auto-generated method stub
throw new MinorException("Blank Profile Name","No Profile Name specified");
}
OBSRemoteController controller = MotherConnection.getRemoteController();
if (MotherConnection.getRemoteController() == null)
if (controller == null) {
{
new StreamPiAlert("Is OBS Connected?",
boolean autoConnect = getClientProperties().getSingleProperty(
"It seems there is no connection to OBS, please connect it in Settings", StreamPiAlertType.WARNING)
"auto_connect"
.show();
).getBoolValue();
} else {
controller.setCurrentProfile(getClientProperties().getSingleProperty("current_profile").getStringValue(), MotherConnection.getDefaultCallBack(
if(autoConnect)
"Unable to Set Current Profile","Failed to set current profile"
{
));
MotherConnection.connect(()->setProfile(profile));
}
else
{
new StreamPiAlert("Is OBS Connected?",
"It seems there is no connection to OBS, please connect it in Settings", StreamPiAlertType.WARNING)
.show();
}
}
else
{
setProfile(profile);
}
}
}
}
@Override
public void setProfile(String profile)
public void onShutDown() throws Exception {
{
// TODO Auto-generated method stub
MotherConnection.getRemoteController().setCurrentProfile(profile, setCurrentProfileResponse -> {
String status = setCurrentProfileResponse.getStatus();
String error = setCurrentProfileResponse.getError();
if(status.equals("error"))
{
String content;
if(error.equals("profile does not exist"))
{
content = "Profile "+profile+" does not exist.";
}
else
{
content = error;
}
new StreamPiAlert("OBS",content, StreamPiAlertType.ERROR).show();
}
});
}
}
}
}