Skip to content

Commit

Permalink
Merge branch 'jellyfin:master' into feature/zoom-setting
Browse files Browse the repository at this point in the history
  • Loading branch information
JagerSprinkles committed Sep 29, 2024
2 parents ca2429f + 0cfffdb commit a7a5e70
Show file tree
Hide file tree
Showing 18 changed files with 112 additions and 21 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/app-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ permissions:
jobs:
build:
name: Build
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Setup Java
uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 # v4.3.0
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0
with:
distribution: temurin
java-version: 17
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/app-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ permissions:
jobs:
lint:
name: Lint
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Setup Java
uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 # v4.3.0
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0
with:
distribution: temurin
java-version: 17
Expand All @@ -28,7 +28,7 @@ jobs:
- name: Run detekt and lint tasks
run: ./gradlew detekt lint
- name: Upload SARIF files
uses: github/codeql-action/upload-sarif@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8
uses: github/codeql-action/upload-sarif@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9
if: ${{ always() }}
with:
sarif_file: .
6 changes: 3 additions & 3 deletions .github/workflows/app-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ on:
jobs:
publish:
name: Publish
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
if: ${{ contains(github.repository_owner, 'jellyfin') }}
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Setup Java
uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 # v4.3.0
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0
with:
distribution: temurin
java-version: 17
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/app-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ permissions:
jobs:
test:
name: Test
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Setup Java
uses: actions/setup-java@2dfa2011c5b2a0f1489bf9e433881c92c1631f88 # v4.3.0
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0
with:
distribution: temurin
java-version: 17
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gradlew-validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ permissions:
jobs:
validate:
name: Validate
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0
2 changes: 1 addition & 1 deletion .github/workflows/repo-merge-conflict.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
triage:
name: Triage
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
if: ${{ contains(github.repository_owner, 'jellyfin') }}
steps:
- uses: eps1lon/actions-label-merge-conflict@1b1b1fcde06a9b3d089f3464c96417961dde1168 # v3.0.2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/repo-stale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
jobs:
triage:
name: Triage
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
if: ${{ contains(github.repository_owner, 'jellyfin') }}
steps:
- uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class MainActivity : FragmentActivity() {
if (savedInstanceState == null && navigationRepository.canGoBack) navigationRepository.reset(clearHistory = true)

navigationRepository.currentAction
.flowWithLifecycle(lifecycle, Lifecycle.State.RESUMED)
.flowWithLifecycle(lifecycle, Lifecycle.State.STARTED)
.onEach { action ->
handleNavigationAction(action)
backPressedCallback.isEnabled = navigationRepository.canGoBack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data.hasExtra(API_MX_RESULT_POSITION)) {
pos = data.getIntExtra(API_MX_RESULT_POSITION, 0);
} else if (data.hasExtra(API_VLC_RESULT_POSITION)) {
pos = data.getIntExtra(API_VLC_RESULT_POSITION, 0);
pos = (int) data.getLongExtra(API_VLC_RESULT_POSITION, 0);
} else if (data.hasExtra(API_VIMU_RESULT_POSITION)) {
pos = data.getIntExtra(API_VIMU_RESULT_POSITION, 0);
}
Expand Down
21 changes: 19 additions & 2 deletions app/src/main/res/values-nb/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<string name="msg_cannot_play">Dette elementet kunne ikke bli avspilt</string>
<string name="lbl_no_items">Ingen elementer</string>
<string name="lbl_empty">Tom</string>
<string name="lbl_tv_queuing">Legg til alle påfølgende episoder i køen</string>
<string name="lbl_tv_queuing">Spill av neste episode automatisk</string>
<string name="lbl_search_hint">Søk tekst (velg for tastatur)</string>
<string name="lbl_play_first_unwatched">Spill av første som ikke er sett</string>
<string name="lbl_mark_unplayed">Merk som usett</string>
Expand Down Expand Up @@ -407,7 +407,7 @@
<string name="app_notification_uimode_invalid">Denne appen er optimalisert for TV-er. Vi anbefaler å bruke mobilappen vår på andre enheter.</string>
<string name="server_unsupported_notification">Denne serveren bruker Jellyfin versjon %1$s, som ikke støttes. Oppdater til Jellyfin %2$s eller nyere for å fortsette å bruke appen.</string>
<string name="app_notification_beta">App oppdatert til %1$s
\nTakk for at du deltar i Jellyfin beta-programmet</string>
\nTakk for at du deltar i Jellyfin beta-programmet.</string>
<string name="pref_screensaver_inapp_enabled">Bruk skjermsparer i appen</string>
<string name="enable_reactive_homepage">Aktiver reaktiv hjemmeside</string>
<string name="pref_screensaver_inapp_enabled_description">Vis Jellyfin-skjermspareren mens appen er åpen</string>
Expand Down Expand Up @@ -539,4 +539,21 @@
<string name="pref_screensaver_ageratingrequired_enabled">Kun vis elementer med en aldersgrense</string>
<string name="pref_screensaver_ageratingrequired_disabled">Viser alle elementer</string>
<string name="all_channels">Alle kanaler</string>
<string name="lbl_subtitle_background_color">Bakgrunnsfarge for undertekst</string>
<string name="app_notification_update_soon">Oppdater tjeneren fra %1$s til minst %2$s for å fortsette å bruke appen etter neste oppdatering.</string>
<string name="prefer_exoplayer_ffmpeg">Foretrekk FFmpeg for lydavspilling</string>
<string name="prefer_exoplayer_ffmpeg_content">Bruk FFmpeg for å dekode lyd, selv om plattformkodeker er tilgjengelige.</string>
<string name="lbl_subtitle_text_stroke_color">Strekfarge for undertekst</string>
<string name="lbl_subtitle_text_color">Farge for undertekst</string>
<string name="pref_subtitles_size_very_small">Veldig liten</string>
<string name="pref_subtitles_size_small">Liten</string>
<string name="pref_subtitles_size_normal">Normal</string>
<string name="pref_subtitles_size_large">Stor</string>
<string name="pref_subtitles_size_very_large">Veldig stor</string>
<string name="current_queue">Aktuell kø</string>
<string name="past_week">Forrige uke</string>
<string name="pref_external_player">Bruk ekstern avspiller</string>
<string name="continue_listening">Fortsett å lytte</string>
<string name="past_24_hours">Siste 24 timene</string>
<string name="scheduled_in_next_24_hours">Planlagt i løpet av de neste 24 timene</string>
</resources>
18 changes: 18 additions & 0 deletions playback/core/src/main/kotlin/element/ElementsContainer.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
package org.jellyfin.playback.core.element

import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map
import java.util.concurrent.ConcurrentHashMap

/**
* Container to hold elements identified with an [ElementKey].
*/
open class ElementsContainer {
private val elements = ConcurrentHashMap<ElementKey<*>, Any?>()
private val updateFlow = MutableSharedFlow<ElementKey<*>>(
replay = 1,
extraBufferCapacity = 1,
onBufferOverflow = BufferOverflow.DROP_OLDEST,
)

fun <T : Any> get(key: ElementKey<T>): T = getOrNull(key)
?: error("No element found for key $key.")
Expand All @@ -18,9 +28,17 @@ open class ElementsContainer {

fun <T : Any> put(key: ElementKey<T>, value: T) {
elements[key] = value
updateFlow.tryEmit(key)
}

fun <T : Any> remove(key: ElementKey<T>) {
elements.remove(key)
updateFlow.tryEmit(key)
}

fun <T : Any> getFlow(key: ElementKey<T>): Flow<T?> {
return updateFlow
.map { getOrNull(key) }
.distinctUntilChanged()
}
}
9 changes: 9 additions & 0 deletions playback/core/src/main/kotlin/element/delegates.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jellyfin.playback.core.element

import kotlinx.coroutines.flow.Flow
import kotlin.properties.ReadOnlyProperty
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty

Expand Down Expand Up @@ -38,3 +40,10 @@ fun <T : Any> requiredElement(
thisRef.put(key, value)
}
}

/**
* Delegate for the flow of an element.
*/
fun <T : Any> elementFlow(
key: ElementKey<T>,
) = ReadOnlyProperty<ElementsContainer, Flow<T?>> { thisRef, _ -> thisRef.getFlow(key) }
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.jellyfin.playback.core.mediastream

import org.jellyfin.playback.core.element.ElementKey
import org.jellyfin.playback.core.element.element
import org.jellyfin.playback.core.element.elementFlow
import org.jellyfin.playback.core.queue.QueueEntry

private val mediaStreamKey = ElementKey<PlayableMediaStream>("MediaStream")
Expand All @@ -10,3 +11,8 @@ private val mediaStreamKey = ElementKey<PlayableMediaStream>("MediaStream")
* Get or set the [MediaStream] for this [QueueEntry].
*/
var QueueEntry.mediaStream by element(mediaStreamKey)

/**
* Get the [MediaStream] flow for this [QueueEntry].
*/
val QueueEntry.mediaStreamFlow by elementFlow(mediaStreamKey)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.jellyfin.playback.core.mediastream

import org.jellyfin.playback.core.element.ElementKey
import org.jellyfin.playback.core.element.element
import org.jellyfin.playback.core.element.elementFlow
import org.jellyfin.playback.core.queue.QueueEntry

private val normalizationGainKey = ElementKey<Float>("NormalizationGain")
Expand All @@ -11,3 +12,9 @@ private val normalizationGainKey = ElementKey<Float>("NormalizationGain")
* apply a gain to the audio output. The normalization gain must target a loudness of -23LUFS.
*/
var QueueEntry.normalizationGain by element(normalizationGainKey)

/**
* Get the flow of [normalizationGain].
* @see normalizationGain
*/
val QueueEntry.normalizationGainFlow by elementFlow(normalizationGainKey)
7 changes: 7 additions & 0 deletions playback/core/src/main/kotlin/queue/QueueEntryMetadata.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jellyfin.playback.core.queue

import org.jellyfin.playback.core.element.ElementKey
import org.jellyfin.playback.core.element.elementFlow
import org.jellyfin.playback.core.element.requiredElement
import java.time.LocalDate
import kotlin.time.Duration
Expand Down Expand Up @@ -42,3 +43,9 @@ private val metadataKey = ElementKey<QueueEntryMetadata>("QueueEntryMetadata")
* Get or set the [QueueEntryMetadata] for this [QueueEntry]. Defaults to [QueueEntryMetadata.Empty].
*/
var QueueEntry.metadata by requiredElement(metadataKey) { QueueEntryMetadata.Empty }

/**
* Get the flow of [metadata].
* @see metadata
*/
val QueueEntry.metadataFlow by elementFlow(metadataKey)
14 changes: 14 additions & 0 deletions playback/core/src/main/kotlin/queue/QueueService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import org.jellyfin.playback.core.PlaybackManager
import org.jellyfin.playback.core.backend.PlayerBackendEventListener
import org.jellyfin.playback.core.mediastream.PlayableMediaStream
import org.jellyfin.playback.core.model.PlayState
import org.jellyfin.playback.core.model.PlaybackOrder
import org.jellyfin.playback.core.model.RepeatMode
import org.jellyfin.playback.core.plugin.PlayerService
Expand Down Expand Up @@ -44,6 +47,17 @@ class QueueService internal constructor() : PlayerService(), Queue {
PlaybackOrder.SHUFFLE -> ShuffleOrderIndexProvider()
}
}.launchIn(coroutineScope)

