Kotlin SDK for Jellyfin, supporting Android and JVM targets
Go to file
2020-07-20 21:48:52 +02:00
android Add Jellyfin class which should be used when using the library 2020-06-15 22:14:35 +02:00
gradle/wrapper Upgrade gradle wrapper to 6.3 2020-04-30 17:03:44 +02:00
library Merge pull request #69 from nielsvanvelzen/jellyfin-entry 2020-07-20 12:47:58 -04:00
model Add support for SearchTerm on ItemByNameQueries 2020-06-14 16:20:21 +02:00
samples/kotlin-console Add kotlin-console example using kotlinx.cli and the library 2020-07-20 21:48:52 +02:00
.editorconfig Use tabs for XML files 2020-05-01 11:12:37 +02:00
.gitignore Add gradle wrapper 2019-08-13 21:02:17 -04:00
azure-pipelines.yml Set up CI with Azure Pipelines 2019-09-11 13:09:16 -04:00
build.gradle.kts Ignore detekt failures 2020-06-01 16:51:28 +02:00
detekt.yml Add Detekt plugin 2020-06-01 16:48:57 +02:00
gradle.properties Fix issue with Bintray using the wrong versions 2020-05-13 12:18:03 +02:00
gradlew Upgrade gradle wrapper to 6.3 2020-04-30 17:03:44 +02:00
gradlew.bat Upgrade gradle wrapper to 6.3 2020-04-30 17:03:44 +02:00
LICENSE.md Update readme and copyright 2019-09-12 00:38:25 -04:00
README.md Add Jellyfin class which should be used when using the library 2020-06-15 22:14:35 +02:00
settings.gradle.kts Add kotlin-console example using kotlinx.cli and the library 2020-07-20 21:48:52 +02:00

Jellyfin

The Free Software Media System


Logo Banner

MIT license Current Release Azure DevOps builds
Donate Submit Feature Requests Discuss on our Forum Chat on Matrix Join our Subreddit Release RSS Feed Master Commits RSS Feed


This library allows Java and Android applications to easily access the Jellyfin API. It is built with Volley, OkHttp, Boon, and Robolectric. The dependencies are modular and can easily be swapped out with alternate implementations when desired.

Android Example

This is an example of connecting to a single server using a fixed address from an Android app that has requires a user login.

// Create a Jellyfin instance
val jellyfin = Jellyfin {
	// It is recommended to create an own logger implementation
	logger = NullLogger()
	android(context)
}

// Create a new api client
val apiClient = jellyfin.createApi(
	serverAddress = "http://localhost:8096",
	device = AndroidDevice.fromContext(context)
)

// Call authenticate function
apiClient.AuthenticateUserAsync("username", "password", object : Response<AuthenticationResult>() {
	override fun onResponse(result: AuthenticationResult) {
		// Authentication succeeded
	}

	override fun onError(error: Exception) {
		// Authentication failed
	}
})

Web Socket

Once you have an ApiClient instance you can easily connect to the server's web socket using the following command.

apiClient.OpenWebSocket()

This will open a connection in a background thread, and periodically check to ensure it's still connected. The web socket provides various events that can be used to receive notifications from the server. Simply override the methods in the ApiEventListener class which can be passed to the "createApi" function.

override fun onSetVolumeCommand(value: Int) {
}

Using Java

The Jellyfin library supports both Java and Kotlin out of the box. The basic Android example in Java looks like this

// Create the options using the options builder
JellyfinOptions.Builder options = new JellyfinOptions.Builder();
options.setLogger(new NullLogger());
JellyfinAndroidKt.android(options, context);

// Create a Jellyfin instance
Jellyfin jellyfin = new Jellyfin(options.build());

// Create a new api client
ApiClient apiClient = jellyfin.createApi(
		"http://localhost:8096",
		null,
		AndroidDevice.fromContext(context),
		new ApiEventListener()
);

// Call authenticate function
apiClient.AuthenticateUserAsync("username", "password", new Response<AuthenticationResult>() {
	@Override
	public void onResponse(AuthenticationResult response) {
		// Authentication succeeded
	}

	@Override
	public void onError(Exception exception) {
		// Authentication failed
	}
});