2 * SomePlayer - An alternate music player for Maemo 5
3 * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "tagresolver.h"
25 using namespace SomePlayer::DataObjects;
27 TagResolver::TagResolver(QObject *parent) :
32 void TagResolver::decode(QStringList files) {
33 foreach (QString filename, files) {
34 TagLib::FileRef file_ref(QFile::encodeName(filename).data());
35 if (!file_ref.isNull()) {
36 TagLib::Tag *tag = file_ref.tag();
38 TagLib::AudioProperties *properties = file_ref.audioProperties();
39 if (NULL != properties) {
40 TrackMetadata meta(QString::fromStdWString(tag->title().toWString()),
41 QString::fromStdWString(tag->artist().toWString()),
42 QString::fromStdWString(tag->album().toWString()),
43 properties->length());
44 Track track(0, meta, filename);
53 void TagResolver::updateTags(Track track) {
54 TagLib::FileRef file_ref(QFile::encodeName(track.source()).data());
55 if (!file_ref.isNull()) {
56 TagLib::Tag *tag = file_ref.tag();
58 tag->setArtist(TagLib::String(track.metadata().artist().toStdWString()));
59 tag->setAlbum(TagLib::String(track.metadata().album().toStdWString()));
60 tag->setTitle(TagLib::String(track.metadata().title().toStdWString()));