From: EVNPC <39675973+EVNPC@users.noreply.github.com>
Date: Wed, 14 Apr 2021 00:53:20 +0530
Subject: new changes
---
new changes
---
Binary files /dev/null and b/playaudioclipaction/.DS_Store differ
--- 'a/playaudioclipaction/PlayAudioClipAction.iml'
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ 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 loopState;
+ private ArrayList 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