/*************************************************************************** * Copyright (C) 2009-2012 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ***************************************************************************/ #include #include #include #include #include #include "vorbismetadatamodel.h" #define QStringToTString_qt4(s) TagLib::String(s.toUtf8().constData(), TagLib::String::UTF8) #define TStringToQString_qt4(s) QString::fromUtf8(s.toCString(true)).trimmed() VorbisMetaDataModel::VorbisMetaDataModel(const QString &path, QObject *parent) : MetaDataModel(parent) { m_path = path; m_tags << new VorbisCommentModel(path); } VorbisMetaDataModel::~VorbisMetaDataModel() { while(!m_tags.isEmpty()) delete m_tags.takeFirst(); } QHash VorbisMetaDataModel::audioProperties() { QHash ap; TagLib::Ogg::Vorbis::File f (m_path.toLocal8Bit().constData()); if(f.audioProperties()) { QString text = QString("%1").arg(f.audioProperties()->length()/60); text +=":"+QString("%1").arg(f.audioProperties()->length()%60,2,10,QChar('0')); ap.insert(tr("Length"), text); ap.insert(tr("Sample rate"), QString("%1 " + tr("Hz")).arg(f.audioProperties()->sampleRate())); ap.insert(tr("Channels"), QString("%1").arg(f.audioProperties()->channels())); ap.insert(tr("Bitrate"), QString("%1 " + tr("kbps")).arg(f.audioProperties()->bitrate())); ap.insert(tr("File size"), QString("%1 "+tr("KB")).arg(f.length()/1024)); } return ap; } QList VorbisMetaDataModel::tags() { return m_tags; } QPixmap VorbisMetaDataModel::cover() { TagLib::Ogg::Vorbis::File file(m_path.toLocal8Bit().constData()); TagLib::Ogg::XiphComment *tag = file.tag(); if(!tag) return QPixmap(); TagLib::StringList list = tag->fieldListMap()["METADATA_BLOCK_PICTURE"]; if(list.isEmpty()) return QPixmap(); for(uint i = 0; i < list.size(); ++i) { TagLib::String value = list[i]; QByteArray block = QByteArray::fromBase64(TStringToQString_qt4(value).toAscii()); if(block.size() < 32) continue; qint64 pos = 0; if(readPictureBlockField(block, pos) != 3) //picture type, use front cover only continue; pos += 4; int mimeLength = readPictureBlockField(block, pos); //mime type length pos += 4; pos += mimeLength; //skip mime type int descLength = readPictureBlockField(block, pos); //description length pos += 4; pos += descLength; //skip description pos += 4; //width pos += 4; //height pos += 4; //color depth pos += 4; //the number of colors used int length = readPictureBlockField(block, pos); //picture size pos += 4; QPixmap cover; cov<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> <TS version="2.1" language="pl_PL"> <context> <name>OutputJACKFactory</name> <message> <location filename="../outputjackfactory.cpp" line="30"/> <source>JACK Plugin</source> <translation>Wtyczka JACK</translation> </message> <message> <location filename="../outputjackfactory.cpp" line="53"/> <source>About Jack Output Plugin</source> <translation>O wtyczce wyjściowej Jack</translation> </message> <message> <location filename="../outputjackfactory.cpp" line="54"/> <source>Qmmp Jack Output Plugin</source> <translation>Wtyczka wyjściowa Jack dla Qmmp</translation> </message> <message>