/** * If any of these streams are already in this playlist, they will be removed before being added * in their new position */ public void addStreams(List<String> streamIds, int position) { if (!canEdit) throw new SeekInnerCalmException(); updateLock.lock(); try { // Rather than buggering about inside our eventlist, we re-order the playlist and then just // re-add the whole // list again // First, scan through our playlist and remove any that are in this // list (they're being moved) for (Iterator<String> iter = p.getStreamIds().iterator(); iter.hasNext(); ) { String pStreamId = iter.next(); if (streamIds.contains(pStreamId)) iter.remove(); } if (position > p.getStreamIds().size()) position = p.getStreamIds().size(); // Put the new streams in the right spot p.getStreamIds().addAll(position, streamIds); // Now regenerate our tracks regenEventList(); } finally { updateLock.unlock(); } runPlaylistUpdate(); }