summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTill Mayer <till.mayer@web.de>2019-11-05 19:09:31 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-05 19:50:11 +0100
commitac9907ee6142bec11302b3bd5f18674676372f4f (patch)
tree043fad6e0b428864184cbba1f4a4866b1448ce18
parent94a96499453c68c9362a1362203460fbd3d18563 (diff)
downloadserenity-ac9907ee6142bec11302b3bd5f18674676372f4f.zip
SoundPlayer: Changed some small cosmetic things
Renamed "Position" to "Elapsed". "channel/channels" automatically changes now when more than one channel exist. The current file name is now displayed in the window title.
-rw-r--r--Applications/SoundPlayer/SoundPlayerWidget.cpp9
-rw-r--r--Applications/SoundPlayer/SoundPlayerWidget.h3
-rw-r--r--Applications/SoundPlayer/main.cpp2
-rw-r--r--Libraries/LibAudio/AWavLoader.h1
4 files changed, 10 insertions, 5 deletions
diff --git a/Applications/SoundPlayer/SoundPlayerWidget.cpp b/Applications/SoundPlayer/SoundPlayerWidget.cpp
index 83eadd3860..07d0586bb9 100644
--- a/Applications/SoundPlayer/SoundPlayerWidget.cpp
+++ b/Applications/SoundPlayer/SoundPlayerWidget.cpp
@@ -5,9 +5,11 @@
#include <LibGUI/GLabel.h>
#include <LibM/math.h>
-SoundPlayerWidget::SoundPlayerWidget(NonnullRefPtr<AClientConnection> connection, AWavLoader& loader)
+SoundPlayerWidget::SoundPlayerWidget(GWindow& window, NonnullRefPtr<AClientConnection> connection, AWavLoader& loader)
: m_manager(PlaybackManager(connection, loader))
{
+ window.set_title(String::format("SoundPlayer - \"%s\"", loader.file()->filename().characters()));
+
set_fill_with_background_color(true);
set_layout(make<GBoxLayout>(Orientation::Vertical));
layout()->set_margins({ 2, 2, 2, 2 });
@@ -66,9 +68,10 @@ SoundPlayerWidget::SoundPlayerWidget(NonnullRefPtr<AClientConnection> connection
m_status->set_preferred_size(0, 18);
m_status->set_text(String::format(
- "Sample rate %uHz, %u channels, %u bits per sample",
+ "Sample rate %uHz, %u %s, %u bits per sample",
loader.sample_rate(),
loader.num_channels(),
+ (loader.num_channels() == 1) ? "channel" : "channels",
loader.bits_per_sample()));
update_position(0);
@@ -109,7 +112,7 @@ void SoundPlayerWidget::update_position(const int position)
float remaining_seconds = m_manager.total_length() - seconds;
m_elapsed->set_text(String::format(
- "Position:\n%u:%02u.%02u",
+ "Elapsed:\n%u:%02u.%02u",
static_cast<int>(seconds / 60),
static_cast<int>(seconds) % 60,
static_cast<int>(seconds * 100) % 100));
diff --git a/Applications/SoundPlayer/SoundPlayerWidget.h b/Applications/SoundPlayer/SoundPlayerWidget.h
index 65a6dc36e4..caf8eb6b8e 100644
--- a/Applications/SoundPlayer/SoundPlayerWidget.h
+++ b/Applications/SoundPlayer/SoundPlayerWidget.h
@@ -6,6 +6,7 @@
#include <LibGUI/GLabel.h>
#include <LibGUI/GSlider.h>
#include <LibGUI/GWidget.h>
+#include <LibGUI/GWindow.h>
class SoundPlayerWidget final : public GWidget {
C_OBJECT(SoundPlayerWidget)
@@ -13,7 +14,7 @@ public:
virtual ~SoundPlayerWidget() override;
private:
- explicit SoundPlayerWidget(NonnullRefPtr<AClientConnection>, AWavLoader&);
+ explicit SoundPlayerWidget(GWindow&, NonnullRefPtr<AClientConnection>, AWavLoader&);
void update_position(const int position);
void update_ui();
diff --git a/Applications/SoundPlayer/main.cpp b/Applications/SoundPlayer/main.cpp
index 7f925e83af..ae8f5e025f 100644
--- a/Applications/SoundPlayer/main.cpp
+++ b/Applications/SoundPlayer/main.cpp
@@ -52,7 +52,7 @@ int main(int argc, char** argv)
window->set_rect(300, 300, 350, 140);
window->set_icon(GraphicsBitmap::load_from_file("/res/icons/16x16/app-sound-player.png"));
- auto player = SoundPlayerWidget::construct(audio_client, loader);
+ auto player = SoundPlayerWidget::construct(window, audio_client, loader);
window->set_main_widget(player);
window->show();
diff --git a/Libraries/LibAudio/AWavLoader.h b/Libraries/LibAudio/AWavLoader.h
index bd53b2ff15..0b13a5a070 100644
--- a/Libraries/LibAudio/AWavLoader.h
+++ b/Libraries/LibAudio/AWavLoader.h
@@ -30,6 +30,7 @@ public:
u32 sample_rate() const { return m_sample_rate; }
u16 num_channels() const { return m_num_channels; }
u16 bits_per_sample() const { return m_bits_per_sample; }
+ RefPtr<CFile> file() const { return m_file; }
private:
bool parse_header();