⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qmmp3info.cpp

📁 可以播放MP3,wma等文件格式的播放器
💻 CPP
字号:
/* qmmp3info.cpp * * $Id: qmmp3info.cpp,v 1.8.2.2 2002/09/23 19:26:51 kyllingstad Exp $ * * Apollo sound player: http://www.apolloplayer.org * Copyright(C) 2000-2002 Apollo Team.  See CREDITS file. * * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * * The GNU General Public License is also available online at: * * http://www.gnu.org/copyleft/gpl.html */#ifdef ENABLE_ID3#include "qmmp3info.h"#include "util.h"#include <iostream>#include <stdlib.h>#include <id3/misc_support.h>/*!  \class QmMp3Info qmmp3info.h  \brief Provides functionality to retrieve ID3 fields.*//*!  Creates an MP3 information object to retrieve information from \a filename.*/QmMp3Info::QmMp3Info(	const QString &filename)	: QmSongInfo(),      m_Filename(filename){	m_pTag = new ID3_Tag(m_Filename);    ID3_Tag::Iterator *i = m_pTag->CreateIterator();    ID3_Frame* frame = 0;    const char *tmp;	QString temp;	for (int i=0; i<QmSongInfo::Fields; ++i)		m_Fields[i] = blank();	int len = getMp3LengthInSeconds(filename);	if (len != -1)		m_Fields[Length] = QString::number(len);	// rk: the heuristics could stand improvement:	if (filename.contains("various", false))		m_Fields[MultiArtist] = "1";	    /*    cout << "id3lib version: "         << ID3LIB_MAJOR_VERSION << "."         << ID3LIB_MINOR_VERSION << "."         << ID3LIB_PATCH_VERSION << std::endl;    */	    while ((frame = i->GetNext()))    {		tmp = 0;		        switch(frame->GetID())		{        case ID3FID_ALBUM:			tmp = frame->GetField(ID3FN_TEXT)->GetRawText();			if(tmp)				m_Fields[QmSongInfo::Album] = QString(tmp);			break;			        case ID3FID_TITLE:			tmp = frame->GetField(ID3FN_TEXT)->GetRawText();			if(tmp)				m_Fields[QmSongInfo::Title] = QString(tmp);			break;			        case ID3FID_BAND:			break;			        case ID3FID_LEADARTIST:			tmp = frame->GetField(ID3FN_TEXT)->GetRawText();			if(tmp)				m_Fields[QmSongInfo::Artist] = QString(tmp);			break;		case ID3FID_CONTENTTYPE:			tmp = frame->GetField(ID3FN_TEXT)->GetRawText();			if (*tmp == '(')			{				char* end;				long genre = strtol(tmp+1, &end, 10);				if (genre==LONG_MIN || genre==LONG_MAX || end==(tmp+1))					break;				if (genre>=0 && genre<126)					m_Fields[QmSongInfo::Genre] == genres[genre];				/*! \todo read refinement */			}			else				m_Fields[QmSongInfo::Genre] = QString(tmp);			break;			        case ID3FID_TRACKNUM:  			tmp = frame->GetField(ID3FN_TEXT)->GetRawText(); 			if(tmp)			{				char *end;				long num = strtol(tmp, &end, 10);				if (num!=LONG_MIN && num!=LONG_MAX && end!=tmp)					m_Fields[QmSongInfo::Track] = QString::number(num); 				/*! \todo read refinement and store it in songitem */ 			}			break;        case ID3FID_SONGLEN:            tmp = frame->GetField(ID3FN_TEXT)->GetRawText();			            if(tmp)			{                bool ok;				long len = QString(tmp).toLong(&ok) / 1000;				if(ok)					m_Fields[QmSongInfo::Length] =  QString::number(len);            }            break;		case ID3FID_YEAR:			tmp = frame->GetField(ID3FN_TEXT)->GetRawText();            if(tmp)				m_Fields[QmSongInfo::Year] = QString(tmp);            break;		case ID3FID_COMMENT:			tmp = frame->GetField(ID3FN_TEXT)->GetRawText();			if(tmp)				m_Fields[QmSongInfo::Comment] = QString(tmp);			break;        default:			break;        }    }	    delete i;}QmMp3Info::QmMp3Info(const QmMp3Info &/*other*/)    : QmSongInfo(){}QmMp3Info& QmMp3Info::operator=(const QmMp3Info &/*rhs*/){    return *this;}/*!*/QmMp3Info::~QmMp3Info(){	delete m_pTag;}/*!  \return The value of the field \a f, or blank if the field does not exist. */const QString&QmMp3Info::get(	Field f) const{	return m_Fields[f];}// list from: http://www.id3.org/id3v2.3.0.htmlconst char*QmMp3Info::genres[] ={"Blues","Classic Rock","Country","Dance","Disco","Funk","Grunge","Hip-Hop","Jazz","Metal","New Age","Oldies","Other","Pop","R&B","Rap","Reggae","Rock","Techno","Industrial","Alternative","Ska","Death Metal","Pranks","Soundtrack","Euro-Techno","Ambient","Trip-Hop","Vocal","Jazz+Funk","Fusion","Trance","Classical","Instrumental","Acid","House","Game","Sound Clip","Gospel","Noise","AlternRock","Bass","Soul","Punk","Space","Meditative","Instrumental Pop","Instrumental Rock","Ethnic","Gothic","Darkwave","Techno-Industrial","Electronic","Pop-Folk","Eurodance","Dream","Southern Rock","Comedy","Cult","Gangsta","Top 40","Christian Rap","Pop/Funk","Jungle","Native American","Cabaret","New Wave","Psychadelic","Rave","Showtunes","Trailer","Lo-Fi","Tribal","Acid Punk","Acid Jazz","Polka","Retro","Musical","Rock & Roll","Hard Rock","Folk","Folk-Rock","National Folk","Swing","Fast Fusion","Bebob","Latin","Revival","Celtic","Bluegrass","Avantgarde","Gothic Rock","Progressive Rock","Psychedelic Rock","Symphonic Rock","Slow Rock","Big Band","Chorus","Easy Listening","Acoustic","Humour","Speech","Chanson","Opera","Chamber Music","Sonata","Symphony","Booty Bass","Primus","Porn Groove","Satire","Slow Jam","Club","Tango","Samba","Folklore","Ballad","Power Ballad","Rhythmic Soul","Freestyle","Duet","Punk Rock","Drum Solo","A capella","Euro-House","Dance Hall"};#endif // ENABLE_ID3

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -