mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
SoundPlayer: Display title and artist in the window title if available
This commit is contained in:
parent
0563048949
commit
68447d8f39
Notes:
sideshowbarker
2024-07-17 03:59:29 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/68447d8f39 Pull-request: https://github.com/SerenityOS/serenity/pull/17749 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/LucasChollet Reviewed-by: https://github.com/trflynn89 ✅
2 changed files with 13 additions and 1 deletions
|
@ -39,6 +39,7 @@ public:
|
||||||
bool is_playlist(DeprecatedString const& path);
|
bool is_playlist(DeprecatedString const& path);
|
||||||
|
|
||||||
Playlist& playlist() { return m_playlist; }
|
Playlist& playlist() { return m_playlist; }
|
||||||
|
PlaybackManager const& playback_manager() const { return m_playback_manager; }
|
||||||
DeprecatedString const& loaded_filename() const { return m_loaded_filename; }
|
DeprecatedString const& loaded_filename() const { return m_loaded_filename; }
|
||||||
|
|
||||||
PlayState play_state() const { return m_play_state; }
|
PlayState play_state() const { return m_play_state; }
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "BarsVisualizationWidget.h"
|
#include "BarsVisualizationWidget.h"
|
||||||
#include "M3UParser.h"
|
#include "M3UParser.h"
|
||||||
#include "PlaybackManager.h"
|
#include "PlaybackManager.h"
|
||||||
|
#include <AK/DeprecatedString.h>
|
||||||
#include <AK/LexicalPath.h>
|
#include <AK/LexicalPath.h>
|
||||||
#include <AK/SIMD.h>
|
#include <AK/SIMD.h>
|
||||||
#include <LibGUI/Action.h>
|
#include <LibGUI/Action.h>
|
||||||
|
@ -215,7 +216,17 @@ void SoundPlayerWidgetAdvancedView::time_elapsed(int seconds)
|
||||||
void SoundPlayerWidgetAdvancedView::file_name_changed(StringView name)
|
void SoundPlayerWidgetAdvancedView::file_name_changed(StringView name)
|
||||||
{
|
{
|
||||||
m_visualization->start_new_file(name);
|
m_visualization->start_new_file(name);
|
||||||
m_window.set_title(DeprecatedString::formatted("{} - Sound Player", name));
|
DeprecatedString title = name;
|
||||||
|
if (playback_manager().loader()) {
|
||||||
|
auto const& metadata = playback_manager().loader()->metadata();
|
||||||
|
if (auto artists_or_error = metadata.all_artists(" / "_short_string);
|
||||||
|
!artists_or_error.is_error() && artists_or_error.value().has_value() && metadata.title.has_value()) {
|
||||||
|
title = DeprecatedString::formatted("{} – {}", metadata.title.value(), artists_or_error.release_value().release_value());
|
||||||
|
} else if (metadata.title.has_value()) {
|
||||||
|
title = metadata.title.value().to_deprecated_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_window.set_title(DeprecatedString::formatted("{} — Sound Player", title));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundPlayerWidgetAdvancedView::total_samples_changed(int total_samples)
|
void SoundPlayerWidgetAdvancedView::total_samples_changed(int total_samples)
|
||||||
|
|
Loading…
Reference in a new issue