private void backgroundWorker6_DoWork(object sender, DoWorkEventArgs e) { while (bgw5_done != 2) { System.Threading.Thread.Sleep(10); } TimeSpan lastEndTime = new TimeSpan(); for (int i = 0; i < liedjes.Count; i++) { TimeSpan newEndTime = lastEndTime.Add(liedjes[i].EindTijd - liedjes[i].BeginTijd); MusicEditor.TrimMp3(File.defaultDir + "\\total\\total.mp3", outputDir + "\\" + liedjes[i].Liedje.Titel + ".mp3", lastEndTime, newEndTime); lastEndTime = newEndTime; } }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { //Fragmenten maken uit de liedjes //Map aanmaken string dir = File.defaultDir + "\\ready_for_export"; if (System.IO.Directory.Exists(dir)) { System.IO.Directory.Delete(dir, true); } System.IO.Directory.CreateDirectory(dir); dir = File.defaultDir + "\\trimmed"; if (System.IO.Directory.Exists(dir)) { System.IO.Directory.Delete(dir, true); } System.IO.Directory.CreateDirectory(dir); dir = File.defaultDir + "\\normalized"; if (System.IO.Directory.Exists(dir)) { System.IO.Directory.Delete(dir, true); } System.IO.Directory.CreateDirectory(dir); dir = File.defaultDir + "\\faded"; if (System.IO.Directory.Exists(dir)) { System.IO.Directory.Delete(dir, true); } System.IO.Directory.CreateDirectory(dir); dir = File.defaultDir + "\\total"; if (System.IO.Directory.Exists(dir)) { System.IO.Directory.Delete(dir, true); } System.IO.Directory.CreateDirectory(dir); for (int i = 0; i < liedjes.Count; i++) { if (backgroundWorker1.CancellationPending) { return; } if (!liedjes[i].IsDummy()) { MusicEditor.TrimMp3( liedjes[i].Liedje.WriteToFile(File.defaultDir + "\\ready_for_export\\" + (i + 1).ToString() + ".mp3"), File.defaultDir + "\\trimmed\\" + (i + 1).ToString() + ".mp3", liedjes[i].BeginTijd - new DateTime(2000, 1, 1), liedjes[i].EindTijd - new DateTime(2000, 1, 1) ); } else { errors.Add("Leeg fragment gevonden (geen mp3 bestand gekoppeld)"); backgroundWorker1.ReportProgress(2); } backgroundWorker1.ReportProgress(1); //System.Threading.Thread.Sleep(500); } }