Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional information to PlaybackStartInfo #4147

Merged
merged 1 commit into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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
) {
Comment on lines +26 to +33

Check warning

Code scanning / detekt

The more parameters a function has the more complex it is. Long parameter lists are often used to control complex algorithms and violate the Single Responsibility Principle. Prefer functions with short parameter lists. Warning

The function reportStart(lifecycleOwner: LifecycleOwner, playbackController: PlaybackController, item: BaseItemDto, streamInfo: StreamInfo, position: Long, paused: Boolean) has too many parameters. The current threshold is set to 6.
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
Loading