Skip to content
Snippets Groups Projects
Commit 39d78b99 authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

Add pad status command to web api

parent f6680270
No related branches found
No related tags found
No related merge requests found
......@@ -159,6 +159,10 @@ public class PlayPadImpl implements PlayPad {
} else {
currentProject = project;
mainViewController.openProject(project);
if (onLoaded != null) {
onLoaded.accept(mainViewController);
}
}
}
......
......@@ -32,7 +32,6 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
......@@ -252,18 +251,13 @@ public class PathMatchDialog extends NVC {
}
}
private Set<Path> searchHistory = new HashSet<>();
private void find(boolean subdirectories) {
// Check Project
Worker.runLater(() -> {
if (!missingMediaPaths.isEmpty()) {
Set<Path> searchFolders = calculateSearchPaths();
searchFolders.stream()
.filter(folder -> !searchHistory.contains(folder))
.forEach(folder -> {
searchHistory.add(folder);
searchFolders.forEach(folder -> {
Logger.info("Search in: " + folder);
this.missingMediaPaths.parallelStream()
.filter(entry -> !entry.isMatched())
......
......@@ -5,7 +5,7 @@ import java.util.concurrent.ConcurrentLinkedQueue
import com.google.gson.{Gson, JsonObject}
import de.thecodelabs.logger.Logger
import de.tobias.playpad.plugin.api.websocket.message.Message
import de.tobias.playpad.plugin.api.websocket.methods.{ProjectCurrentMethod, ProjectListMethod, ProjectOpenMethod}
import de.tobias.playpad.plugin.api.websocket.methods.{PadStatusChangeMethod, ProjectCurrentMethod, ProjectListMethod, ProjectOpenMethod}
import org.eclipse.jetty.websocket.api.Session
import org.eclipse.jetty.websocket.api.annotations._
......@@ -17,7 +17,8 @@ class WebSocketHandler {
private val methods: Map[String, MethodExecutable] = Map(
"project-list" -> new ProjectListMethod,
"project-current" -> new ProjectCurrentMethod,
"project-open" -> new ProjectOpenMethod
"project-open" -> new ProjectOpenMethod,
"pad-status-change" -> new PadStatusChangeMethod
)
@OnWebSocketConnect def connected(session: Session): Unit = {
......@@ -42,7 +43,7 @@ class WebSocketHandler {
}
@OnWebSocketError def onError(session: Session, error: Throwable): Unit = {
Logger.warning(error.getMessage)
Logger.error(error)
}
}
......
package de.tobias.playpad.plugin.api.websocket.methods
import java.util.UUID
import com.google.gson.JsonObject
import de.tobias.playpad.PlayPadPlugin
import de.tobias.playpad.pad.PadStatus
import de.tobias.playpad.plugin.api.websocket.MethodExecutable
import de.tobias.playpad.plugin.api.websocket.message.Message
import javafx.application.Platform
import org.eclipse.jetty.websocket.api.Session
class PadStatusChangeMethod extends MethodExecutable {
override def execute(session: Session, message: Message): JsonObject = {
val padId = UUID.fromString(message.payload.get("pad").getAsString)
val newStatus = PadStatus.valueOf(message.payload.get("status").getAsString)
val currentProject = PlayPadPlugin.getInstance().getCurrentProject
val pad = currentProject.getPad(padId)
Platform.runLater(() => {
newStatus match {
case PadStatus.PLAY => pad.play()
case PadStatus.PAUSE => pad.pause()
case PadStatus.STOP => pad.stop()
case _ =>
}
})
new JsonObject
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment