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

Reorder players on playlist edit

parent 9687c12d
No related branches found
No related tags found
No related merge requests found
......@@ -127,6 +127,7 @@ public class PlaylistTabViewController extends PadSettingsTabViewController {
final int selectedIndex = mediaPathListView.getSelectionModel().getSelectedIndex();
Collections.swap(pad.getPaths(), selectedIndex, selectedIndex - 1);
mediaPathListView.getSelectionModel().select(selectedIndex - 1);
pad.getContent().reorderMedia();
}
@FXML
......@@ -134,6 +135,7 @@ public class PlaylistTabViewController extends PadSettingsTabViewController {
final int selectedIndex = mediaPathListView.getSelectionModel().getSelectedIndex();
Collections.swap(pad.getPaths(), selectedIndex, selectedIndex + 1);
mediaPathListView.getSelectionModel().select(selectedIndex + 1);
pad.getContent().reorderMedia();
}
@FXML
......
......@@ -64,6 +64,9 @@ public abstract class PadContent {
*/
public abstract void unloadMedia(MediaPath mediaPath);
public void reorderMedia() {
}
public abstract void updateVolume();
@Override
......
......@@ -68,9 +68,11 @@ class ContentPlayerPadContent(val pad: Pad, val `type`: String) extends PadConte
_positionProperty.unbind()
_positionProperty.set(Duration.ZERO)
}
override def toString: String = f"MediaPlayerContainer: $path"
}
private val mediaPlayers: ListBuffer[MediaPlayerContainer] = ListBuffer.empty
private var mediaPlayers: ListBuffer[MediaPlayerContainer] = ListBuffer.empty
private var currentRunningIndex: Int = -1
private val _durationProperty = new SimpleObjectProperty[Duration]
......@@ -219,6 +221,15 @@ class ContentPlayerPadContent(val pad: Pad, val `type`: String) extends PadConte
mediaPlayers.remove(index)
}
override def reorderMedia(): Unit = {
val paths = pad.getPaths
mediaPlayers = mediaPlayers.sortWith((o1, o2) => paths.indexOf(o1.path) < paths.indexOf(o2.path))
}
/*
Volume
*/
override def updateVolume(): Unit = {
val volume = VolumeManager.getInstance.computeVolume(getPad)
mediaPlayers.foreach(player => player.mediaPlayer.setVolume(volume))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment