From 8ba4b4881a176944cd9e33865629dfdd58eea6ed Mon Sep 17 00:00:00 2001 From: Niels van Velzen Date: Sat, 2 Nov 2024 21:50:27 +0100 Subject: [PATCH] Add additional information to PlaybackStartInfo --- .../androidtv/data/compat/StreamInfo.java | 6 ++--- .../ui/playback/ExternalPlayerActivity.java | 2 +- .../ui/playback/PlaybackController.java | 2 +- .../util/apiclient/ReportingHelper.kt | 24 +++++++++++++++---- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/org/jellyfin/androidtv/data/compat/StreamInfo.java b/app/src/main/java/org/jellyfin/androidtv/data/compat/StreamInfo.java index fc2c8e16c5..9e42e6a165 100644 --- a/app/src/main/java/org/jellyfin/androidtv/data/compat/StreamInfo.java +++ b/app/src/main/java/org/jellyfin/androidtv/data/compat/StreamInfo.java @@ -34,14 +34,14 @@ public final void setMediaUrl(String value) { MediaUrl = value; } - private PlayMethod PlayMethod = getPlayMethod().values()[0]; + private PlayMethod playMethod = PlayMethod.DirectPlay; public final PlayMethod getPlayMethod() { - return PlayMethod; + return playMethod; } public final void setPlayMethod(PlayMethod value) { - PlayMethod = value; + playMethod = value; } private EncodingContext Context = EncodingContext.values()[0]; diff --git a/app/src/main/java/org/jellyfin/androidtv/ui/playback/ExternalPlayerActivity.java b/app/src/main/java/org/jellyfin/androidtv/ui/playback/ExternalPlayerActivity.java index 8ebe337690..7d0b0c1404 100644 --- a/app/src/main/java/org/jellyfin/androidtv/ui/playback/ExternalPlayerActivity.java +++ b/app/src/main/java/org/jellyfin/androidtv/ui/playback/ExternalPlayerActivity.java @@ -374,7 +374,7 @@ protected void startExternalActivity(String path, String container) { try { mLastPlayerStart = Instant.now().toEpochMilli(); - reportingHelper.getValue().reportStart(this, item, mPosition * RUNTIME_TICKS_TO_MS); + reportingHelper.getValue().reportStart(this, playbackControllerContainer.getValue().getPlaybackController(), item, mCurrentStreamInfo, mPosition * RUNTIME_TICKS_TO_MS, false); startReportLoop(); startActivityForResult(external, 1); } catch (ActivityNotFoundException e) { diff --git a/app/src/main/java/org/jellyfin/androidtv/ui/playback/PlaybackController.java b/app/src/main/java/org/jellyfin/androidtv/ui/playback/PlaybackController.java index 0333809179..43755b8fb3 100644 --- a/app/src/main/java/org/jellyfin/androidtv/ui/playback/PlaybackController.java +++ b/app/src/main/java/org/jellyfin/androidtv/ui/playback/PlaybackController.java @@ -640,7 +640,7 @@ public void run() { } dataRefreshService.getValue().setLastPlayedItem(item); - reportingHelper.getValue().reportStart(mFragment, item, mbPos); + reportingHelper.getValue().reportStart(mFragment, PlaybackController.this, item, response, mbPos, false); return null; }); diff --git a/app/src/main/java/org/jellyfin/androidtv/util/apiclient/ReportingHelper.kt b/app/src/main/java/org/jellyfin/androidtv/util/apiclient/ReportingHelper.kt index c6643fb68d..0b43fb7481 100644 --- a/app/src/main/java/org/jellyfin/androidtv/util/apiclient/ReportingHelper.kt +++ b/app/src/main/java/org/jellyfin/androidtv/util/apiclient/ReportingHelper.kt @@ -23,16 +23,32 @@ class ReportingHelper( private val dataRefreshService: DataRefreshService, private val api: ApiClient, ) { - fun reportStart(lifecycleOwner: LifecycleOwner, item: BaseItemDto, position: Long) { + fun reportStart( + lifecycleOwner: LifecycleOwner, + playbackController: PlaybackController, + item: BaseItemDto, + streamInfo: StreamInfo, + position: Long, + paused: Boolean + ) { val info = PlaybackStartInfo( itemId = item.id, positionTicks = position, - canSeek = false, - isPaused = false, + canSeek = (streamInfo.runTimeTicks ?: 0) > 0, + isPaused = paused, + liveStreamId = streamInfo.mediaSource?.liveStreamId, + playSessionId = streamInfo.playSessionId, + playMethod = when (requireNotNull(streamInfo.playMethod)) { + PlayMethod.Transcode -> org.jellyfin.sdk.model.api.PlayMethod.TRANSCODE + PlayMethod.DirectStream -> org.jellyfin.sdk.model.api.PlayMethod.DIRECT_STREAM + PlayMethod.DirectPlay -> org.jellyfin.sdk.model.api.PlayMethod.DIRECT_PLAY + }, + audioStreamIndex = playbackController.audioStreamIndex, + subtitleStreamIndex = playbackController.subtitleStreamIndex, isMuted = false, - playMethod = org.jellyfin.sdk.model.api.PlayMethod.DIRECT_PLAY, repeatMode = RepeatMode.REPEAT_NONE, playbackOrder = PlaybackOrder.DEFAULT, + mediaSourceId = streamInfo.mediaSourceId, ) lifecycleOwner.lifecycleScope.launch {