mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 16:35:08 +00:00
SoundPlayer: Use new format functions.
This commit is contained in:
parent
97660ad46c
commit
30ca17e78f
2 changed files with 9 additions and 13 deletions
|
@ -165,7 +165,7 @@ void PlaybackManager::next_buffer()
|
||||||
remove_dead_buffers();
|
remove_dead_buffers();
|
||||||
if (!m_next_buffer) {
|
if (!m_next_buffer) {
|
||||||
if (!m_connection->get_remaining_samples() && !m_paused) {
|
if (!m_connection->get_remaining_samples() && !m_paused) {
|
||||||
dbg() << "Exhausted samples :^)";
|
dbgln("Exhausted samples :^)");
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,10 +127,7 @@ void SoundPlayerWidget::open_file(String path)
|
||||||
OwnPtr<Audio::WavLoader> loader = make<Audio::WavLoader>(path);
|
OwnPtr<Audio::WavLoader> loader = make<Audio::WavLoader>(path);
|
||||||
if (loader->has_error()) {
|
if (loader->has_error()) {
|
||||||
GUI::MessageBox::show(window(),
|
GUI::MessageBox::show(window(),
|
||||||
String::format(
|
String::formatted("Failed to load WAV file: {} ({})", path, loader->error_string()),
|
||||||
"Failed to load WAV file: %s (%s)",
|
|
||||||
path.characters(),
|
|
||||||
loader->error_string()),
|
|
||||||
"Filetype error", GUI::MessageBox::Type::Error);
|
"Filetype error", GUI::MessageBox::Type::Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -142,12 +139,11 @@ void SoundPlayerWidget::open_file(String path)
|
||||||
m_play->set_enabled(true);
|
m_play->set_enabled(true);
|
||||||
m_stop->set_enabled(true);
|
m_stop->set_enabled(true);
|
||||||
|
|
||||||
m_window.set_title(String::format("%s - SoundPlayer", loader->file()->filename().characters()));
|
m_window.set_title(String::formatted("{} - SoundPlayer", loader->file()->filename()));
|
||||||
m_status->set_text(String::format(
|
m_status->set_text(String::formatted(
|
||||||
"Sample rate %uHz, %u %s, %u bits per sample",
|
"Sample rate {}Hz, {} channel(s), {} bits per sample",
|
||||||
loader->sample_rate(),
|
loader->sample_rate(),
|
||||||
loader->num_channels(),
|
loader->num_channels(),
|
||||||
(loader->num_channels() == 1) ? "channel" : "channels",
|
|
||||||
loader->bits_per_sample()));
|
loader->bits_per_sample()));
|
||||||
|
|
||||||
m_manager.set_loader(move(loader));
|
m_manager.set_loader(move(loader));
|
||||||
|
@ -177,14 +173,14 @@ void SoundPlayerWidget::update_position(const int position)
|
||||||
float seconds = (total_norm_samples / static_cast<float>(PLAYBACK_MANAGER_RATE));
|
float seconds = (total_norm_samples / static_cast<float>(PLAYBACK_MANAGER_RATE));
|
||||||
float remaining_seconds = m_manager.total_length() - seconds;
|
float remaining_seconds = m_manager.total_length() - seconds;
|
||||||
|
|
||||||
m_elapsed->set_text(String::format(
|
m_elapsed->set_text(String::formatted(
|
||||||
"Elapsed:\n%u:%02u.%02u",
|
"Elapsed:\n{}:{:02}.{:02}",
|
||||||
static_cast<int>(seconds / 60),
|
static_cast<int>(seconds / 60),
|
||||||
static_cast<int>(seconds) % 60,
|
static_cast<int>(seconds) % 60,
|
||||||
static_cast<int>(seconds * 100) % 100));
|
static_cast<int>(seconds * 100) % 100));
|
||||||
|
|
||||||
m_remaining->set_text(String::format(
|
m_remaining->set_text(String::formatted(
|
||||||
"Remaining:\n%u:%02u.%02u",
|
"Remaining:\n{}:{:02}.{:02}",
|
||||||
static_cast<int>(remaining_seconds / 60),
|
static_cast<int>(remaining_seconds / 60),
|
||||||
static_cast<int>(remaining_seconds) % 60,
|
static_cast<int>(remaining_seconds) % 60,
|
||||||
static_cast<int>(remaining_seconds * 100) % 100));
|
static_cast<int>(remaining_seconds * 100) % 100));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue