brand new song info screen

This commit is contained in:
unK
2008-09-10 17:25:35 +02:00
parent c80b7e6568
commit cb79ecdb2a
7 changed files with 109 additions and 3 deletions

View File

@@ -20,6 +20,7 @@
#include <algorithm>
#include "helpers.h"
#include "tag_editor.h"
extern MPDConnection *Mpd;
@@ -698,6 +699,40 @@ string DisplaySong(const Song &s, void *s_template)
return result;
}
string GetInfo(Song &s)
{
string result;
# ifdef HAVE_TAGLIB_H
string path_to_file = Config.mpd_music_dir + "/" + s.GetFile();
TagLib::FileRef f(path_to_file.c_str());
if (!f.isNull())
s.SetComment(f.tag()->comment().to8Bit(UNICODE));
# endif // HAVE_TAGLIB_H
result = "[.b][.white]Filename: [/white][.green][/b]" + s.GetShortFilename() + "[/green]\n";
result += "[.b][.white]Directory: [/white][.green][/b]" + s.GetDirectory() + "[/green]\n\n";
result += "[.b][.white]Length: [/white][.green][/b]" + s.GetLength() + "[/green]\n";
# ifdef HAVE_TAGLIB_H
if (!f.isNull())
{
result += "[.b][.white]Bitrate: [/white][.green][/b]" + IntoStr(f.audioProperties()->bitrate()) + " kbps[/green]\n";
result += "[.b][.white]Sample rate: [/white][.green][/b]" + IntoStr(f.audioProperties()->sampleRate()) + " Hz[/green]\n";
result += "[.b][.white]Channels: [/white][.green][/b]" + string(f.audioProperties()->channels() == 1 ? "Mono" : "Stereo") + "[/green]\n";
}
# endif // HAVE_TAGLIB_H
result += "\n[.b]Title:[/b] " + s.GetTitle();
result += "\n[.b]Artist:[/b] " + s.GetArtist();
result += "\n[.b]Album:[/b] " + s.GetAlbum();
result += "\n[.b]Year:[/b] " + s.GetYear();
result += "\n[.b]Track:[/b] " + s.GetTrack();
result += "\n[.b]Genre:[/b] " + s.GetGenre();
result += "\n[.b]Composer:[/b] " + s.GetComposer();
result += "\n[.b]Performer:[/b] " + s.GetPerformer();
result += "\n[.b]Disc:[/b] " + s.GetDisc();
result += "\n[.b]Comment:[/b] " + s.GetComment();
return result;
}
void ShowMessage(const string &message, int delay)
{
if (messages_allowed)