Clone wiki

libtaginfo / SampleCode

Below you can find sample code for libtaginfo for C++, C and vala.

C++:

#include "taginfo.h"
#include <stdio.h>
#include <iostream>

using namespace TagInfo;

int main( void ) {
    Info * info;

    //READING
    info = Info::create_tag_info(target);
    if( info ) {
        if( info->read() ) {
            std::cout << "title: " << info->get_title() << std::endl;
        }
        delete info;
    }
}

Vala

using TagInfo;

void main() {
    var info = Info.factory_make("path/to/file.ogg");
    //READING
    if(info.read()) {
        print("title: %s\n", info.title);
    }
}
// compile with valac --pkg libtaginfo_c tagreader.vala

C

#include <stdio.h>
#include <taginfo_c.h>

int main(void) {
    TagInfo_Info *info;

    info = taginfo_info_factory_make("./path/to/file.mp3");

    if(info == NULL)
      return 1;

    //READING
    if(taginfo_info_read(info)) {
      char* name = taginfo_info_get_title(info);
      printf("-- TAG --%s\n", name);
      free(name);
    }
    else {
      printf("-- ERROR --\n");
    }

    taginfo_free(info);
    return 0;
}

Updated