Skip to content

Commit

Permalink
Don't report stopped playback if changing stream
Browse files Browse the repository at this point in the history
  • Loading branch information
3flex committed Nov 4, 2024
1 parent 1a59aa2 commit 3cd9151
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
21 changes: 14 additions & 7 deletions src/components/maincontroller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,19 @@ window.playerManager.addEventListener(
(mediaFinishedEvent): void => {
const playbackState = PlaybackManager.playbackState;

reportPlaybackStopped(playbackState, {
...getReportingParams(playbackState),
PositionTicks:
(mediaFinishedEvent.currentMediaTime ??
getCurrentPositionTicks(playbackState)) * TicksPerSecond
});
// Don't notify server or client if changing streams, but notify next time.
if (!playbackState.isChangingStream) {
reportPlaybackStopped(playbackState, {
...getReportingParams(playbackState),
PositionTicks:
(mediaFinishedEvent.currentMediaTime ??
getCurrentPositionTicks(playbackState)) * TicksPerSecond
});

defaultOnStop();
defaultOnStop();
} else {
playbackState.isChangingStream = false;
}
}
);

Expand Down Expand Up @@ -511,6 +516,8 @@ export async function changeStream(
// await stopActiveEncodings($scope.playSessionId);
//}

state.isChangingStream = true;

// @ts-expect-error is possible here
return await PlaybackManager.playItemInternal(state.item, {
audioStreamIndex: params.AudioStreamIndex ?? state.audioStreamIndex,
Expand Down
4 changes: 3 additions & 1 deletion src/components/playbackManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ export abstract class PlaybackManager {
item: BaseItemDto,
options: any // eslint-disable-line @typescript-eslint/no-explicit-any
): Promise<void> {
this.playbackState.isChangingStream = false;
DocumentManager.setAppStatus(AppStatus.Loading);

const maxBitrate = await getMaxBitrate();
Expand Down Expand Up @@ -286,7 +285,10 @@ export abstract class PlaybackManager {
loadRequestData.currentTime = ticksToSeconds(startPositionTicks);
}

const isChangingStream = this.playbackState.isChangingStream;

load(mediaInfo.customData, item);
this.playbackState.isChangingStream = isChangingStream;
this.playerManager.load(loadRequestData);

this.playbackState.PlaybackMediaSource = mediaSource;
Expand Down

0 comments on commit 3cd9151

Please sign in to comment.