void AudioController::OnSubtitlesSave() { if (IsAudioOpen()) context->ass->SetScriptInfo("Audio URI", config::path->MakeRelative(audio_url, "?script").generic_string()); else context->ass->SetScriptInfo("Audio URI", ""); }
void AudioController::PlayToEndOfPrimary(int start_ms) { if (!IsAudioOpen()) return; PlayRange(TimeRange(start_ms, GetPrimaryPlaybackRange().end())); if (playback_mode == PM_Range) playback_mode = PM_PrimaryRange; }
void AudioController::Stop() { if (!IsAudioOpen()) return; player->Stop(); playback_mode = PM_NotPlaying; playback_timer.Stop(); AnnouncePlaybackStop(); }
void AudioController::PlayRange(const TimeRange &range) { if (!IsAudioOpen()) return; player->Play(SamplesFromMilliseconds(range.begin()), SamplesFromMilliseconds(range.length())); playback_mode = PM_Range; playback_timer.Start(20); AnnouncePlaybackPosition(range.begin()); }
void AudioController::PlayToEnd(int64_t start_sample) { if (!IsAudioOpen()) return; player->Play(start_sample, provider->GetNumSamples()-start_sample); playback_mode = PM_ToEnd; playback_timer.Start(20); AnnouncePlaybackPosition(start_sample); }
void AudioController::OnSubtitlesSave() { if (IsAudioOpen()) { context->ass->SetScriptInfo("Audio URI", MakeRelativePath(audio_url, context->ass->filename)); } else { context->ass->SetScriptInfo("Audio URI", ""); } }
void AudioController::OnAudioPlayerChanged() { if (!IsAudioOpen()) return; Stop(); delete player; try { player = AudioPlayerFactory::GetAudioPlayer(provider); } catch (...) { CloseAudio(); throw; } }
void AudioController::SetVolume(double volume) { if (!IsAudioOpen()) return; player->SetVolume(volume); }
double AudioController::GetVolume() const { if (!IsAudioOpen()) return 1.0; return player->GetVolume(); }
bool AudioController::IsPlaying() { return IsAudioOpen() && playback_mode != PM_NotPlaying; }
void AudioController::OnAudioProviderChanged() { if (IsAudioOpen()) // url is cloned because CloseAudio clears it and OpenAudio takes a const reference OpenAudio(audio_url.Clone()); }