Skip to content

Commit

Permalink
Add additional information to PlaybackStartInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed Nov 2, 2024
1 parent ef4e2b5 commit ef25757
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit ef25757

Please sign in to comment.