Jellyfin is a next-generation Java ME platform that can be run on Android and other devices. With Jellyfin, you can speed up your Java ME application development, provide a fast and stable platform for your application development, and save the development cost. In addition, Jellyfin can run on all Android devices, including Android TV, Android Handets, Android Tablets, and more.
This is a brief overview of the current state of Kotlin support in Jellyfin, the Android SDK for JavaScript. Jellyfin supports Android and the JVM, and currently supports the Kotlin language. Please check out the resources section for links to the documentation, API reference and blog posts.
Jellyfin Kotlin SDK
The Jellyfin Kotlin SDK is a library that implements the Jellyfin API for easy access to servers. It is currently available for the JVM and Android 4.4 and above. Java 8 or higher required. In Android versions lower than Android 8, you need to use the de-oiling libraries.
Setting
The versions are published on mavenCentral(). Make sure you are using the correct library for the platform. Gradle with Kotlin DSL implementation(org.jellyfin.sdk:jellyfin-core:$sdkVersion) // Or when using the Android implementation (org.jellyfin.sdk:jellyfin-platform-android:$sdkVersion) Gradle with Groovy implementation org.jellyfin.sdk:jellyfin-core:$sdkVersion // Or if you are using the Android implementation org.jellyfin.sdk:jellyfin-platform-android:$sdkVersion Maven org.jellyfin.sdk jellyfin-core $sdkVersion org.jellyfin.sdk jellyfin-platform-android $sdkVersion Using SNAPSHOT versions If you’re working on new features in your application, you may need to create an SDK targeting the next server version. For this use case, we publish two SNAPSHOT versions: master-SNAPSHOT and openapi-unstable-SNAPSHOT. To use the snapshot versions of , add a snapshot store to your build script: https://s01.oss.sonatype.org/content/repositories/snapshots/ An example of using Gradle with the Kotlin DSL which only allows the SNAPSHOT master version: Repositories { maven(https://s01.oss.sonatype.org/content/repositories/snapshots/) { content { // Allow only SDK snapshots includeVersionByRegex(org.jellyfin.sdk, .*, master-SNAPSHOT) } } }
Use
Create a jellyfin instance
Most SDK functions require an instance of the Jellyfin class. This class contains the configurations needed to create platform-specific API calls and options. The Jellyfin class can be instantiated with its own Kotlin DSL: val jellyfin = Jellyfin { clientInfo = ClientInfo(name = My awesome client!, version = 1.33.7,) // Do not comment if you are not using jellyfin-platform-android : // deviceInfo = DeviceInfo(id = UUID.randomUUID().toString(), name = Awesome device,) // Do not comment when using jellyfin-platform-android : // android() } Be sure to provide client and device information when making API calls. Use the android() helper function when working with Android to enable server discovery and automatically set device information.
Create API instance
API calls require an API instance. This can be done with the createApi function. This requires a server address of . Customer and device information is set automatically, but can be changed. All properties can be changed later in the API instance. val api = jellyfin.createApi( baseUrl = https://demo.jellyfin.org/stable/, // optional options : // accessToken = access token or api key // clientInfo = ClientInfo(), // default to parent information // deviceInfo = DeviceInfo(), // default to parent information // httpClientOptions = HttpClientOptions() // allow additional options )
User Authentication
All API operations are grouped together. To use this operation, you must create an instance of group and pass your API instance to it. val userApi = UserApi(api) try { trap authenticationResult by userApi.authenticateUserByName( username = demo, password = , ) // Use the access token in the Api instance api.accessToken = authenticationResult.accessToken // display session information println(authenticationResult.sessionInfo) } catch(err : ApiClientException) { // catch exceptions println(Something went wrong ! ${err.message}) }
WebSockets
Jellyfin uses WebSockets to communicate events such as library changes and actions. This API can be used with a special WebSocketApi class. val webSocketApi = WebSocketApi(api) // publish messages webSocketApi.publish(ActivityLogEntryStartMessage() webSocketApi.publish(SessionsStartMessage()) webSocketApi.publish(ScheduledTasksInfoStartMessage()) // Waiting for messages webSocketApi.subscribe().collect { message -> println(message) }
Server opening
The server search function allows you to search for servers on the local network, normalize the entered server addresses, and determine the best server from the list of addresses. // Discover local network servers jellyfin.discovery.discoverLocalServers().collect { println(Server ${it.name} was found at address ${it.address}) } // Get all candidates for a given item val candidates = jellyfin.discovery.getAddressCandidates(demo.jellyfin.org/stable) // Get the stream of potential servers to connect to val recommended = jellyfin.discovery.getRecommendedServers(candidates, RecommendedServerInfoScore.GOOD)
Other examples
We offer several small projects in a sample folder. The samples are used to test the new possibilities of the and can be used as a basis for your own application.
GitHub
https://github.com/jellyfin/jellyfin-sdk-kotlin
Related Tags:
jellyfin-android githubjellyfin githubjellyfin rest apijellyfin android tvjellyfin-vueemby api,People also search for,Privacy settings,How Search works,jellyfin-android github,jellyfin github,jellyfin rest api,jellyfin android tv,jellyfin-vue,emby api,jellyfin mobile download,jellyfin repositories