I want to find the length of a song in seconds so that I can make a playlist with the M3U format, but I don't know how to get that info from the file. I am using id3lib and also Qt.
I've tried:
ID3_Frame* myFrame = myTag.Find(ID3FID_SONGLEN);
ID3_Frame* myFrame = myTag.Find(ID3FID_TIME);
ID3_Frame* myFrame = myTag.Find(ID3FID_SIZE);
but myFrame was NULL. I tried other parameters and worked, like ID3FID_ALBUM
. I really don't know what to try. I didn't find anything in the id3lib API.
I know that Qt can give me that info, but can't I use id3lib?
Later edit: I've read that MediaObject::totalTime()
gives me the time only if the song is played but I want that info, regarding that the songs are played or not; I need this info to write it in a file.
LATER EDIT:
I am trying to use Phonon from Qt for the length, but i receive a lot of errors.
#include <Phonon/MediaSource>
#include <Phonon/MediaObject>
#include <iostream>
#include <Qstring>
/* stuff */
Phonon::MediaObject *mediaObject = new Phonon::MediaObject();
QString fileName("D:/melodie.mp3");
mediaObject->setCurrentSource(fileName);
cout << mediaObject->totalTime() << endl;
I get a lot of unresolved external symbol
main.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall Phonon::MediaObject::MediaObject(class QObject *)" (_imp??0MediaObject@Phonon@@QAE@PAVQObject@@@Z) referenced in function _main
I am using QCreator, my application is simple, just a window that says hello(it works if i don't use Phonon); i just can't make it run; i've allocated static mediaObject, i've made a MediaSource and tried to pass it, but it doesn't work(here it says that can't covert from MediaSource* to MediaSource &). What could be the problem?