// Automatically advance when current stream ends
manager.backendService.addListener(object : PlayerBackendEventListener {
override fun onPlayStateChange(state: PlayState) = Unit
override fun onVideoSizeChange(width: Int, height: Int) = Unit
override fun onMediaStreamEnd(mediaStream: PlayableMediaStream) {
coroutineScope.launch {
next(usePlaybackOrder = true, useRepeatMode = true)
}
}
})
}

// Entry management
Expand Down
6 changes: 6 additions & 0 deletions playback/jellyfin/src/main/kotlin/queue/baseItemElement.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.jellyfin.playback.jellyfin.queue

import org.jellyfin.playback.core.element.ElementKey
import org.jellyfin.playback.core.element.element
import org.jellyfin.playback.core.element.elementFlow
import org.jellyfin.playback.core.queue.QueueEntry
import org.jellyfin.sdk.model.api.BaseItemDto

Expand All @@ -11,3 +12,8 @@ private val baseItemKey = ElementKey<BaseItemDto>("BaseItemDto")
* Get or set the [BaseItemDto] for this [QueueEntry].
*/
var QueueEntry.baseItem by element(baseItemKey)

/**
* Get the [BaseItemDto] flow for this [QueueEntry].
*/
val QueueEntry.baseItemFlow by elementFlow(baseItemKey)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.jellyfin.playback.jellyfin.queue

import org.jellyfin.playback.core.element.ElementKey
import org.jellyfin.playback.core.element.element
import org.jellyfin.playback.core.element.elementFlow
import org.jellyfin.playback.core.queue.QueueEntry

private val mediaSourceIdKey = ElementKey<String>("MediaSource")
Expand All @@ -11,3 +12,9 @@ private val mediaSourceIdKey = ElementKey<String>("MediaSource")
* behavior.
*/
var QueueEntry.mediaSourceId by element(mediaSourceIdKey)

/**
* Get the flow of [mediaSourceId].
* @see mediaSourceId
*/
val QueueEntry.mediaSourceIdFlow by elementFlow(mediaSourceIdKey)

0 comments on commit a7a5e70

Please sign in to comment.