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

Add active playing stack per zone

parent 2bb1282e
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@ class ContentPlayerViewController extends NVC {
private class MediaPlayerStack(val playerInstance: PlayerInstance) extends StackPane {
private var activePlayers: ListBuffer[PadIndex] = ListBuffer.empty
val mediaViews: mutable.Map[MediaPlayer, MediaView] = new mutable.HashMap[MediaPlayer, MediaView]()
setLayoutX(playerInstance.x)
......@@ -28,6 +29,10 @@ class ContentPlayerViewController extends NVC {
setWidth(playerInstance.width)
setHeight(playerInstance.height)
def addActivePad(padIndex: PadIndex): Unit = activePlayers.addOne(padIndex)
def removeActivePad(padIndex: PadIndex): Unit = activePlayers = activePlayers.filter(element => element != padIndex)
def showMediaPlayer(padIndex: PadIndex, mediaPlayer: MediaPlayer): Unit = {
if (!mediaViews.contains(mediaPlayer)) {
val mediaView = new MediaView(mediaPlayer)
......@@ -54,7 +59,6 @@ class ContentPlayerViewController extends NVC {
override def toString: String = f"MediaPlayerStack: ${getChildren.stream().map(view => f"MediaView: ${view.getUserData}").collect(Collectors.joining(", "))}"
}
private var activePlayers: ListBuffer[PadIndex] = ListBuffer.empty
private val mediaPlayers: ListBuffer[MediaPlayerStack] = ListBuffer.empty
load("view", "PlayerView")
......@@ -120,7 +124,11 @@ class ContentPlayerViewController extends NVC {
})
}
def addActivePadToList(padIndex: PadIndex): Unit = activePlayers.addOne(padIndex)
def addActivePadToList(padIndex: PadIndex, zones: Seq[PlayerInstance]): Unit = mediaPlayers
.filter(mediaPlayer => zones.contains(mediaPlayer.playerInstance))
.foreach(mediaPlayer => mediaPlayer.addActivePad(padIndex))
def removeActivePadFromList(padIndex: PadIndex): Unit = activePlayers = activePlayers.filter(element => element != padIndex)
def removeActivePadFromList(padIndex: PadIndex, zones: Seq[PlayerInstance]): Unit = mediaPlayers
.filter(mediaPlayer => zones.contains(mediaPlayer.playerInstance))
.foreach(mediaPlayer => mediaPlayer.removeActivePad(padIndex))
}
......@@ -93,7 +93,7 @@ class ContentPlayerPadContent(val pad: Pad, val `type`: String) extends PadConte
if (isPause) {
mediaPlayers(currentPlayingMediaIndex).resume()
} else {
ContentPluginMain.playerViewController.addActivePadToList(getPad.getPadIndex)
ContentPluginMain.playerViewController.addActivePadToList(getPad.getPadIndex, getSelectedZones)
getPad.setEof(false)
mediaPlayers.head.play()
......@@ -116,7 +116,7 @@ class ContentPlayerPadContent(val pad: Pad, val `type`: String) extends PadConte
mediaPlayers(currentPlayingMediaIndex).stop()
currentRunningIndexProperty.set(-1)
ContentPluginMain.playerViewController.removeActivePadFromList(getPad.getPadIndex)
ContentPluginMain.playerViewController.removeActivePadFromList(getPad.getPadIndex, getSelectedZones)
val controller = getPad.getController
if (controller != null) {
......@@ -140,7 +140,7 @@ class ContentPlayerPadContent(val pad: Pad, val `type`: String) extends PadConte
return
}
ContentPluginMain.playerViewController.removeActivePadFromList(getPad.getPadIndex)
ContentPluginMain.playerViewController.removeActivePadFromList(getPad.getPadIndex, getSelectedZones)
}
/*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment