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

#183 - Implement playlist start and end trigger, refactor existing playlist...

#183 - Implement playlist start and end trigger, refactor existing playlist triggers, add localization for new playlist trigger points
parent 85723647
No related branches found
No related tags found
No related merge requests found
......@@ -215,7 +215,10 @@ Trigger.Volume.Name=Lautst\u00E4rke
TriggerPoint.START=Start
TriggerPoint.STOP=Stop
TriggerPoint.EOF=Ende
TriggerPoint.PLAYLIST_NEXT=Playlist Next
TriggerPoint.PLAYLIST_START=Playlist Start
TriggerPoint.PLAYLIST_ITEM_START=Playlist Item Start
TriggerPoint.PLAYLIST_ITEM_END=Playlist Item Ende
TriggerPoint.PLAYLIST_END=Playlist Ende
# Drag and Drop Mode
DnDMode.Replace=Ersetzen
......
......@@ -13,40 +13,35 @@ import javafx.util.Duration;
public class PadTriggerPlaylistListener implements PlaylistListener {
@Override
public void onPlaylistStart(Pad pad) {
handleTrigger(pad, TriggerPoint.PLAYLIST_START);
}
@Override
public void onPlaylistItemStart(Pad pad) {
if (!pad.isIgnoreTrigger()) {
final PadSettings padSettings = pad.getPadSettings();
final Trigger trigger = padSettings.getTriggers().get(TriggerPoint.PLAYLIST_ITEM_START);
executeTrigger(pad, trigger);
} else {
pad.setIgnoreTrigger(false);
}
handleTrigger(pad, TriggerPoint.PLAYLIST_ITEM_START);
}
@Override
public void onPlaylistItemEnd(Pad pad) {
if (!pad.isIgnoreTrigger()) {
final PadSettings padSettings = pad.getPadSettings();
final Trigger trigger = padSettings.getTriggers().get(TriggerPoint.PLAYLIST_ITEM_END);
executeTrigger(pad, trigger);
} else {
pad.setIgnoreTrigger(false);
}
handleTrigger(pad, TriggerPoint.PLAYLIST_ITEM_END);
}
@Override
public void onPlaylistEnd(Pad pad) {
handleTrigger(pad, TriggerPoint.PLAYLIST_END);
}
private void executeTrigger(Pad pad, Trigger trigger) {
IMainViewController mainViewController = PlayPadPlugin.getInstance().getMainViewController();
Profile currentProfile = Profile.currentProfile();
private void handleTrigger(Pad pad, TriggerPoint point) {
if (!pad.isIgnoreTrigger()) {
final PadSettings padSettings = pad.getPadSettings();
final Trigger trigger = padSettings.getTriggers().get(point);
final IMainViewController mainViewController = PlayPadPlugin.getInstance().getMainViewController();
final Profile currentProfile = Profile.currentProfile();
trigger.handle(pad, Duration.ZERO, pad.getProject(), mainViewController, currentProfile);
} else {
pad.setIgnoreTrigger(false);
}
}
}
......@@ -106,11 +106,14 @@ public class Trigger {
public void handle(Pad pad, Duration currentDuration, Project project, IMainViewController mainViewController, Profile currentProfile) {
for (TriggerItem item : items) {
if (triggerPoint == TriggerPoint.START) {
switch (triggerPoint) {
case START:
handleStartPoint(pad, currentDuration, project, mainViewController, currentProfile, item);
} else if (triggerPoint == TriggerPoint.STOP) {
break;
case STOP:
item.performAction(pad, project, mainViewController, currentProfile);
} else if (triggerPoint == TriggerPoint.EOF) {
break;
case EOF:
if (item.getDurationFromPoint() == Duration.ZERO) {
if (pad.isEof()) {
item.performAction(pad, project, mainViewController, currentProfile);
......@@ -118,10 +121,15 @@ public class Trigger {
} else {
handleEndPoint(pad, currentDuration, project, mainViewController, currentProfile, item);
}
} else if (triggerPoint == TriggerPoint.PLAYLIST_ITEM_START) {
break;
case PLAYLIST_START:
case PLAYLIST_ITEM_START:
handleStartPoint(pad, currentDuration, project, mainViewController, currentProfile, item);
} else if (triggerPoint == TriggerPoint.PLAYLIST_ITEM_END) {
break;
case PLAYLIST_ITEM_END:
case PLAYLIST_END:
item.performAction(pad, project, mainViewController, currentProfile);
break;
}
}
}
......
......@@ -38,9 +38,6 @@ class ContentPlayerMediaContainer(val content: ContentPlayerPadContent, private[
content.getPad.setEof(false)
content.currentPlayingMediaIndexProperty().set(content.getMediaContainers.indexOf(this))
content.listeners.forEach(listener => listener.onPlaylistStart(content.pad))
content.listeners.forEach(listener => listener.onPlaylistItemStart(content.pad))
}
def resume(withFadeIn: Boolean): Unit = {
......@@ -56,18 +53,13 @@ class ContentPlayerMediaContainer(val content: ContentPlayerPadContent, private[
val currentIndex = players.indexOf(this)
content.currentPlayingMediaIndexProperty().set(currentIndex)
if (currentIndex + 1 < players.length) {
content.listeners.forEach(listener => listener.onPlaylistItemEnd(content.pad))
if (content.getPad.getStatus == PadStatus.PLAY) {
players(currentIndex + 1).play(false)
content.listeners.forEach(listener => listener.onPlaylistItemStart(content.pad))
}
} else if (content.getPad.getPadSettings.isLoop) {
content.listeners.forEach(listener => listener.onPlaylistItemEnd(content.pad))
if (content.getPad.getStatus == PadStatus.PLAY) {
players.head.play(false)
content.listeners.forEach(listener => listener.onPlaylistItemStart(content.pad))
}
} else {
content.getPad.setStatus(PadStatus.STOP)
......
......@@ -69,6 +69,9 @@ class ContentPlayerPadContent(val pad: Pad, val `type`: String) extends PadConte
}
getPad.setEof(false)
mediaPlayers.head.play(withFadeIn)
listeners.forEach(listener => listener.onPlaylistStart(pad))
listeners.forEach(listener => listener.onPlaylistItemStart(pad))
}
showingLastFrame = false
isPause = false
......@@ -81,7 +84,11 @@ class ContentPlayerPadContent(val pad: Pad, val `type`: String) extends PadConte
}
override def next(): Unit = {
listeners.forEach(listener => listener.onPlaylistItemEnd(pad))
if (pad.getStatus == PadStatus.PLAY) {
mediaPlayers(getCurrentPlayingMediaIndex).next()
listeners.forEach(listener => listener.onPlaylistItemStart(pad))
}
}
override def stop(): Boolean = {
......@@ -91,6 +98,8 @@ class ContentPlayerPadContent(val pad: Pad, val `type`: String) extends PadConte
if (getCurrentPlayingMediaIndex != -1) {
mediaPlayers(getCurrentPlayingMediaIndex).stop()
listeners.forEach(listener => listener.onPlaylistEnd(pad))
if (showingLastFrame && !stopMediaByOtherPlayer) {
ContentPluginMain.playerViewController.clearHold(mediaPlayers(getCurrentPlayingMediaIndex))
}
......@@ -128,7 +137,7 @@ class ContentPlayerPadContent(val pad: Pad, val `type`: String) extends PadConte
// Only automatically go to the next playlist item, if auto next is active or
// the item is the last one (next() go into stop state if no item is left)
if (isAutoNext || noFurtherItemsInPlaylist) {
mediaPlayers(getCurrentPlayingMediaIndex).next()
next()
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment