Skip to content

tumugin/taglib-ndk

 
 

Repository files navigation

taglib-ndk

Android NDK(Java) wrapper for taglib.

THIS IS EXPERIMENTAL PROJECT!!!! Not all APIs are wrapped and might be unstable.

How to use in your App

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 this repository

git clone under src/main/cpp/.

Generate Java/C++ wrapper files

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

Write build settings

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.

Use taglib from Java/Kotlin code

Load libs before using

// make sure... it's not "libtag"(it will load liblibtag)
System.loadLibrary("tag")

Load some Flac or MP3 and get 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)

About

Android NDK(Java) wrapper for taglib.

Resources

License

LGPL-2.1, Unknown licenses found

Licenses found

LGPL-2.1
COPYING.LGPL
Unknown
COPYING.MPL

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 96.9%
  • CMake 2.3%
  • Other 0.8%