mirror of
https://github.com/taglib/taglib.git
synced 2026-02-11 01:40:19 -05:00
Initial attachments support
This commit is contained in:
committed by
Urs Fleisch
parent
6342f00e8b
commit
6d019a894c
@ -2,17 +2,20 @@
|
||||
#include "matroskafile.h"
|
||||
#include "matroskatag.h"
|
||||
#include "matroskasimpletag.h"
|
||||
#include "matroskaattachments.h"
|
||||
#include "matroskaattachedfile.h"
|
||||
#include "tfilestream.h"
|
||||
#include "tstring.h"
|
||||
#include "tutils.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2) {
|
||||
printf("Usage: matroskawriter FILE\n");
|
||||
if(argc != 3) {
|
||||
printf("Usage: matroskawriter FILE ARTWORK\n");
|
||||
return 1;
|
||||
}
|
||||
TagLib::Matroska::File file(argv[1]);
|
||||
if (!file.isValid()) {
|
||||
if(!file.isValid()) {
|
||||
printf("File is not valid\n");
|
||||
return 1;
|
||||
}
|
||||
@ -31,6 +34,19 @@ int main(int argc, char *argv[])
|
||||
simpleTag->setTargetTypeValue(TagLib::Matroska::SimpleTag::TargetTypeValue::Album);
|
||||
simpleTag->setValue("Test Value 2");
|
||||
tag->addSimpleTag(simpleTag);
|
||||
tag->setTitle("Test title");
|
||||
tag->setArtist("Test artist");
|
||||
tag->setYear(1969);
|
||||
|
||||
TagLib::FileStream image(argv[2]);
|
||||
auto data = image.readBlock(image.length());
|
||||
auto attachments = file.attachments(true);
|
||||
auto attachedFile = new TagLib::Matroska::AttachedFile();
|
||||
attachedFile->setFileName("cover.jpg");
|
||||
attachedFile->setMediaType("image/jpeg");
|
||||
attachedFile->setData(data);
|
||||
//attachedFile->setUID(5081000385627515072ull);
|
||||
attachments->addAttachedFile(attachedFile);
|
||||
|
||||
file.save();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user