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.0.0</version>
<version>1.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.35.v20201120</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>
module com.stream_pi.obssuite.motheraction
module com.stream_pi.obssuite.motheraction
{
{
requires com.stream_pi.action_api;
requires com.stream_pi.action_api;
requires com.stream_pi.util;
requires com.stream_pi.util;
requires transitive obs.websocket.java;
requires transitive obs.websocket.java;
requires transitive org.eclipse.jetty.client;
requires transitive org.eclipse.jetty.client;
requires transitive org.eclipse.jetty.websocket.api;
requires transitive org.eclipse.jetty.websocket.api;
requires transitive org.eclipse.jetty.http;
requires transitive org.eclipse.jetty.http;
requires transitive org.eclipse.jetty.util;
requires transitive org.eclipse.jetty.util;
requires transitive org.eclipse.jetty.websocket.client;
requires transitive org.eclipse.jetty.websocket.client;
requires transitive org.eclipse.jetty.websocket.common;
requires transitive org.eclipse.jetty.websocket.common;
requires transitive org.eclipse.jetty.io;
requires transitive org.eclipse.jetty.io;
requires transitive com.google.gson;
requires transitive com.google.gson;
exports mother.motherconnection;
exports mother.motherconnection;
provides com.stream_pi.action_api.normalaction.NormalAction with mother.Mother;
provides com.stream_pi.action_api.externalplugin.ExternalPlugin with mother.Mother;
}
}
package mother;
package mother;
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.normalaction.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,0,0));
setVersion(new Version(1,0,0));
connectDisconnectButton = new Button("Connect");
connectDisconnectButton = new Button("Connect");
setButtonBar(connectDisconnectButton);
setServerSettingsButtonBar(connectDisconnectButton);
}
}
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.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 {
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)
{
{
new Thread(
new Thread(
new OBSActionConnectionTask(url, pass, connectDisconnectButton)
new OBSActionConnectionTask(url, pass, connectDisconnectButton)
).start();
).start();
}
}
@Override
@Override
public void onActionClicked() throws Exception {
public void onActionClicked() throws Exception {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
}
}
@Override
@Override
public void onShutDown() throws Exception
public void onShutDown() throws Exception
{
{
if(MotherConnection.getRemoteController() != null)
if(MotherConnection.getRemoteController() != null)
{
{
MotherConnection.getRemoteController().disconnect();
MotherConnection.getRemoteController().disconnect();
}
}
}
}
}
}
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 net.twasi.obsremotejava.OBSRemoteController;
import net.twasi.obsremotejava.OBSRemoteController;
import net.twasi.obsremotejava.callbacks.Callback;
import net.twasi.obsremotejava.callbacks.Callback;
import net.twasi.obsremotejava.requests.ResponseBase;
import net.twasi.obsremotejava.requests.ResponseBase;
public class MotherConnection {
public class MotherConnection
{
private static OBSRemoteController obsRemoteController = null;
private static OBSRemoteController obsRemoteController = null;
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 new Callback() {
return new Callback() {
@Override
@Override
public void run(ResponseBase response) {
public void run(ResponseBase 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();
}
}
}
}
};
};
}
}
}
}
module com.stream_pi.obssuite.setcurrentprofileaction
module com.stream_pi.obssuite.setcurrentprofileaction
{
{
requires com.stream_pi.action_api;
requires com.stream_pi.action_api;
requires com.stream_pi.util;
requires com.stream_pi.util;
requires com.stream_pi.obssuite.motheraction;
requires com.stream_pi.obssuite.motheraction;
provides com.stream_pi.action_api.normalaction.NormalAction with setcurrentprofile.SetCurrentProfile;
provides com.stream_pi.action_api.externalplugin.ExternalPlugin with setcurrentprofile.SetCurrentProfile;
}
}
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.normalaction.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.version.Version;
import mother.motherconnection.MotherConnection;
import mother.motherconnection.MotherConnection;
import net.twasi.obsremotejava.OBSRemoteController;
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(new Version(1, 0, 0));
}
}
@Override
@Override
public void initProperties() throws Exception {
public void initProperties() throws Exception {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
Property currentProfileProperty = new Property("current_profile", Type.STRING);
Property currentProfileProperty = new Property("current_profile", Type.STRING);
currentProfileProperty.setDisplayName("Profile Name");
currentProfileProperty.setDisplayName("Profile Name");
addClientProperties(currentProfileProperty);
addClientProperties(currentProfileProperty);
}
}
@Override
@Override
public void initAction() throws Exception {
public void initAction() throws Exception {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
}
}
@Override
@Override
public void onActionClicked() throws Exception {
public void onActionClicked() throws Exception {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
OBSRemoteController controller = MotherConnection.getRemoteController();
OBSRemoteController controller = MotherConnection.getRemoteController();
if (controller == null) {
if (controller == null) {
new StreamPiAlert("Is OBS Connected?",
new StreamPiAlert("Is OBS Connected?",
"It seems there is no connection to OBS, please connect it in Settings", StreamPiAlertType.WARNING)
"It seems there is no connection to OBS, please connect it in Settings", StreamPiAlertType.WARNING)
.show();
.show();
} else {
} else {
controller.setCurrentProfile(getClientProperties().getSingleProperty("current_profile").getStringValue(), MotherConnection.getDefaultCallBack(
controller.setCurrentProfile(getClientProperties().getSingleProperty("current_profile").getStringValue(), MotherConnection.getDefaultCallBack(
"Unable to Set Current Profile","Failed to set current profile"
"Unable to Set Current Profile","Failed to set current profile"
));
));
}
}
}
}
@Override
@Override
public void onShutDown() throws Exception {
public void onShutDown() throws Exception {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
}
}
}
}
M
playaudioclipaction/src/main/java/com/stream_pi/playaudioclipaction/PlayAudioClipAction.java
+5
−2
package com.stream_pi.playaudioclipaction;
package com.stream_pi.playaudioclipaction;
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.FileExtensionFilter;
import com.stream_pi.action_api.actionproperty.property.FileExtensionFilter;
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.version.Version;
import javafx.application.Platform;
import javafx.application.Platform;
import javafx.scene.media.AudioClip;
import javafx.scene.media.AudioClip;
import java.io.File;
import java.io.File;
public class PlayAudioClipAction extends NormalAction {
public class PlayAudioClipAction extends NormalAction {
public PlayAudioClipAction()
public PlayAudioClipAction()
{
{
setName("Play Audio Clip");
setName("Play Audio Clip");
setCategory("Essentials");
setCategory("Essentials");
setAuthor("rnayabed");
setAuthor("rnayabed");
setServerButtonGraphic("fas-volume-up");
setServerButtonGraphic("fas-volume-up");
setHelpLink("https://github.com/Stream-Pi/EssentialActions");
setHelpLink("https://github.com/Stream-Pi/EssentialActions");
setVersion(new Version(2,0,0));
setVersion(new Version(2,0,0));
}
}
@Override
@Override
public void initProperties() throws Exception
public void initProperties() throws Exception
{
{
Property audioFileLocationProperty = new Property("audio_location", Type.STRING);
Property audioFileLocationProperty = new Property("audio_location", Type.STRING);
audioFileLocationProperty.setControlType(ControlType.FILE_PATH);
audioFileLocationProperty.setControlType(ControlType.FILE_PATH);
audioFileLocationProperty.setDisplayName("Audio File Location");
audioFileLocationProperty.setDisplayName("Audio File Location");
audioFileLocationProperty.setExtensionFilters(
audioFileLocationProperty.setExtensionFilters(
new FileExtensionFilter("MP3","*.mp3"),
new FileExtensionFilter("MP3","*.mp3"),
new FileExtensionFilter("MP4","*.mp4", "*.m4a", "*.m4v"),
new FileExtensionFilter("MP4","*.mp4", "*.m4a", "*.m4v"),
new FileExtensionFilter("WAV","*.wav"),
new FileExtensionFilter("WAV","*.wav"),
new FileExtensionFilter("AIFF","*.aif", "*.aiff"),
new FileExtensionFilter("AIFF","*.aif", "*.aiff"),
new FileExtensionFilter("FXM","*.fxm"),
new FileExtensionFilter("FXM","*.fxm"),
new FileExtensionFilter("FLV","*.flv"),
new FileExtensionFilter("FLV","*.flv"),
new FileExtensionFilter("HLS","*.m3u8")
new FileExtensionFilter("HLS","*.m3u8")
);
);
addClientProperties(audioFileLocationProperty);
addClientProperties(audioFileLocationProperty);
}
}
public AudioClip mediaPlayer = null;
public AudioClip mediaPlayer = null;
public String path = null;
public String path = null;
@Override
@Override
public void onActionClicked() throws Exception
public void onActionClicked() throws Exception
{
{
Property audioFileLocationProperty = getClientProperties().getSingleProperty("audio_location");
Property audioFileLocationProperty = getClientProperties().getSingleProperty("audio_location");
if (audioFileLocationProperty.getStringValue().isBlank())
if (audioFileLocationProperty.getStringValue().isBlank())
{
{
new StreamPiAlert("Media Action", "No file specified", StreamPiAlertType.ERROR).show();
new StreamPiAlert("Media Action", "No file specified", StreamPiAlertType.ERROR).show();
return;
return;
}
}
if(mediaPlayer != null)
if(mediaPlayer != null)
{
{
if(mediaPlayer.isPlaying())
if(mediaPlayer.isPlaying())
{
{
Platform.runLater(mediaPlayer::stop);
Platform.runLater(mediaPlayer::stop);
return;
return;
}
}
}
}
if(!audioFileLocationProperty.getStringValue().equals(path))
if(!audioFileLocationProperty.getStringValue().equals(path))
{
{
path = audioFileLocationProperty.getStringValue();
path = audioFileLocationProperty.getStringValue();
mediaPlayer = new AudioClip(new File(path).toURI().toString());
mediaPlayer = new AudioClip(new File(path).toURI().toString());
}
}
Platform.runLater(mediaPlayer::play);
Platform.runLater(mediaPlayer::play);
}
}
@Override
@Override
public void onShutDown()
public void onShutDown()
{
{
if(mediaPlayer.isPlaying())
if(mediaPlayer != null)
Platform.runLater(mediaPlayer::stop);
{
if(mediaPlayer.isPlaying())
Platform.runLater(mediaPlayer::stop);
}
}
}
}
}