mirror of
https://github.com/taglib/taglib.git
synced 2026-02-09 17:00:20 -05:00
Added write support
This commit is contained in:
committed by
Urs Fleisch
parent
47e9b9a17c
commit
80837485cf
@ -44,6 +44,11 @@ target_link_libraries(strip-id3v1 tag)
|
||||
add_executable(matroskareader matroskareader.cpp)
|
||||
target_link_libraries(matroskareader tag)
|
||||
|
||||
########### next target ###############
|
||||
|
||||
add_executable(matroskawriter matroskawriter.cpp)
|
||||
target_link_libraries(matroskawriter tag)
|
||||
|
||||
install(TARGETS tagreader tagreader_c tagwriter framelist strip-id3v1
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
|
||||
37
examples/matroskawriter.cpp
Normal file
37
examples/matroskawriter.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include <cstdio>
|
||||
#include "matroskafile.h"
|
||||
#include "matroskatag.h"
|
||||
#include "matroskasimpletag.h"
|
||||
#include "tstring.h"
|
||||
#include "tutils.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2) {
|
||||
printf("Usage: matroskawriter FILE\n");
|
||||
return 1;
|
||||
}
|
||||
TagLib::Matroska::File file(argv[1]);
|
||||
if (!file.isValid()) {
|
||||
printf("File is not valid\n");
|
||||
return 1;
|
||||
}
|
||||
auto tag = file.tag(true);
|
||||
tag->clearSimpleTags();
|
||||
|
||||
auto simpleTag = new TagLib::Matroska::SimpleTagString();
|
||||
simpleTag->setName("Test Name 1");
|
||||
simpleTag->setTargetTypeValue(TagLib::Matroska::SimpleTag::TargetTypeValue::Track);
|
||||
simpleTag->setValue("Test Value 1");
|
||||
tag->addSimpleTag(simpleTag);
|
||||
|
||||
simpleTag = new TagLib::Matroska::SimpleTagString();
|
||||
simpleTag->setName("Test Name 2");
|
||||
simpleTag->setTargetTypeValue(TagLib::Matroska::SimpleTag::TargetTypeValue::Album);
|
||||
simpleTag->setValue("Test Value 2");
|
||||
tag->addSimpleTag(simpleTag);
|
||||
|
||||
file.save();
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user