| 26 | #include "WaveTrack.h" |
| 27 | |
| 28 | void TransportUtilities::PlayCurrentRegionAndWait( |
| 29 | const CommandContext &context, |
| 30 | bool newDefault, |
| 31 | bool cutpreview) |
| 32 | { |
| 33 | auto &project = context.project; |
| 34 | auto &projectAudioManager = ProjectAudioManager::Get(project); |
| 35 | |
| 36 | const auto &playRegion = ViewInfo::Get(project).playRegion; |
| 37 | double t0 = playRegion.GetStart(); |
| 38 | double t1 = playRegion.GetEnd(); |
| 39 | |
| 40 | projectAudioManager.PlayCurrentRegion(newDefault, cutpreview); |
| 41 | |
| 42 | if (project.mBatchMode > 0 && t0 != t1 && !newDefault) { |
| 43 | wxYieldIfNeeded(); |
| 44 | |
| 45 | /* i18n-hint: This title appears on a dialog that indicates the progress |
| 46 | in doing something.*/ |
| 47 | ProgressDialog progress(XO("Progress"), XO("Playing"), pdlgHideCancelButton); |
| 48 | auto gAudioIO = AudioIO::Get(); |
| 49 | |
| 50 | while (projectAudioManager.Playing()) { |
| 51 | ProgressResult result = progress.Update(gAudioIO->GetStreamTime() - t0, t1 - t0); |
| 52 | if (result != ProgressResult::Success) { |
| 53 | projectAudioManager.Stop(); |
| 54 | if (result != ProgressResult::Stopped) { |
| 55 | context.Error(wxT("Playing interrupted")); |
| 56 | } |
| 57 | break; |
| 58 | } |
| 59 | |
| 60 | using namespace std::chrono; |
| 61 | std::this_thread::sleep_for(100ms); |
| 62 | wxYieldIfNeeded(); |
| 63 | } |
| 64 | |
| 65 | projectAudioManager.Stop(); |
| 66 | wxYieldIfNeeded(); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | void TransportUtilities::PlayPlayRegionAndWait( |
| 71 | const CommandContext &context, |
nothing calls this directly
no test coverage detected