essential-actions
Clone or download
Modified Files
package com.stream_pi.documentopen;
package com.stream_pi.documentopen;
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.exception.MinorException;
import com.stream_pi.util.exception.MinorException;
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 java.io.File;
import java.io.File;
import java.awt.*;
import java.awt.*;
import java.net.URI;
import java.net.URI;
public class DocumentOpen extends NormalAction
public class DocumentOpen extends NormalAction
{
{
public DocumentOpen()
public DocumentOpen()
{
{
setName("Document Open");
setName("Document Open");
setAuthor("quimodotcom");
setAuthor("quimodotcom");
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));
setCategory("Essential Actions");
setCategory("Essentials");
}
}
@Override
@Override
public void initProperties() throws Exception {
public void initProperties() throws Exception {
//Called First
//Called First
Property property1 = new Property("documentopen", Type.STRING);
Property property1 = new Property("documentopen", Type.STRING);
property1.setDefaultValueStr("Document.pdf");
property1.setDefaultValueStr("Document.pdf");
property1.setControlType(ControlType.FILE_PATH);
property1.setControlType(ControlType.FILE_PATH);
property1.setDisplayName("Document File Location");
property1.setDisplayName("Document File Location");
property1.setExtensionFilters(
property1.setExtensionFilters(
new FileExtensionFilter("pdf","*.pdf"),
new FileExtensionFilter("pdf","*.pdf"),
new FileExtensionFilter("docx", "*.docx")
new FileExtensionFilter("docx", "*.docx")
);
);
addClientProperties(
addClientProperties(
property1
property1
);
);
}
}
@Override
@Override
public void initAction() {
public void initAction() {
}
}
public String path = null;
public String path = null;
@Override
@Override
public void onActionClicked() throws Exception
public void onActionClicked() throws Exception
{
{
Property documentloc = getClientProperties().getSingleProperty("documentopen");
Property documentloc = getClientProperties().getSingleProperty("documentopen");
if (documentloc.getStringValue().isBlank())
if (documentloc.getStringValue().isBlank())
{
{
new StreamPiAlert("Document Open Action", "No file specified", StreamPiAlertType.ERROR).show();
new StreamPiAlert("Document Open Action", "No file specified", StreamPiAlertType.ERROR).show();
return;
return;
}
}
File file = new File(documentloc.getStringValue());
File file = new File(documentloc.getStringValue());
//Open PDF file
//Open PDF file
Desktop.getDesktop().open(file);
Desktop.getDesktop().open(file);
}
}
}
}
M
playaudioclipaction/src/main/java/com/stream_pi/playaudioclipaction/PlayAudioClipAction.java
+20
−70
package com.stream_pi.playaudioclipaction;
package com.stream_pi.playaudioclipaction;
import java.util.ArrayList;
import java.util.ArrayList;
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.awt.*;
import java.net.URI;
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));
states = new ArrayList<>();
states.add("Audio Clip");
states.add("Music Clip");
}
}
private ArrayList<String> states;
@Override
@Override
public void initProperties() throws Exception
public void initProperties() throws Exception
{
{
Property audioOrMusic = new Property("selection", Type.LIST);
audioOrMusic.setListValue(states);
audioOrMusic.setDisplayName("Audio Clip or Music Clip");
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(audioOrMusic, 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
{
{
String state = states.get(getClientProperties().getSingleProperty("selection").getSelectedIndex());
if(state.equals("Audio Clip"))
{
audioClipPlay();
}
else if(state.equals("Music Clip"))
{
musicClipPlay();
}
}
@Override
public void onShutDown()
{
shutDown();
}
public void onActionDeleted()
{
shutDown();
}
public void onClientDisconnected()
{
shutDown();
}
private void shutDown()
{
if(mediaPlayer != null)
{
if(mediaPlayer.isPlaying())
Platform.runLater(mediaPlayer::stop);
}
}
public void audioClipPlay() 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);
}
}
public void musicClipPlay() throws Exception
@Override
public void onShutDown()
{
{
shutDown();
}
Property audioFileLocationProperty = getClientProperties().getSingleProperty("audio_location");
public void onActionDeleted()
{
shutDown();
}
if (audioFileLocationProperty.getStringValue().isBlank())
public void onClientDisconnected()
{
{
new StreamPiAlert("Media Action", "No file specified", StreamPiAlertType.ERROR).show();
shutDown();
return;
}
}
if(!audioFileLocationProperty.getStringValue().equals(path))
private void shutDown()
{
if(mediaPlayer != null)
{
{
path = audioFileLocationProperty.getStringValue();
if(mediaPlayer.isPlaying())
Platform.runLater(mediaPlayer::stop);
}
}
File file = new File(path);
Desktop.getDesktop().open(file);
}
}
}
}
module com.stream_pi.playaudioclipaction
module com.stream_pi.playaudioclipaction
{
{
requires com.stream_pi.action_api;
requires com.stream_pi.action_api;
requires com.stream_pi.util;
requires com.stream_pi.util;
requires javafx.media;
requires javafx.media;
requires org.kordamp.ikonli.javafx;
requires org.kordamp.ikonli.javafx;
requires org.kordamp.ikonli.fontawesome5;
requires org.kordamp.ikonli.fontawesome5;
requires java.desktop;
provides com.stream_pi.action_api.externalplugin.ExternalPlugin with com.stream_pi.playaudioclipaction.PlayAudioClipAction;
provides com.stream_pi.action_api.externalplugin.ExternalPlugin with com.stream_pi.playaudioclipaction.PlayAudioClipAction;
}
}