Ejemplo n.º 1
0
void Track::readTags()
{
    QByteArray fileName = QFile::encodeName( p->url.toLocalFile() );
    const char * encodedName = fileName.constData();
    TagLib::FileRef fileref = TagLib::FileRef( encodedName, true, TagLib::AudioProperties::Fast);

   if ( !fileref.isNull() )
   {
        if( fileref.tag() )
        {
            TagLib::Tag *tag = fileref.tag();

            p->title   = !tag->title().isNull() ? TStringToQString( tag->title() ).trimmed() : QObject::tr("Unknown");
            p->artist  = !tag->artist().isNull() ? TStringToQString( tag->artist() ).trimmed() : QObject::tr("Unknown");
            p->album   = !tag->album().isNull() ? TStringToQString( tag->album() ).trimmed() : QObject::tr("Unknown");
            p->comment = TStringToQString( tag->comment() ).trimmed();
            p->genre   = !tag->genre().isNull() ? TStringToQString( tag->genre() ).trimmed() : QObject::tr("Unknown");
            p->year    = tag->year() ? QString::number( tag->year() ) : QString::null;
            p->tracknumber   = tag->track() ? QString::number( tag->track() ) : QString::null;
            p->length     = fileref.audioProperties()->length();
            p->counter = 0;
            p->rate = 0;

            //polish up empty tags
            if( p->title == QObject::tr("Unknown") ) {
                QFileInfo fileInfo(p->url.toLocalFile());
                p->title = fileInfo.fileName().replace( '_', ' ' ).replace('.' + fileInfo.suffix(),"") ;
            }
        }
    }

}
Ejemplo n.º 2
0
/**
 * MPEG-4:
 * Video Codecs:
 *    H.264 Baseline: avc1.42E0xx, where xx is the AVC level
 *    H.264 Main: avc1.4D40xx, where xx is the AVC level
 *    H.264 High: avc1.6400xx, where xx is the AVC level
 *    MPEG-4 Visual Simple Profile Level 0: mp4v.20.9
 *    MPEG-4 Visual Advanced Simple Profile Level 0: mp4v.20.240
 * Audio Codecs:
 *    Low-Complexity AAC: mp4a.40.2
 */
