本文整理汇总了C++中taglib::mpeg::File::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ File::isValid方法的具体用法?C++ File::isValid怎么用?C++ File::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taglib::mpeg::File
的用法示例。
在下文中一共展示了File::isValid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strip
void
MetaBundle::readTags( TagLib::AudioProperties::ReadStyle readStyle )
{
if( m_url.protocol() != "file" )
return;
const QString path = m_url.path();
TagLib::FileRef fileref;
TagLib::Tag *tag = 0;
if( AmarokConfig::recodeID3v1Tags() && path.endsWith( ".mp3", false ) )
{
TagLib::MPEG::File *mpeg = new TagLib::MPEG::File( QFile::encodeName( path ), true, readStyle );
fileref = TagLib::FileRef( mpeg );
if( mpeg->isValid() )
// we prefer ID3v1 over ID3v2 if recoding tags because
// apparently this is what people who ignore ID3 standards want
tag = mpeg->ID3v1Tag() ? (TagLib::Tag*)mpeg->ID3v1Tag() : (TagLib::Tag*)mpeg->ID3v2Tag();
}
else {
fileref = TagLib::FileRef( QFile::encodeName( path ), true, readStyle );
if( !fileref.isNull() )
tag = fileref.tag();
}
if( !fileref.isNull() ) {
if ( tag ) {
#define strip( x ) TStringToQString( x ).stripWhiteSpace()
m_title = strip( tag->title() );
m_artist = strip( tag->artist() );
m_album = strip( tag->album() );
m_comment = strip( tag->comment() );
m_genre = strip( tag->genre() );
m_year = tag->year() ? QString::number( tag->year() ) : QString();
m_track = tag->track() ? QString::number( tag->track() ) : QString();
#undef strip
m_isValidMedia = true;
}
init( fileref.audioProperties() );
}
//FIXME disabled for beta4 as it's simpler to not got 100 bug reports
//else if( KMimeType::findByUrl( m_url )->is( "audio" ) )
// init( KFileMetaInfo( m_url, QString::null, KFileMetaInfo::Everything ) );
}
示例2: addImage
bool CTagBase::addImage(wchar_t* s)
{
if (!_tagFile) return false;
TagLib::MPEG::File *pAudioFile = (TagLib::MPEG::File *)_tagFile.get();
CString strFileName = s;
ImageFile imageFile((CW2A)strFileName.GetBuffer());
if (!pAudioFile->isValid() || !imageFile.isValid())
return false;
TagLib::ID3v2::Tag *tag = pAudioFile->ID3v2Tag(true);
TagLib::ID3v2::AttachedPictureFrame *frame = new TagLib::ID3v2::AttachedPictureFrame;
frame->setMimeType(imageFile.mimeType());
frame->setPicture(imageFile.data());
tag->addFrame(frame);
return pAudioFile->save();
}
示例3: malloc
/* LOAD UP THE FILE'S TAG
* Search each file type individually so we can get individual tags for
* custom tagging.
*/
TagDatac * tag_data_load (char *url, int *pvalid)
{
TagData * data;
TagLib::String s = url;
int mtime;
struct stat buf;
if (!stat (url, &buf))
mtime = (int) buf.st_mtime;
/* FIXME: Using filename to find media type. GStreamer probe instead?
*/
if(s.size() > 4) {
if(s.substr(s.size() - 4, 4).upper() == ".OGG")
{
TagLib::Vorbis::File * f = new TagLib::Vorbis::File(url);
if (! f->isValid ())
return NULL;
data = (TagData*) malloc (sizeof (TagData));
data->file = new TagLib::FileRef (f);
data->id3v2 = NULL;
data->id3v1 = NULL;
data->ape = NULL;
data->xiph = f->tag ();
data->mime = "application/ogg";
data->mtime = mtime;
return reinterpret_cast<TagDatac *> (data);
}
if(s.substr(s.size() - 4, 4).upper() == ".MP3")
{
TagLib::MPEG::File * f = new TagLib::MPEG::File(url);
if (! f->isValid ())
return NULL;
data = (TagData*) malloc (sizeof (TagData));
data->file = new TagLib::FileRef (f);
data->id3v2 = f->ID3v2Tag ();
data->id3v1 = f->ID3v1Tag ();
data->ape = f->APETag ();
data->xiph = NULL;
data->mime = "audio/mpeg";
data->mtime = mtime;
return reinterpret_cast<TagDatac *>(data);
}
if(s.substr(s.size() - 5, 5).upper() == ".FLAC")
{
TagLib::FLAC::File * f = new TagLib::FLAC::File(url);
if ((! f->isValid ())&& (pvalid != NULL)){
*pvalid = -1;//paul add on 080827 merge from Olive
return NULL;
}
data = (TagData*) malloc (sizeof (TagData));
data->file = new TagLib::FileRef (f);
data->id3v2 = f->ID3v2Tag ();
data->id3v1 = f->ID3v1Tag ();
data->ape = NULL;
data->xiph = f->xiphComment ();
data->mime = "audio/x-flac";
data->mtime = mtime;
return reinterpret_cast<TagDatac *>(data);
}
if(s.substr(s.size() - 4, 4).upper() == ".MPC" || s.substr(s.size() - 4, 4).upper() == ".AAC")
{
TagLib::MPC::File * f = new TagLib::MPC::File(url);
if (! f->isValid ())
return NULL;
data = (TagData*) malloc (sizeof (TagData));
data->file = new TagLib::FileRef (f);
data->id3v2 = NULL;
data->id3v1 = f->ID3v1Tag ();
data->ape = f->APETag ();
data->xiph = NULL;
data->mime = "audio/x-musepack";
data->mtime = mtime;
return reinterpret_cast<TagDatac *>(data);
}
}
return NULL;
}