essential-actions

Clone or download

Modified Files

Binary files /dev/null and b/playaudioclipaction/.DS_Store differ
--- 'a/playaudioclipaction/PlayAudioClipAction.iml'
+++ /dev/null
@@ -1,26 +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+6" level="project" />
- <orderEntry type="library" name="Maven: org.openjfx:javafx-controls:linux:16-ea+6" level="project" />
- <orderEntry type="library" name="Maven: org.openjfx:javafx-base:16-ea+6" level="project" />
- <orderEntry type="library" name="Maven: org.openjfx:javafx-base:linux:16-ea+6" level="project" />
- <orderEntry type="library" name="Maven: com.stream-pi:action-api:1.0.0-SNAPSHOT" level="project" />
- <orderEntry type="library" name="Maven: org.openjfx:javafx-media:16-ea+6" level="project" />
- <orderEntry type="library" name="Maven: org.openjfx:javafx-media:linux:16-ea+6" level="project" />
- <orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:16-ea+6" level="project" />
- <orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:linux:16-ea+6" level="project" />
- <orderEntry type="library" name="Maven: org.kordamp.ikonli:ikonli-fontawesome5-pack: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-javafx:11.5.0" level="project" />
- </component>
-</module>
\ No newline at end of file
Binary files /dev/null and b/playaudioclipaction/src/.DS_Store differ
Binary files /dev/null and b/playaudioclipaction/src/main/.DS_Store differ
Binary files /dev/null and b/playaudioclipaction/src/main/java/.DS_Store differ
Binary files /dev/null and b/playaudioclipaction/src/main/java/com/.DS_Store differ
Binary files /dev/null and b/playaudioclipaction/src/main/java/com/stream_pi/.DS_Store differ
--- 'a/playaudioclipaction/src/main/java/com/stream_pi/playaudioclipaction/PlayAudioClipAction.java'
+++ b/playaudioclipaction/src/main/java/com/stream_pi/playaudioclipaction/PlayAudioClipAction.java
@@ -2,6 +2,7 @@ package com.stream_pi.playaudioclipactio
import java.util.ArrayList;
+
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.Property;
@@ -14,6 +15,9 @@ import com.stream_pi.util.version.Versio
import javafx.application.Platform;
import javafx.scene.media.AudioClip;
+import java.awt.*;
+import java.net.URI;
+
import java.io.File;
public class PlayAudioClipAction extends NormalAction {
@@ -27,19 +31,19 @@ public class PlayAudioClipAction extends
setHelpLink("https://github.com/Stream-Pi/EssentialActions");
setVersion(new Version(2,0,0));
- loopState = new ArrayList<>();
- loopState.add("No");
- loopState.add("Yes");
+ states = new ArrayList<>();
+ states.add("Audio Clip");
+ states.add("Music Clip");
}
- private ArrayList<String> loopState;
+ private ArrayList<String> states;
@Override
public void initProperties() throws Exception
{
- Property looped = new Property("audio_clip_loop", Type.LIST);
- looped.setListValue(loopState);
- looped.setDisplayName("Clip Looped?");
+ 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);
audioFileLocationProperty.setControlType(ControlType.FILE_PATH);
audioFileLocationProperty.setDisplayName("Audio File Location");
@@ -53,7 +57,7 @@ public class PlayAudioClipAction extends
new FileExtensionFilter("HLS","*.m3u8")
);
- addClientProperties(audioFileLocationProperty, looped);
+ addClientProperties(audioOrMusic, audioFileLocationProperty);
}
public AudioClip mediaPlayer = null;
@@ -62,25 +66,56 @@ public class PlayAudioClipAction extends
@Override
public void onActionClicked() throws Exception
{
- Property audioFileLocationProperty = getClientProperties().getSingleProperty("audio_location");
+ String state = states.get(getClientProperties().getSingleProperty("selection").getSelectedIndex());
- if (audioFileLocationProperty.getStringValue().isBlank())
+ if(state.equals("Audio Clip"))
{
- new StreamPiAlert("Media Action", "No file specified", StreamPiAlertType.ERROR).show();
- return;
+ audioClipPlay();
+ }
+ else if(state.equals("Music Clip"))
+ {
+ musicClipPlay();
}
- String state = loopState.get(getClientProperties().getSingleProperty("audio_clip_looped").getSelectedIndex());
+ }
+
+ @Override
+ public void onShutDown()
+ {
+ shutDown();
+ }
- if(state.equals("Yes"))
+ public void onActionDeleted()
+ {
+ shutDown();
+ }
+
+ public void onClientDisconnected()
+ {
+ shutDown();
+ }
+
+ private void shutDown()
+ {
+ if(mediaPlayer != null)
{
- mediaPlayer.setCycleCount(AudioClip.INDEFINITE);
+ if(mediaPlayer.isPlaying())
+ Platform.runLater(mediaPlayer::stop);
}
- else if(state.equals("No"))
+ }
+
+ public void audioClipPlay() throws Exception
+ {
+
+ Property audioFileLocationProperty = getClientProperties().getSingleProperty("audio_location");
+
+ if (audioFileLocationProperty.getStringValue().isBlank())
{
- mediaPlayer.setCycleCount(0);
+ new StreamPiAlert("Media Action", "No file specified", StreamPiAlertType.ERROR).show();
+ return;
}
+
if(mediaPlayer != null)
{
if(mediaPlayer.isPlaying())
@@ -99,30 +134,25 @@ public class PlayAudioClipAction extends
Platform.runLater(mediaPlayer::play);
}
- @Override
- public void onShutDown()
- {
- shutDown();
- }
- @Override
- public void onActionDeleted()
+ public void musicClipPlay() throws Exception
{
- shutDown();
- }
- @Override
- public void onClientDisconnected()
- {
- shutDown();
- }
+ Property audioFileLocationProperty = getClientProperties().getSingleProperty("audio_location");
- private void shutDown()
- {
- if(mediaPlayer != null)
+ if (audioFileLocationProperty.getStringValue().isBlank())
{
- if(mediaPlayer.isPlaying())
- Platform.runLater(mediaPlayer::stop);
+ new StreamPiAlert("Media Action", "No file specified", StreamPiAlertType.ERROR).show();
+ return;
+ }
+
+ if(!audioFileLocationProperty.getStringValue().equals(path))
+ {
+ path = audioFileLocationProperty.getStringValue();
}
+
+ File file = new File(path);
+
+ Desktop.getDesktop().open(file);
}
--- 'a/playaudioclipaction/src/main/java/module-info.java'
+++ b/playaudioclipaction/src/main/java/module-info.java
@@ -7,5 +7,7 @@ module com.stream_pi.playaudioclipaction
requires org.kordamp.ikonli.javafx;
requires org.kordamp.ikonli.fontawesome5;
+ requires java.desktop;
+
provides com.stream_pi.action_api.externalplugin.ExternalPlugin with com.stream_pi.playaudioclipaction.PlayAudioClipAction;
}
\ No newline at end of file