//======================================================================================== // Methods //======================================================================================== /// <summary> /// Adds a new track to this playlist as specified by the given file path. /// </summary> /// <param name="path">The file system path of the track to add.</param> /// <returns> /// A new Track describinging the newly added track or <b>null</b> if the track /// could not be added. /// </returns> public Track AddFile(string path) { var list = playlist as IITUserPlaylist; if (list == null) { return(null); } return(Invoke((Func <Track>) delegate { Track track = null; IITOperationStatus status = list.AddFile(path); while (status.InProgress) { // this is horrible! How could Apple not provide a better way? System.Threading.Thread.Sleep(10); } if ((status.Tracks != null) && (status.Tracks.Count > 0)) { // successfully imported raw file without conversion track = new Track(status.Tracks[1]); } return track; })); }
public static IITOperationStatus Await(this IITOperationStatus operation) { while (operation.InProgress) { Thread.Sleep(100); } return(operation); }
private void button8_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in dataGridView1.SelectedRows) { string x = row.Cells[0].Value.ToString(); IITOperationStatus result = mainLibrary.AddFile(x); } MessageBox.Show("done"); }
static void CheckQueue(object sender, ElapsedEventArgs e) { foreach (string file in myQueue.ToList()) { FileInfo f = new FileInfo(file); f.Refresh(); if (f.LastAccessTime < lastChecked) { myQueue.Dequeue(); Console.WriteLine(@"Trying to add " + file); IITOperationStatus status = ProcessFile(file); if (status != null && !status.InProgress && status.Tracks.Count > 0) { tracksAdded++; Console.WriteLine(@"Added " + status.Tracks[1].Artist + " - " + status.Tracks[1].Name); } } } lastChecked = DateTime.Now; }