tom989
6th January 2013, 23:35
I'm trying to join two or more files together.
For each new file to add I call this function:
void MainWindow::mergemp3(QString fname) //fname is the new file to add
{
QFile mp3name (fname);
mp3name.open(QIODevice::ReadOnly);
QByteArray temp= mp3name.readAll();
mergedaudio +=temp; //mergedaudio is a global qbytearray which is the resulting joined up file
}
Then I write out the merged file:
QFile test("testout.mp3");
test.open(QIODevice::WriteOnly);
QDataStream writetest(&test);
writetest<< mergedaudio;
The resulting file (mp3) doesn't play correctly. I know this can be done as I used standard c++ to do it.
Any idea what I've done wrong?
Added after 5 minutes:
Oops. Was using the << which is for formatted data.
For each new file to add I call this function:
void MainWindow::mergemp3(QString fname) //fname is the new file to add
{
QFile mp3name (fname);
mp3name.open(QIODevice::ReadOnly);
QByteArray temp= mp3name.readAll();
mergedaudio +=temp; //mergedaudio is a global qbytearray which is the resulting joined up file
}
Then I write out the merged file:
QFile test("testout.mp3");
test.open(QIODevice::WriteOnly);
QDataStream writetest(&test);
writetest<< mergedaudio;
The resulting file (mp3) doesn't play correctly. I know this can be done as I used standard c++ to do it.
Any idea what I've done wrong?
Added after 5 minutes:
Oops. Was using the << which is for formatted data.