public IEnumerable <JRFile> getFiles(JRPlaylist playlist, List <string> fields = null, string filter = null, int start = 0, int step = 1) { IMJPlaylistAutomation pl = jr.GetPlaylistByID(playlist.ID); IMJFilesAutomation files = pl.GetFiles(); if (!string.IsNullOrWhiteSpace(filter)) { files.Filter(filter); } int num = files.GetNumberFiles(); playlist.Count = num; for (int i = start; i < num; i += step) { var file = files.GetFile(i); if (file != null) { yield return(getFieldValues(file, fields)); } else { playlist.Count--; } } }
public int getPLFileCount(int listID, string filter = null) { int count = -1; try { Task t = Task.Run(() => { IMJPlaylistAutomation iList = jr.GetPlaylistByID(listID); IMJFilesAutomation iFiles = iList.GetFiles(); if (!string.IsNullOrEmpty(filter)) { iFiles.Filter(filter); } count = iFiles.GetNumberFiles(); }); if (!t.Wait(1000)) { return(-2); // timeout, slow playlist } } catch { } return(count); }