Giter Site home page Giter Site logo

hendriks73 / jitlibrary Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 505 KB

Java API for the native Apple iTunes Library Framework for Music.app and iTunes (macOS)

License: GNU Lesser General Public License v2.1

Java 53.96% Objective-C 45.07% C 0.97%
objective-c itunes itunes-library java music apple macos

jitlibrary's Introduction

LGPL 2.1 Maven Central Build and Test CodeCov

jITLibrary

jITLibrary is a thin wrapper around the Apple iTunes Library Framework, which - despite its name - can also be used to access Music.app data. Note that the API is read-only, just like Apple's framework. For write access, see Obstmusic or Obstunes.

Important

You must code sign your app to retrieve information with this framework, and iTunes library access is read-only. This framework is available to users with iTunes 11 or later (also Music.app).

Installation

jITLibrary is released via Maven. You can install it via the following dependency:

<dependencies>
    <dependency>
        <groupId>com.tagtraum</groupId>
        <artifactId>jitlibrary</artifactId>
    </dependency>
</dependencies>

Java Module

jITLibrary is shipped as a Java module (see JPMS) with the name tagtraum.jitlibrary.

Usage

Once you have obtained an ITLibrary instance you may access its ITMediaItems and ITPlaylists as you like.

Example:

import com.tagtraum.jitlibrary.*;

public class ListAllMediaItems {

    public static void main(final String args) throws Exception {
        // get library (blocking call)
        final ITLibrary itLibrary = ITLibrary.getInstance(true);
        // get the natively backed collection
        final ITLibMediaItems allMediaItems = itLibrary.getAllMediaItems();
        
        // print size if library
        final int length = allMediaItems.size();
        System.out.println("Library size: " + length);

        // iterate over the library and print names and artists
        for (int i=0; i<length; i++) {
            final ITLibMediaItem item = allMediaItems.getMediaItem(i);
            System.out.println("Item named " + item.getName() + " by " + item.getArtist());
        }
    }
}

Note that you should not call ITLibrary.getInstance(..) from the Event Dispatch Thread (EDT, i.e. the AWT/Swing thread). Also note that this library is not necessarily thread-safe.

Logging

jITLibrary uses java.util.logging.

Known Shortcomings

  • Apple's code signing requirement sucks
  • thread safety may be an issue
  • reloading data after changes my not be quick

API

You can find the complete API here.

Additional Resources

jitlibrary's People

Contributors

hendriks73 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.