}
public void addItemToPlaylist(String playlistName, ILibraryItem libraryItem, boolean playFirst, int insertionIndex) {
if (_items.containsKey(playlistName)) {
if (libraryItem != null) {
LibraryAdder adder = new LibraryAdder(playlistName, libraryItem, insertionIndex);
ProgressMonitorDialog dialog = new ProgressMonitorDialog(Display.getDefault().getActiveShell());
try {
dialog.run(true, true, adder);
} catch (InvocationTargetException e) {
Log.getInstance(PlaylistController.class).error(e.getMessage());
} catch (InterruptedException e) {
Log.getInstance(PlaylistController.class).error(e.getMessage());
}
if (playFirst) {
if (adder.getFirstItem() != null) {
Playlist playlist = getPlaylistByName(playlistName);
if (playlist != null) {
AudioItem audioItem = playlist.getAudioItemByPath(((TitleItem) adder.getFirstItem()).getFilePath());
if (audioItem != null) {
playFile(playlistName, audioItem);
}
}
}