Android NDK(Java) wrapper for taglib.
THIS IS EXPERIMENTAL PROJECT!!!! Not all APIs are wrapped and might be unstable.
You must have these dependencies installed on Android SDK
before you start.
- Android NDK
- CMake
Also Swig
is required to generate wrapper files.
- Swig(install this from apt or brew...or whatever you use)
git clone
under src/main/cpp/
.
cd taglib/swig
swig -java -c++ -package com.yourapp.taglib -outdir /(path_to_your_project_root)/app/src/main/java/com/yourapp/taglib -o swigout/swig_taglib_wrap.cpp taglib.i
Open your build.gradle
and add this.
android {
defaultConfig {
externalNativeBuild {
cmake {
cppFlags "-std=c++14 -frtti -fexceptions"
}
}
}
externalNativeBuild {
cmake {
path "src/main/cpp/taglib/CMakeLists.txt"
}
}
}
Hit 🔨build
on your Android Studio and make sure it builds successfully.
// make sure... it's not "libtag"(it will load liblibtag)
System.loadLibrary("tag")
val fileRef = FileRef("/sdcard/01_girls_in_the_frontier (M@STER VERSION).flac")
val tag = fileRef.tag()
// get title and artist
val title = tag.title()
val artist = tag.artist()
// get additional tags
// check if the tag exists(accessing non exist item will SIGSEGV crash)
val comment = if (tag.properties().contains("COMMENT")) {
tag.properties()["COMMENT"].front()
} else {
""
}
// get cover art(will return empty array when cover art does not exist)
val imageArray = fileRef.GetCoverArt()
val bitmap = BitmapFactory.decodeByteArray(imageArray, 0, imageArray.size)