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

📄 qmm3uformat.cpp

📁 可以播放MP3,wma等文件格式的播放器
💻 CPP
字号:
/* qmm3uformat.cpp * * $Id: qmm3uformat.cpp,v 1.10.2.2 2002/10/11 06:39:03 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 */#include "qmm3uformat.h"#include "qmplaylist.h"#include "qmsongitem.h"#include <qfile.h>#include <qdir.h>#include <qtextstream.h>#include <iostream>/* Disables false warning in Visual Studio about dynamic_cast */#ifdef _WS_WIN_#pragma warning(disable: 4541)#endif/** * @file qmm3uformat.cpp * @brief Saves and reads m3u format playlists *//*!  \class QmM3uFormat qmm3uformat.h  \brief Provides functionality for loading and saving playlists in M3U format.  For XML format, see the QmXmlFormat class.*//*!*/QmM3uFormat::QmM3uFormat(){}/*!*/QmM3uFormat::~QmM3uFormat(){}/*!  Loads the M3U playlist \a filename into \a list.  The \a above argument  specifies the position of where the new items will be placed.  Items  will be placed below \a above.  If \a above is null, the items will appear  at the top of the playlist. */QmPlayListItem*QmM3uFormat::load(	QmPlayList *list,	const QString &filename,	QmPlayListItem *above){	CHECK_PTR(list);    QFile f(filename);    if( f.open(IO_ReadOnly) )	{		QFileInfo fi(f);		QDir::setCurrent(fi.dirPath());        QTextStream t( &f );        QString s;		QmPlayListItem *song = dynamic_cast<QmPlayListItem*>(above);        while ( ! t.eof() )		{            s = t.readLine();						if(QFile::exists(s))				if (song && song->depth())					song = new QmSongItem(reinterpret_cast<QmPlayListItem*>(song->parent()),										  song, s);				else					song = new QmSongItem(list, song, s);        }		return song;    }	else		return 0;}/*!  Saves the playlist \a list to \a filename in M3U format. Note that m3u  is a flat format, to conserve the tree structure use the XML format  through QmXmlFormat.  \sa QmXmlFormat::save(QmPlayList *, const QString &) */voidQmM3uFormat::save(	QmPlayList *list,	const QString &filename){	CHECK_PTR(list);    QFile f(filename);	    if( f.open(IO_WriteOnly) )	{        QTextStream t( &f );		QmSongItem *song = 0;				for(QListViewItemIterator it(list); it.current(); ++it)		{			song = dynamic_cast<QmSongItem*>(it.current());			if(song)                t << song->filePath() << "\n";		}	}}/*!  This function will try to determine if the file \a filename is  a M3U playlist or not.  If \a filename does not exist, the extension will be checked.  If it is  'm3u' or 'pls' (case insensitive), true will be returned.  Otherwise, false.    If \a filename exist, the file will be opened and  the first line read to see  if it is a file that exists.  It could be an M3U playlist even though the file  may not exist, but it's a lot easier to identify the line as a path if the file  actually exists.    \return True if \a filename is estimated to be an M3U playlist,  false otherwise.*/boolQmM3uFormat::isMatch(	const QString &filename){	bool rc = false;    QFile f(filename);	if( ! f.exists())	{		QFileInfo fi( f );		return fi.extension(false).lower() == "m3u" || fi.extension(false).lower() == "pls";	}		    if( f.open(IO_ReadOnly) )	{        QTextStream t( &f );        QString tmp = t.readLine();		if(QFile::exists( t.readLine() ))			rc = true;    }	return rc;}

⌨️ 快捷键说明

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