void p_mp4_header(TagLib::FileRef f)
{
    TagLib::String title = f.tag()->title();
    TagLib::String artist = f.tag()->artist();
    TagLib::String album = f.tag()->album();
    TagLib::String comment = f.tag()->comment();
    TagLib::String genre = f.tag()->genre();
    TagLib::uint year = f.tag()->year();
    TagLib::uint track = f.tag()->track();
    TagLib::MP4::Properties *prop = (TagLib::MP4::Properties*) f.audioProperties();
    TagLib::MP4::Properties::Codec codec = prop->codec();

    printf("Metadata\n");
    printf("Artist    :  %s\nTitle     :  %s\nAlbum     :  %s\nGenre     :  %s\n",
            artist.toCString(true),
            title.toCString(true),
            album.toCString(true),
            genre.toCString(true));
    printf("Comment   :  %s\nYear      :  %d\nTrack     :  %d\n",
            comment.toCString(true),
            year, track);
    printf("Length    :  %d\nBitrate   :  %d\nS' Rate   :  %d\nChannels  :  %d\n",
            prop->length(),
            prop->bitrate(),
            prop->sampleRate(),
            prop->channels());
    printf("BPS       :  %d\nEncrypted :  %d\nAudio Codec  :  %s\n",
            prop->bitsPerSample(),
            prop->isEncrypted(),
            mp4_codec_str[codec]);
}
Ejemplo n.º 3
0
bool getAudioInfo(const QString& file, qint64* durationMiliSecs, int* bitrate)
{
	TagLib::FileRef ref = Qomp::fileName2TaglibRef(file);
	if(!ref.isNull() && ref.audioProperties()) {
		TagLib::AudioProperties *prop = ref.audioProperties();

		*bitrate = prop->bitrate();
		*durationMiliSecs = prop->length() * 1000;

		return true;
	}

	return false;
}
Ejemplo n.º 4
0
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 ) );
}
Ejemplo n.º 5
0
bool CCover::GetComposer(TagLib::FileRef& fr, std::string& composer)
{
    TagLib::MPEG::File        * mpgfile   = NULL;
    TagLib::Ogg::Vorbis::File * oggfile   = NULL;
    TagLib::FLAC::File        * flacfile  = NULL;
    TagLib::Ogg::XiphComment  * xiph      = NULL;
    TagLib::ID3v2::Tag        * id3v2     = NULL;
#ifdef TAGLIB_HAVE_MP4
    TagLib::MP4::File         * mp4file   = NULL;
    TagLib::MP4::Tag          * mp4       = NULL;
#endif

    if ((oggfile = dynamic_cast<TagLib::Ogg::Vorbis::File*>(fr.file()))) {
        xiph=oggfile->tag();
        //log_debug("ogg");
    } else if ((flacfile = dynamic_cast<TagLib::FLAC::File*>(fr.file()))) {
        xiph=flacfile->xiphComment();
        id3v2=flacfile->ID3v2Tag();
        //log_debug("flac");
    } else if ((mpgfile = dynamic_cast<TagLib::MPEG::File*>(fr.file()))) {
        id3v2=mpgfile->ID3v2Tag();
        //log_debug("mpg");
    }
#ifdef TAGLIB_HAVE_MP4
    else if ((mp4file = dynamic_cast<TagLib::MP4::File*>(fr.file()))) {
        mp4=mp4file->tag();
    }
#endif
#ifndef TAGLIB_HAVE_MP4
    void* mp4 = NULL;
#endif
    //log_debug4("xiph=%p, id3v2=%p, mp4=%p", xiph, id3v2, mp4);

    bool retval = true;
    if (xiph)
        retval = xiph_get_field(xiph, "COMPOSER",composer);
    else if (id3v2)
        retval = id3v2_get_field(id3v2, "TCOM",composer);
#ifdef TAGLIB_HAVE_MP4
    else if (mp4)
        retval = mp4_get_field(mp4file, "\251wrt",composer);
#endif
    else
        retval = false;

    //log_debug2("composer = %s", composer.c_str());

    return retval;
}
Ejemplo n.º 6
0
/*!
* \brief Find the length of the track (in seconds)
*
* \param filename The filename for which we want to find the length.
* \returns An integer (signed!) to represent the length in milliseconds.
*/
int MetaIOTagLib::getTrackLength(const QString &filename)
{
    int milliseconds = 0;
    QByteArray fname = filename.toLocal8Bit();
    TagLib::FileRef *file = new TagLib::FileRef(fname.constData());

    if (file && file->audioProperties())
        milliseconds = file->audioProperties()->length() * 1000;

    // If we didn't get a valid length, add the metadata but show warning.
    if (milliseconds <= 1000)
        LOG(VB_GENERAL, LOG_ERR,
            QString("MetaIOTagLib: Failed to read length "
                    "from '%1'. It may be corrupt.").arg(filename));
    
    return milliseconds;
}
Ejemplo n.º 7
0
/*
** Attempts to extract cover art from audio files.
**
*/
bool CCover::GetEmbedded(const TagLib::FileRef& fr, const std::wstring& target)
{
	bool found = false;

	if (TagLib::MPEG::File* file = dynamic_cast<TagLib::MPEG::File*>(fr.file()))
	{
		if (file->ID3v2Tag())
		{
			found = ExtractID3(file->ID3v2Tag(), target);
		}
		if (!found && file->APETag())
		{
			found = ExtractAPE(file->APETag(), target);
		}
	}
	else if (TagLib::FLAC::File* file = dynamic_cast<TagLib::FLAC::File*>(fr.file()))
	{
		found = ExtractFLAC(file, target);

		if (!found && file->ID3v2Tag())
		{
			found = ExtractID3(file->ID3v2Tag(), target);
		}
	}
	else if (TagLib::ASF::File* file = dynamic_cast<TagLib::ASF::File*>(fr.file()))
	{
		found = ExtractASF(file, target);
	}
	else if (TagLib::APE::File* file = dynamic_cast<TagLib::APE::File*>(fr.file()))
	{
		if (file->APETag())
		{
			found = ExtractAPE(file->APETag(), target);
		}
	}
	else if (TagLib::MPC::File* file = dynamic_cast<TagLib::MPC::File*>(fr.file()))
	{
		if (file->APETag())
		{
			found = ExtractAPE(file->APETag(), target);
		}
	}

	return found;
}
Ejemplo n.º 8
0
Tune* tuneFromFile(const QString& file)
{
	Tune* tune = new Tune(false);
	tune->file = file;

	TagLib::FileRef ref = fileName2TaglibRef(file);
	if(!ref.isNull()) {
		if(ref.tag()) {
			TagLib::Tag* tag = ref.tag();
			tune->artist = safeTagLibString2QString( tag->artist() );
			tune->album = safeTagLibString2QString( tag->album() );
			tune->title = safeTagLibString2QString( tag->title() );
			tune->trackNumber = QString::number( tag->track() );
			tune->genre = safeTagLibString2QString( tag->genre() );
		}

		Qomp::loadCover(tune, ref.file());

		if(ref.audioProperties()) {
			TagLib::AudioProperties *prop = ref.audioProperties();
			tune->duration = Qomp::durationSecondsToString( prop->length() );
			tune->bitRate = QString::number( prop->bitrate() );
		}

		tune->setMetadataResolved(true);
	}

	return tune;
}
Ejemplo n.º 9
0
/*
** Attempts to extract cover art from audio files.
**
*/
bool QCoverArt::GetCover(const TagLib::FileRef& fr)
{
    bool found = false;

    if (TagLib::MPEG::File* file = dynamic_cast<TagLib::MPEG::File*>(fr.file()))
    {
        if (file->ID3v2Tag())
        {
            found = ExtractID3(file->ID3v2Tag());
        }
        if (!found && file->APETag())
        {
            found = ExtractAPE(file->APETag());
        }
    }
    else if (TagLib::ASF::File* file = dynamic_cast<TagLib::ASF::File*>(fr.file()))
    {
        found = ExtractASF(file);
    }
    else if (TagLib::MP4::File* file = dynamic_cast<TagLib::MP4::File*>(fr.file()))
    {
        if (file->tag())
        {
            found = ExtractMP4(file);
        }
    }
    else if (TagLib::FLAC::File* file = dynamic_cast<TagLib::FLAC::File*>(fr.file()))
    {
        found = ExtractFLAC(file);

        if (!found && file->ID3v2Tag())
        {
            found = ExtractID3(file->ID3v2Tag());
        }
    }
    else if (TagLib::APE::File* file = dynamic_cast<TagLib::APE::File*>(fr.file()))
    {
        if (file->APETag())
        {
            found = ExtractAPE(file->APETag());
        }
    }
    else if (TagLib::MPC::File* file = dynamic_cast<TagLib::MPC::File*>(fr.file()))
    {
        if (file->APETag())
        {
            found = ExtractAPE(file->APETag());
        }
    }
    else if (TagLib::WavPack::File* file = dynamic_cast<TagLib::WavPack::File*>(fr.file()))
    {
        if (file->APETag())
        {
            found = ExtractAPE(file->APETag());
        }
    }

    return found;
}
Ejemplo n.º 10
0
void TagWalker::handleMusicFile(const TagLib::FileRef &fr, std::string path) {
    // check whether the file is already in the right place
    // to do that, expand the pattern first and make it a complete filename
    std::string expandedPattern;

    if (this->expandPattern(fr.tag(), expandedPattern)) {

        // put the pieces together - depending what opmode we have
        switch (this->config.getOpMode()) {
            case Configuration::M_REORDER:
                expandedPattern = this->config.getWalkRoot() + expandedPattern;
                expandedPattern.append(this->getBasename(path));
                break;

            case Configuration::M_RENAME:
                expandedPattern = this->getPathname(path) + std::string("/") + expandedPattern;
                expandedPattern.append(this->getSuffix(path));
                break;
        }

        // only act if the two directories differ
        if ( path != expandedPattern ) {

            // now decide which opmode we have and what we should do
            // in rename mode only the file itself is altered,
            // so creating a directory is unnecessary
            switch (this->config.getOpMode()) {
            case Configuration::M_REORDER:
                this->RecursivelyMkdir(expandedPattern);
                this->forkAndMove(path, expandedPattern);
                break;

            case Configuration::M_RENAME:
                this->forkAndMove(path, expandedPattern);
                break;
            }
        }
    } else {
        ++this->unableToHandleCount;
    }
}
Ejemplo n.º 11
0
BlockResult Block::eval(const TagLib::FileRef& file)
{
    TagLib::PropertyMap metadata = file.tag()->properties();
    TagLib::StringList list;
    std::stringstream ss;
    // TODO: Needs to be refactored
    // TODO: Add more
    ss << file.audioProperties()->length();
    list.append(ss.str());
    metadata.insert("length", list);
    list.clear();
    ss.clear();

    ss << file.audioProperties()->bitrate();
    list.append(ss.str());
    metadata.insert("bitrate", list);
    list.clear();
    ss.clear();

    if (file.audioProperties()->channels() == 1) {
        list.append("mono");
    } else if (file.audioProperties()->channels() == 2) {
        list.append("stereo");
    } //TODO: Add more channels names

    metadata.insert("channels", list);
    list.clear();
    ss.clear();

    ss << file.audioProperties()->sampleRate();
    list.append(ss.str());
    metadata.insert("samplerate", list);
    list.clear();
    ss.clear();

    list.append(file.file()->name());
    metadata.insert("filename", list);
    list.clear();
    ss.clear();

    return this->eval(metadata);
}
Ejemplo n.º 12
0
// Use Taglib to parse tags from file and add entried to wxListCtrl
void AddFromFile_Taglib(wxListCtrl *listctrl, const std::map< wxString, long > &mapping, const wxString &filename)
{
    TagLib::FileRef f = TagLib::FileRef(filename.c_str(), TagLib::String::UTF8 ); //TODO: is c_str() safe?

    if ( f.isNull() )
    {
        wxLogError(wxT("Error: TagLib could not read ") + filename + wxT("."));
        return;
    }

    if ( ! f.tag() )
    {
        wxLogError(wxT("Error: TagLib could not read the tags of file ") + filename + wxT("."));
        return;
    }

    TagLib::Tag *tag = f.tag();
    auto idx = listctrl->GetItemCount();
    auto row_idx = listctrl->InsertItem(idx, wxString::Format(wxT("%d"), idx) );

    // TODO: check return values
    listctrl->SetItem(row_idx, mapping.find("Artist")->second, wxString(tag->artist().to8Bit(true)) );
    listctrl->SetItem(row_idx, mapping.find("Trackname")->second, wxString(tag->title().to8Bit(true)));
    listctrl->SetItem(row_idx, mapping.find("Album")->second, wxString(tag->album().to8Bit(true)));

    if ( f.audioProperties() )
    {
      TagLib::AudioProperties *properties = f.audioProperties();
      int seconds = properties->length() % 60;
      int minutes = (properties->length() - seconds) / 60;

      wxString timestr = wxString::Format("%d:%02d", minutes, seconds);

      listctrl->SetItem(row_idx, mapping.find("Time")->second, timestr);
    }

}
Ejemplo n.º 13
0
void ReplaceDialog::replace(){

    QProgressDialog p("Replacing tags...", "Cancel", 0, items_.size(), 0);
    p.setWindowModality(Qt::WindowModal);
    Qt::CaseSensitivity case_sens = Qt::CaseInsensitive;
    if(CaseSensitive->isChecked()){
        case_sens = Qt::CaseSensitive;
    }
    QString log; int nReplaced=0;
    TagLib::FileRef f; QString before;
    for(int i=0;i<items_.size();i++){

        p.setValue(i);
        if( p.wasCanceled() ){
            break;
        }

        f = TagLib::FileRef( items_[i]->fileInfo().absoluteFilePath().toStdString().c_str() );
        if( f.tag() ){
            QString field = TagComboBox->currentText().toLower();
            QString tagtxt;
            if( field=="artist" ){
                tagtxt = f.tag()->artist().toCString(); before=tagtxt;
                tagtxt.replace( Before->text(), After->text(), case_sens );
                if(before!=tagtxt){
                    nReplaced++;
                }
                f.tag()->setArtist( tagtxt.toStdString().c_str() );
            }else if(field=="album"){
                tagtxt = f.tag()->album().toCString(); before=tagtxt;
                tagtxt.replace( Before->text(), After->text(), case_sens );
                if(before!=tagtxt){
                    nReplaced++;
                }
                f.tag()->setAlbum( tagtxt.toStdString().c_str() );
            }else if(field=="title"){
                tagtxt = f.tag()->title().toCString(); before=tagtxt;
                tagtxt.replace( Before->text(), After->text(), case_sens );
                if(before!=tagtxt){
                    nReplaced++;
                }
                f.tag()->setTitle( tagtxt.toStdString().c_str() );
            }else if(field=="genre"){
                tagtxt = f.tag()->genre().toCString(); before=tagtxt;
                tagtxt.replace( Before->text(), After->text(), case_sens );
                if(before!=tagtxt){
                    nReplaced++;
                }
                f.tag()->setGenre( tagtxt.toStdString().c_str() );
            }else if(field=="comment"){
                tagtxt = f.tag()->comment().toCString(); before=tagtxt;
                tagtxt.replace( Before->text(), After->text(), case_sens );
                if(before!=tagtxt){
                    nReplaced++;
                }
                f.tag()->setComment( tagtxt.toStdString().c_str() );
            }else if(field=="track"){
                tagtxt = QString::number(f.tag()->track()); before=tagtxt;
                tagtxt.replace( Before->text(), After->text(), case_sens );
                bool ok; int tmp=tagtxt.toInt(&ok);
                if(ok){
                    if(before!=tagtxt){
                        nReplaced++;
                    }
                    f.tag()->setTrack( tmp );
                }else{
                    log.append("\nInvalid value for "+field+": "+tagtxt+". "+field+" must be uint");
                }
            }else if(field=="year"){
                tagtxt = QString::number(f.tag()->year()); before=tagtxt;
                tagtxt.replace( Before->text(), After->text(), case_sens );
                bool ok; int tmp=tagtxt.toInt(&ok);
                if(ok){
                    if(before!=tagtxt){
                        nReplaced++;
                    }
                    f.tag()->setYear( tmp );
                }else{
                    log.append("\nInvalid value for "+field+": "+tagtxt+". "+field+" must be uint");
                }
            }
            f.save();
            items_[i]->clearTags();
            items_[i]->readTags();
        }else{
            log.append("\n Could not get tag for "+items_[i]->fileInfo().absoluteFilePath());
        }

    }
    log.append("\n\nReplaced "+Before->text()+" with "+After->text()+" in "+QString::number(nReplaced)+" tags");
    p.setValue(items_.size());
    TextViewer t(log);
    t.exec();

    accept();
}
Ejemplo n.º 14
0
void MediaInfo::readInfo(TagLib::FileRef f) {
    bitrate = f.audioProperties() -> bitrate();
    channels = f.audioProperties() -> channels();
    duration = f.audioProperties() -> length();
    sampleRate = f.audioProperties() -> sampleRate();
}
Ejemplo n.º 15
0
    foreach(QString filepath, files)
    {
        TagLib::FileRef f(reinterpret_cast<filestr*>(filepath.constData()));
        TagLib::AudioProperties* props = f.audioProperties();
        duration += props->lengthInSeconds();

        QString filename = filepath.split("/").last();
        filename.remove(QRegExp("\\.(mp3|flac|m4a)"));
        filenames += filename + "\n";
    }
    ui->lengthLine->setText(QTime(duration / 3600, (duration % 3600) / 60, ((duration % 3600) % 60)).toString("hh:mm:ss"));
    filenames.remove(QRegExp("\n$"));
    ui->tracklistText->setPlainText(filenames);

    QString tagfile = files.first();
    TagLib::FileRef f(reinterpret_cast<filestr*>(tagfile.constData()));
    QString artist = f.tag()->artist().toCString(true);
    QString album  = f.tag()->album() .toCString(true);
    uint    year   = f.tag()->year();
    QString genre  = f.tag()->genre() .toCString(true);

    ui->artistLine ->setText(artist);
    ui->albumLine  ->setText(album);
    ui->yearSpinBox->setValue(year);

    QStringList genres = genre.split(" / ");
    if(genres.count() > 1)
    {
        int num = genres.count();
        for (int i = 1; i <= num; i++)
        {
Ejemplo n.º 16
0
Meta::ReplayGainTagMap
Meta::readReplayGainTags( const TagLib::FileRef &fileref )
{
    Meta::ReplayGainTagMap map;
    // NB: we can't get replay gain info from MPC files, since it's stored in some magic place
    //     and not in the APE tags, and taglib doesn't let us access the information (unless
    //     we want to parse the file ourselves).
    // FIXME: should we try getting the info from the MPC APE tag just in case?

    if ( TagLib::MPEG::File *file = dynamic_cast<TagLib::MPEG::File *>( fileref.file() ) )
    {
        if ( file->ID3v2Tag() )
            map = readID3v2Tags( file->ID3v2Tag() );
        if ( map.isEmpty() && file->APETag() )
            map = readAPETags( file->APETag() );
    }
    else if ( TagLib::Ogg::Vorbis::File *file = dynamic_cast<TagLib::Ogg::Vorbis::File *>( fileref.file() ) )
    {
        if ( file->tag() )
            map = readXiphTags( file->tag() );
    }
    else if ( TagLib::FLAC::File *file = dynamic_cast<TagLib::FLAC::File *>( fileref.file() ) )
    {
        if ( file->xiphComment() )
            map = readXiphTags( file->xiphComment() );
        if ( map.isEmpty() && file->ID3v2Tag() )
            map = readID3v2Tags( file->ID3v2Tag() );
    }
    else if ( TagLib::Ogg::FLAC::File *file = dynamic_cast<TagLib::Ogg::FLAC::File *>( fileref.file() ) )
    {
        if ( file->tag() )
            map = readXiphTags( file->tag() );
    }
    else if ( TagLib::WavPack::File *file = dynamic_cast<TagLib::WavPack::File *>( fileref.file() ) )
    {
        if ( file->APETag() )
            map = readAPETags( file->APETag() );
    }
    else if ( TagLib::TrueAudio::File *file = dynamic_cast<TagLib::TrueAudio::File *>( fileref.file() ) )
    {
        if ( file->ID3v2Tag() )
            map = readID3v2Tags( file->ID3v2Tag() );
    }
    else if ( TagLib::Ogg::Speex::File *file = dynamic_cast<TagLib::Ogg::Speex::File *>( fileref.file() ) )
    {
        if ( file->tag() )
            map = readXiphTags( file->tag() );
    }
    else if ( TagLib::MPC::File *file = dynamic_cast<TagLib::MPC::File *>( fileref.file() ) )
    {
        // This is NOT the correct way to get replay gain tags from MPC files, but
        // taglib doesn't allow us access to the real information.
        // This allows people to work around this issue by copying their replay gain
        // information to the APE tag.
        if ( file->APETag() )
            map = readAPETags( file->APETag() );
    }
    else if ( TagLib::ASF::File *file = dynamic_cast<TagLib::ASF::File *>( fileref.file() ) )
    {
        if ( file->tag() )
            map = readASFTags( file->tag() );
    }
// See comment above
#ifdef DO_NOT_USE_THIS_UNTIL_FIXED
    else if ( TagLib::MP4::File *file = dynamic_cast<TagLib::MP4::File *>( fileref.file() ) )
    {
        if ( file->tag() )
            map = readMP4Tags( file->getMP4Tag() );
    }
#endif
    return map;
}
Ejemplo n.º 17
0
int main(int argc,char *argv[])
{
	/*g_Indexer.BuildIndex();

	g_Indexer.SetCallback(FinishIndex);

	while (1)
	{
		WormSleep(300);
	}*/

	if (Init()) return 0;

	g_Indexer.SetCallback(FinishIndex, AddToIndex);

	if(REGISTER_WITH_DEVICE) return 0;

	ReportError("In Build Index");

	ReportError("Past Build Index");

	// Inits the music part of the program.
	g_MusController.Init(StartSong, FinishSeek);

	ReportError("About to start the music controller");

	g_MusController.Start();

	ReportError("Made it past the init stuff");

	WormIndexer::READY = 1;

#ifndef ON_DEVICE

	g_MusController.PassMessage(MUS_MESSAGE_ATTRIB_SET,
								ATTRIB_MUSCON_PAUSED,
								MUS_PLAY_CONST,
								0);

	ReportError("Made it past open");

	g_MusController.PassMessage(MUS_MESSAGE_OPEN_SONG, "c:/aobdt.mp3", 0);

	TagLib::FileRef *f =
					new TagLib::FileRef("c:/Users/Katiebird/amazing_grace.ogg");

	fprintf(stderr, "Please Work!!!!! - %s\n", f->tag()->artist().toCString());
	fprintf(stderr, "Please Work!!!!! - %s\n", f->tag()->album().toCString());
	fprintf(stderr, "Please Work!!!!! - %s\n", f->tag()->title().toCString());
	fprintf(stderr, "Please Work!!!!! - %u\n", f->tag()->year());
	fprintf(stderr, "Please Work!!!!! - %s\n", f->tag()->comment().toCString());
	fprintf(stderr, "Please Work!!!!! - %u\n", f->tag()->track());
	fprintf(stderr, "Please Work!!!!! - %s\n", f->tag()->genre().toCString());

	delete f;

	//g_MusController.PassMessage(MUS_MESSAGE_OPEN_SONG, "c:/amazing_grace.ogg", 0);
	//g_MusController.PassMessage(MUS_MESSAGE_OPEN_SONG, "c:/test1.mp3", 0);

	g_MusController.PassMessage(MUS_MESSAGE_SET_NEXT, "c:/amazing_grace.ogg", -10.0, 0);

	//g_MusController.PassMessage(MUS_MESSAGE_SET_NEXT, "c:/test2.mp3", -10.0, 0);

	ReportError("Made it past SetNext");

	// this keeps track of how long the user has waited for
	//	the buffering
	uint32_t uiCurWaitTime;

	uiCurWaitTime = 0;

	// routine to stop for a set time
	/*WormMarkStartTime();
	while (uiCurWaitTime < 10) // check wait time
	{
		uiCurWaitTime = WormCheckTimeSinceMark();
		WormSleep(100);
	}

	g_MusController.PassMessage(MUS_MESSAGE_SEEK,
									100.0);*/


	while (g_iContinue)
	{
		WormSleep(1800);
		//ReportError1("BPM:%s", g_MusController.PassMessage(MUS_MESSAGE_GET_BPM, 0));
		//ReportError1("CurTime:%s", g_MusController.PassMessage(MUS_MESSAGE_GET_SONG_CUR, 0));
		/*const char *cstrRet = g_MusController.PassMessage(MUS_MESSAGE_GET_MAG_STR, 0);
		for (int i=0; i<256; i++)
		{
			fprintf(ERROUT,"%i|", cstrRet[i]);
		}
		fprintf(ERROUT, "\n");*/
	}

#else
	while (1)
	{
		WormSleep(10000);
	}
#endif


	Quit();
	return 0;
}