Post capabilities when creating Home View Model
This commit is contained in:
parent
21067bd7d0
commit
f7ef7736ac
4 changed files with 30 additions and 17 deletions
|
@ -26,6 +26,8 @@ interface JellyfinRepository {
|
|||
|
||||
suspend fun getStreamUrl(itemId: UUID, mediaSourceId: String): String
|
||||
|
||||
suspend fun postCapabilities()
|
||||
|
||||
suspend fun postPlaybackStart(itemId: UUID)
|
||||
|
||||
suspend fun postPlaybackStop(itemId: UUID, positionTicks: Long)
|
||||
|
|
|
@ -145,6 +145,30 @@ class JellyfinRepositoryImpl(private val jellyfinApi: JellyfinApi) : JellyfinRep
|
|||
return streamUrl
|
||||
}
|
||||
|
||||
override suspend fun postCapabilities() {
|
||||
Timber.d("Sending capabilities")
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.sessionApi.postCapabilities(
|
||||
playableMediaTypes = listOf("Video"),
|
||||
supportedCommands = listOf(
|
||||
GeneralCommandType.VOLUME_UP,
|
||||
GeneralCommandType.VOLUME_DOWN,
|
||||
GeneralCommandType.TOGGLE_MUTE,
|
||||
GeneralCommandType.SET_AUDIO_STREAM_INDEX,
|
||||
GeneralCommandType.SET_SUBTITLE_STREAM_INDEX,
|
||||
GeneralCommandType.MUTE,
|
||||
GeneralCommandType.UNMUTE,
|
||||
GeneralCommandType.SET_VOLUME,
|
||||
GeneralCommandType.DISPLAY_MESSAGE,
|
||||
GeneralCommandType.PLAY,
|
||||
GeneralCommandType.PLAY_STATE,
|
||||
GeneralCommandType.PLAY_NEXT,
|
||||
GeneralCommandType.PLAY_MEDIA_SOURCE
|
||||
), supportsMediaControl = true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun postPlaybackStart(itemId: UUID) {
|
||||
Timber.d("Sending start $itemId")
|
||||
withContext(Dispatchers.IO) {
|
||||
|
|
|
@ -43,6 +43,9 @@ constructor(
|
|||
|
||||
init {
|
||||
loadData()
|
||||
viewModelScope.launch {
|
||||
jellyfinRepository.postCapabilities()
|
||||
}
|
||||
}
|
||||
|
||||
fun loadData() {
|
||||
|
|
|
@ -43,31 +43,15 @@ constructor(
|
|||
}
|
||||
|
||||
fun connectToServer(server: Server) {
|
||||
val jellyfinApi = JellyfinApi.newInstance(application, server.address).apply {
|
||||
JellyfinApi.newInstance(application, server.address).apply {
|
||||
api.accessToken = server.accessToken
|
||||
userId = UUID.fromString(server.userId)
|
||||
}
|
||||
|
||||
viewModelScope.launch {
|
||||
postCapabilities(jellyfinApi)
|
||||
}
|
||||
|
||||
|
||||
_navigateToMain.value = true
|
||||
}
|
||||
|
||||
fun doneNavigatingToMain() {
|
||||
_navigateToMain.value = false
|
||||
}
|
||||
|
||||
private suspend fun postCapabilities(jellyfinApi: JellyfinApi) {
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.sessionApi.postCapabilities(
|
||||
playableMediaTypes = listOf("Video"),
|
||||
supportsMediaControl = false,
|
||||
supportsSync = false,
|
||||
supportsPersistentIdentifier = true
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue